on xenial help sign in
move the impl to Shell

so that we can show it on top of panels

commit6bb8a904b1f32264ab5f4a41cb9fc58c09f3dbbf authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 26 Apr 2016, 11:36 (11 years ago) parentf1be3e6
5 files changed+80−77
plugins/Ubuntu/Gestures/TouchGestureArea.h+3−3 qml/Shell.qml+9 qml/Stages/AbstractStage.qml+1 qml/Stages/DesktopStage.qml+2−8 qml/Stages/WindowControlsOverlay.qml+65−66
plugins/Ubuntu/Gestures/TouchGestureArea.h+3−3
@@ -106,8 +106,8 @@ private:
106106/*
107107 An area that detects multi-finger gestures.
108108
109− We can use this to detect gestures contstrained by a minimim and/or maximum number of touch points.
110− This components uses the touch registry to apply for ownership of touch points.
109+ We can use this to detect gestures constrained by a minimum and/or maximum number of touch points.
110+ This component uses the touch registry to apply for ownership of touch points.
111111 This way we can use the component in conjuntion with the directional drag area to compete for ownwership
112112 or gestures; unlike the MultiPointTouchArea.
113113 */
@@ -176,7 +176,7 @@ Q_SIGNALS:
176176 void clicked();
177177
178178protected:
179− void itemChange(ItemChange change, const ItemChangeData &value);
179+ void itemChange(ItemChange change, const ItemChangeData &value) override;
180180
181181private Q_SLOTS:
182182 void rejectGesture();
qml/Shell.qml+9
@@ -541,6 +541,15 @@ Item {
541541 locked: greeter && greeter.active
542542 }
543543
544+ WindowControlsOverlay {
545+ x: target ? target.x : -1
546+ y: target ? target.y : -1
547+ width: target ? target.width : undefined
548+ height: target? target.height : undefined
549+ target: applicationsDisplayLoader.item && applicationsDisplayLoader.item.mainAppDelegate ? applicationsDisplayLoader.item.mainAppDelegate : null
550+ onActivated: MirFocusController.focusedSurface = target
551+ }
552+
544553 Launcher {
545554 id: launcher
546555 objectName: "launcher"
qml/Stages/AbstractStage.qml+1
@@ -52,6 +52,7 @@ FocusScope {
5252
5353 // To be read from outside
5454 property var mainApp: null
55+ property var mainAppDelegate: null
5556 property int mainAppWindowOrientationAngle: 0
5657 property bool orientationChangesEnabled
5758 property int supportedOrientations: Qt.PortraitOrientation
qml/Stages/DesktopStage.qml+2−8
@@ -40,6 +40,7 @@ AbstractStage {
4040 property bool spreadShown: spread.state == "altTab"
4141
4242 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
43+ mainAppDelegate: priv.focusedAppDelegate
4344
4445 // application windows never rotate independently
4546 mainAppWindowOrientationAngle: shellOrientationAngle
@@ -283,6 +284,7 @@ AbstractStage {
283284 property bool visuallyMinimized: false
284285
285286 readonly property var surface: model.surface
287+ readonly property alias resizeArea: resizeArea
286288
287289 function claimFocus() {
288290 if (spread.state == "altTab") {
@@ -604,14 +606,6 @@ AbstractStage {
604606 onDecorationPressed: { appDelegate.focus = true; }
605607 }
606608
607− WindowControlsOverlay {
608− anchors.fill: resizeArea
609− target: appDelegate
610− resizeTarget: resizeArea
611− borderThickness: resizeArea.borderThickness
612− onActivated: ApplicationManager.focusApplication(model.appId)
613− }
614−
615609 WindowedFullscreenPolicy {
616610 id: fullscreenPolicy
617611 active: true
qml/Stages/WindowControlsOverlay.qml+65−66
@@ -21,10 +21,9 @@ import "../Components/PanelState"
2121
2222Item {
2323 id: root
24+
2425 // to be set from outside
2526 property Item target // appDelegate
26− property Item resizeTarget // WindowResizeArea
27− property int borderThickness
2827
2928 signal activated
3029
@@ -33,7 +32,7 @@ Item {
3332 anchors.fill: parent
3433
3534 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
36− minimumTouchPoints: 3
35+ minimumTouchPoints: 2
3736 maximumTouchPoints: minimumTouchPoints
3837
3938 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
@@ -53,49 +52,7 @@ Item {
5352 Timer {
5453 id: overlayTimer
5554 interval: 2000
56− repeat: priv.dragging || root.resizeTarget.dragging
57− }
58−
59−
60− // dismiss area
61− InverseMouseArea {
62− anchors.fill: overlay
63− visible: overlay.visible
64− enabled: visible
65− onPressed: {
66− overlayTimer.stop();
67− mouse.accepted = false;
68− }
69− propagateComposedEvents: true
70− }
71−
72−
73− // move handler
74− MouseArea {
75− anchors.fill: overlay
76− visible: overlay.visible
77− enabled: visible
78− hoverEnabled: true
79− cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
80−
81− onPressedChanged: {
82− if (pressed) {
83− var pos = mapToItem(root.target, mouseX, mouseY);
84− priv.distanceX = pos.x;
85− priv.distanceY = pos.y;
86− priv.dragging = true;
87− } else {
88− priv.dragging = false;
89− }
90− }
91−
92− onPositionChanged: {
93− if (priv.dragging) {
94− var pos = mapToItem(root.target.parent, mouseX, mouseY);
95− root.target.x = pos.x - priv.distanceX;
96− root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
97− }
98− }
55+ repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.dragging)
9956 }
10057
10158 QtObject {
@@ -103,6 +60,9 @@ Item {
10360 property real distanceX
10461 property real distanceY
10562 property bool dragging
63+
64+ readonly property var resizeArea: root.target && root.target.resizeArea ? root.target.resizeArea : null
65+ readonly property int borderThickness: priv.resizeArea ? priv.resizeArea.borderThickness : 0
10666 }
10767
10868
@@ -129,80 +89,119 @@ Item {
12989 anchors.centerIn: parent
13090 opacity: 0.95
13191 visible: target && target.width > units.gu(12) && target.height > units.gu(12)
92+
93+ // move handler
94+ MouseArea {
95+ anchors.fill: parent
96+ visible: overlay.visible
97+ enabled: visible
98+ hoverEnabled: true
99+ cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
100+
101+ onPressedChanged: {
102+ if (pressed) {
103+ var pos = mapToItem(root.target, mouseX, mouseY);
104+ priv.distanceX = pos.x;
105+ priv.distanceY = pos.y;
106+ priv.dragging = true;
107+ } else {
108+ priv.dragging = false;
109+ }
110+ }
111+
112+ onPositionChanged: {
113+ if (priv.dragging) {
114+ var pos = mapToItem(root.target.parent, mouseX, mouseY);
115+ root.target.x = pos.x - priv.distanceX;
116+ root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
117+ }
118+ }
119+ }
120+
121+ // dismiss area
122+ InverseMouseArea {
123+ anchors.fill: parent
124+ visible: overlay.visible
125+ enabled: visible
126+ onClicked: {
127+ overlayTimer.stop();
128+ mouse.accepted = false;
129+ }
130+ }
132131 }
133132
134133 ResizeGrip { // top left
135134 anchors.horizontalCenter: parent.left
136− anchors.horizontalCenterOffset: borderThickness
135+ //anchors.horizontalCenterOffset: priv.borderThickness
137136 anchors.verticalCenter: parent.top
138− anchors.verticalCenterOffset: borderThickness
137+ //anchors.verticalCenterOffset: priv.borderThickness
139138 visible: !overlay.anyMaximized
140− resizeTarget: root.resizeTarget
139+ resizeTarget: priv.resizeArea
141140 }
142141
143142 ResizeGrip { // top center
144143 anchors.horizontalCenter: parent.horizontalCenter
145144 anchors.verticalCenter: parent.top
146− anchors.verticalCenterOffset: borderThickness
145+ //anchors.verticalCenterOffset: priv.borderThickness
147146 rotation: 45
148147 visible: !overlay.anyMaximized
149− resizeTarget: root.resizeTarget
148+ resizeTarget: priv.resizeArea
150149 }
151150
152151 ResizeGrip { // top right
153152 anchors.horizontalCenter: parent.right
154− anchors.horizontalCenterOffset: -borderThickness
153+ //anchors.horizontalCenterOffset: -priv.borderThickness
155154 anchors.verticalCenter: parent.top
156− anchors.verticalCenterOffset: borderThickness
155+ //anchors.verticalCenterOffset: priv.borderThickness
157156 rotation: 90
158157 visible: !overlay.anyMaximized
159− resizeTarget: root.resizeTarget
158+ resizeTarget: priv.resizeArea
160159 }
161160
162161 ResizeGrip { // right
163162 anchors.horizontalCenter: parent.right
164− anchors.horizontalCenterOffset: -borderThickness
163+ //anchors.horizontalCenterOffset: -priv.borderThickness
165164 anchors.verticalCenter: parent.verticalCenter
166165 rotation: 135
167166 visible: target && !target.maximizedRight && !target.maximized
168− resizeTarget: root.resizeTarget
167+ resizeTarget: priv.resizeArea
169168 }
170169
171170 ResizeGrip { // bottom right
172171 anchors.horizontalCenter: parent.right
173− anchors.horizontalCenterOffset: -borderThickness
172+ //anchors.horizontalCenterOffset: -priv.borderThickness
174173 anchors.verticalCenter: parent.bottom
175− anchors.verticalCenterOffset: -borderThickness
174+ //anchors.verticalCenterOffset: -priv.borderThickness
176175 visible: !overlay.anyMaximized
177− resizeTarget: root.resizeTarget
176+ resizeTarget: priv.resizeArea
178177 }
179178
180179 ResizeGrip { // bottom center
181180 anchors.horizontalCenter: parent.horizontalCenter
182181 anchors.verticalCenter: parent.bottom
183− anchors.verticalCenterOffset: -borderThickness
182+ //anchors.verticalCenterOffset: -priv.borderThickness
184183 rotation: 45
185184 visible: !overlay.anyMaximized
186− resizeTarget: root.resizeTarget
185+ resizeTarget: priv.resizeArea
187186 }
188187
189188 ResizeGrip { // bottom left
190189 anchors.horizontalCenter: parent.left
191− anchors.horizontalCenterOffset: borderThickness
190+ //anchors.horizontalCenterOffset: priv.borderThickness
192191 anchors.verticalCenter: parent.bottom
193− anchors.verticalCenterOffset: -borderThickness
192+ //anchors.verticalCenterOffset: -priv.borderThickness
194193 rotation: 90
195194 visible: !overlay.anyMaximized
196− resizeTarget: root.resizeTarget
195+ resizeTarget: priv.resizeArea
197196 }
198197
199198 ResizeGrip { // left
200199 anchors.horizontalCenter: parent.left
201− anchors.horizontalCenterOffset: borderThickness
200+ //anchors.horizontalCenterOffset: priv.borderThickness
202201 anchors.verticalCenter: parent.verticalCenter
203202 rotation: 135
204203 visible: target && !target.maximizedLeft && !target.maximized
205− resizeTarget: root.resizeTarget
204+ resizeTarget: priv.resizeArea
206205 }
207206 }
208207}