on xenial help sign in
fix touch interactions with the window decorations
1ac2236Lukáš Tinkl
qml/ApplicationMenus/MenuBar.qml+6−4
@@ -77,7 +77,7 @@ Item {
77 anchors.fill: parent
77 anchors.fill: parent
78 enabled: d.currentItem != null
78 enabled: d.currentItem != null
79 hoverEnabled: enabled && d.currentItem && d.currentItem.__popup != null
79 hoverEnabled: enabled && d.currentItem && d.currentItem.__popup != null
80− onPressed: d.dismissAll()
80+ onPressed: { d.dismissAll(); mouse.accepted = false; }
81 }
81 }
82
82
83 Row {
83 Row {
@@ -229,13 +229,15 @@ Item {
229 if (d.currentItem) {
229 if (d.currentItem) {
230 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
230 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
231 }
231 }
232+ mouse.accepted = false;
232 }
233 }
233− onClicked: {
234+ onPressed: {
234 var prevItem = d.currentItem;
235 var prevItem = d.currentItem;
235 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
236 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
236 if (prevItem && d.currentItem == prevItem) {
237 if (prevItem && d.currentItem == prevItem) {
237 prevItem.hide();
238 prevItem.hide();
238 }
239 }
240+ mouse.accepted = false;
239 }
241 }
240
242
241 function updateCurrentItemFromPosition(point) {
243 function updateCurrentItemFromPosition(point) {
@@ -258,8 +260,8 @@ Item {
258
260
259 hoverEnabled: d.currentItem
261 hoverEnabled: d.currentItem
260 onEntered: d.currentItem = this
262 onEntered: d.currentItem = this
261− onPositionChanged: d.currentItem = this
263+ onPositionChanged: { d.currentItem = this; mouse.accepted = false; }
262− onClicked: d.currentItem = this
264+ onPressed: { d.currentItem = this; mouse.accepted = false; }
263
265
264 property Item __popup: null;
266 property Item __popup: null;
265 readonly property bool popupVisible: __popup && __popup.visible
267 readonly property bool popupVisible: __popup && __popup.visible
qml/Components/WindowControlButtons.qml−21
@@ -47,13 +47,6 @@ Row {
47 onClicked: root.closeClicked()
47 onClicked: root.closeClicked()
48 visible: root.closeButtonShown
48 visible: root.closeButtonShown
49
49
50− // We dont want touch events to fall through to parent,
51− // otherwise the containsMouse will not work.
52− MouseArea {
53− anchors.fill: parent
54− propagateComposedEvents: true
55− }
56−
57 Rectangle {
50 Rectangle {
58 anchors.fill: parent
51 anchors.fill: parent
59 anchors.margins: windowIsMaximized ? units.dp(3) : 0
52 anchors.margins: windowIsMaximized ? units.dp(3) : 0
@@ -78,13 +71,6 @@ Row {
78 onClicked: root.minimizeClicked()
71 onClicked: root.minimizeClicked()
79 visible: root.minimizeButtonVisible
72 visible: root.minimizeButtonVisible
80
73
81− // We dont want touch events to fall through to parent,
82− // otherwise the containsMouse will not work.
83− MouseArea {
84− anchors.fill: parent
85− propagateComposedEvents: true
86− }
87−
88 Rectangle {
74 Rectangle {
89 anchors.fill: parent
75 anchors.fill: parent
90 anchors.margins: windowIsMaximized ? units.dp(3) : 0
76 anchors.margins: windowIsMaximized ? units.dp(3) : 0
@@ -118,13 +104,6 @@ Row {
118 }
104 }
119 }
105 }
120
106
121− // We dont want touch events to fall through to parent,
122− // otherwise the containsMouse will not work.
123− MouseArea {
124− anchors.fill: parent
125− propagateComposedEvents: true
126− }
127−
128 Rectangle {
107 Rectangle {
129 anchors.fill: parent
108 anchors.fill: parent
130 anchors.margins: windowIsMaximized ? units.dp(3) : 0
109 anchors.margins: windowIsMaximized ? units.dp(3) : 0
qml/Stage/DecoratedWindow.qml+1
@@ -225,6 +225,7 @@ FocusScope {
225 enableMenus: {
225 enableMenus: {
226 return active &&
226 return active &&
227 surface &&
227 surface &&
228+ !moveHandler.moving &&
228 (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
229 (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
229 }
230 }
230 menu: sharedAppModel.model
231 menu: sharedAppModel.model
qml/Stage/MoveHandler.qml+4
@@ -29,6 +29,7 @@ QtObject {
29 property real boundsTopMargin: 0
29 property real boundsTopMargin: 0
30
30
31 readonly property bool dragging: priv.dragging
31 readonly property bool dragging: priv.dragging
32+ readonly property bool moving: priv.moving
32
33
33 signal fakeMaximizeAnimationRequested(real amount)
34 signal fakeMaximizeAnimationRequested(real amount)
34 signal fakeMaximizeLeftAnimationRequested(real amount)
35 signal fakeMaximizeLeftAnimationRequested(real amount)
@@ -43,6 +44,7 @@ QtObject {
43 property real distanceX
44 property real distanceX
44 property real distanceY
45 property real distanceY
45 property bool dragging
46 property bool dragging
47+ property bool moving
46
48
47 readonly property int triggerArea: units.gu(8)
49 readonly property int triggerArea: units.gu(8)
48 property bool nearLeftEdge: target.maximizedLeft
50 property bool nearLeftEdge: target.maximizedLeft
@@ -110,6 +112,7 @@ QtObject {
110
112
111 function handlePositionChanged(mouse, sensingPoints) {
113 function handlePositionChanged(mouse, sensingPoints) {
112 if (priv.dragging) {
114 if (priv.dragging) {
115+ priv.moving = true;
113 priv.mouseDownTimer.stop();
116 priv.mouseDownTimer.stop();
114 Mir.cursorName = "grabbing";
117 Mir.cursorName = "grabbing";
115
118
@@ -180,6 +183,7 @@ QtObject {
180 }
183 }
181
184
182 function handleReleased(touchMode) {
185 function handleReleased(touchMode) {
186+ priv.moving = false;
183 if (touchMode) {
187 if (touchMode) {
184 priv.progress = 0;
188 priv.progress = 0;
185 priv.resetEdges();
189 priv.resetEdges();
qml/Stage/WindowDecoration.qml−12
@@ -39,17 +39,12 @@ MouseArea {
39 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
39 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
40 hoverEnabled: true
40 hoverEnabled: true
41
41
42− drag.target: Item {}
43− drag.filterChildren: true
44− drag.threshold: 0
45−
46 signal closeClicked()
42 signal closeClicked()
47 signal minimizeClicked()
43 signal minimizeClicked()
48 signal maximizeClicked()
44 signal maximizeClicked()
49 signal maximizeHorizontallyClicked()
45 signal maximizeHorizontallyClicked()
50 signal maximizeVerticallyClicked()
46 signal maximizeVerticallyClicked()
51
47
52− onClicked: mouse.accepted = true // propogated event
53 onDoubleClicked: {
48 onDoubleClicked: {
54 if (mouse.button == Qt.LeftButton) {
49 if (mouse.button == Qt.LeftButton) {
55 root.maximizeClicked();
50 root.maximizeClicked();
@@ -69,13 +64,6 @@ MouseArea {
69 (menuBar.showRequested || root.containsMouse)
64 (menuBar.showRequested || root.containsMouse)
70 }
65 }
71
66
72− // We dont want touch events to fall through to parent as it expect some child MouseArea to have them
73− // If not some MouseArea in the menu bar, it will be this one.
74− MouseArea {
75− anchors.fill: parent
76− propagateComposedEvents: true
77− }
78−
79 Rectangle {
67 Rectangle {
80 id: background
68 id: background
81 anchors.fill: parent
69 anchors.fill: parent