on xenial help sign in
fix touch interactions with the window decorations

it was impossible to tap the window control buttons or open the menu popups using touch

commit1ac223602f552897649e6b34146bf02033d85ed3 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateSat 25 Feb 2017, 22:31 (10 years ago) parent71b62b7
5 files changed+11−37
qml/ApplicationMenus/MenuBar.qml+6−4 qml/Components/WindowControlButtons.qml−21 qml/Stage/DecoratedWindow.qml+1 qml/Stage/MoveHandler.qml+4 qml/Stage/WindowDecoration.qml−12
qml/ApplicationMenus/MenuBar.qml+6−4
@@ -77,7 +77,7 @@ Item {
7777 anchors.fill: parent
7878 enabled: d.currentItem != null
7979 hoverEnabled: enabled && d.currentItem && d.currentItem.__popup != null
80− onPressed: d.dismissAll()
80+ onPressed: { d.dismissAll(); mouse.accepted = false; }
8181 }
8282
8383 Row {
@@ -229,13 +229,15 @@ Item {
229229 if (d.currentItem) {
230230 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
231231 }
232+ mouse.accepted = false;
232233 }
233− onClicked: {
234+ onPressed: {
234235 var prevItem = d.currentItem;
235236 updateCurrentItemFromPosition(Qt.point(mouse.x, mouse.y))
236237 if (prevItem && d.currentItem == prevItem) {
237238 prevItem.hide();
238239 }
240+ mouse.accepted = false;
239241 }
240242
241243 function updateCurrentItemFromPosition(point) {
@@ -258,8 +260,8 @@ Item {
258260
259261 hoverEnabled: d.currentItem
260262 onEntered: d.currentItem = this
261− onPositionChanged: d.currentItem = this
262− onClicked: d.currentItem = this
263+ onPositionChanged: { d.currentItem = this; mouse.accepted = false; }
264+ onPressed: { d.currentItem = this; mouse.accepted = false; }
263265
264266 property Item __popup: null;
265267 readonly property bool popupVisible: __popup && __popup.visible
qml/Components/WindowControlButtons.qml−21
@@ -47,13 +47,6 @@ Row {
4747 onClicked: root.closeClicked()
4848 visible: root.closeButtonShown
4949
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−
5750 Rectangle {
5851 anchors.fill: parent
5952 anchors.margins: windowIsMaximized ? units.dp(3) : 0
@@ -78,13 +71,6 @@ Row {
7871 onClicked: root.minimizeClicked()
7972 visible: root.minimizeButtonVisible
8073
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−
8874 Rectangle {
8975 anchors.fill: parent
9076 anchors.margins: windowIsMaximized ? units.dp(3) : 0
@@ -118,13 +104,6 @@ Row {
118104 }
119105 }
120106
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−
128107 Rectangle {
129108 anchors.fill: parent
130109 anchors.margins: windowIsMaximized ? units.dp(3) : 0
qml/Stage/DecoratedWindow.qml+1
@@ -225,6 +225,7 @@ FocusScope {
225225 enableMenus: {
226226 return active &&
227227 surface &&
228+ !moveHandler.moving &&
228229 (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
229230 }
230231 menu: sharedAppModel.model
qml/Stage/MoveHandler.qml+4
@@ -29,6 +29,7 @@ QtObject {
2929 property real boundsTopMargin: 0
3030
3131 readonly property bool dragging: priv.dragging
32+ readonly property bool moving: priv.moving
3233
3334 signal fakeMaximizeAnimationRequested(real amount)
3435 signal fakeMaximizeLeftAnimationRequested(real amount)
@@ -43,6 +44,7 @@ QtObject {
4344 property real distanceX
4445 property real distanceY
4546 property bool dragging
47+ property bool moving
4648
4749 readonly property int triggerArea: units.gu(8)
4850 property bool nearLeftEdge: target.maximizedLeft
@@ -110,6 +112,7 @@ QtObject {
110112
111113 function handlePositionChanged(mouse, sensingPoints) {
112114 if (priv.dragging) {
115+ priv.moving = true;
113116 priv.mouseDownTimer.stop();
114117 Mir.cursorName = "grabbing";
115118
@@ -180,6 +183,7 @@ QtObject {
180183 }
181184
182185 function handleReleased(touchMode) {
186+ priv.moving = false;
183187 if (touchMode) {
184188 priv.progress = 0;
185189 priv.resetEdges();
qml/Stage/WindowDecoration.qml−12
@@ -39,17 +39,12 @@ MouseArea {
3939 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
4040 hoverEnabled: true
4141
42− drag.target: Item {}
43− drag.filterChildren: true
44− drag.threshold: 0
45−
4642 signal closeClicked()
4743 signal minimizeClicked()
4844 signal maximizeClicked()
4945 signal maximizeHorizontallyClicked()
5046 signal maximizeVerticallyClicked()
5147
52− onClicked: mouse.accepted = true // propogated event
5348 onDoubleClicked: {
5449 if (mouse.button == Qt.LeftButton) {
5550 root.maximizeClicked();
@@ -69,13 +64,6 @@ MouseArea {
6964 (menuBar.showRequested || root.containsMouse)
7065 }
7166
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−
7967 Rectangle {
8068 id: background
8169 anchors.fill: parent