on xenial help sign in
move the impl to Shell
6bb8a90Lukáš Tinkl
plugins/Ubuntu/Gestures/TouchGestureArea.h+3−3
@@ -106,8 +106,8 @@ private:
106/*
106/*
107 An area that detects multi-finger gestures.
107 An area that detects multi-finger gestures.
108
108
109− We can use this to detect gestures contstrained by a minimim and/or maximum number of touch points.
109+ We can use this to detect gestures constrained by a minimum and/or maximum number of touch points.
110− This components uses the touch registry to apply for ownership of touch points.
110+ This component uses the touch registry to apply for ownership of touch points.
111 This way we can use the component in conjuntion with the directional drag area to compete for ownwership
111 This way we can use the component in conjuntion with the directional drag area to compete for ownwership
112 or gestures; unlike the MultiPointTouchArea.
112 or gestures; unlike the MultiPointTouchArea.
113 */
113 */
@@ -176,7 +176,7 @@ Q_SIGNALS:
176 void clicked();
176 void clicked();
177
177
178protected:
178protected:
179− void itemChange(ItemChange change, const ItemChangeData &value);
179+ void itemChange(ItemChange change, const ItemChangeData &value) override;
180
180
181private Q_SLOTS:
181private Q_SLOTS:
182 void rejectGesture();
182 void rejectGesture();
qml/Shell.qml+9
@@ -541,6 +541,15 @@ Item {
541 locked: greeter && greeter.active
541 locked: greeter && greeter.active
542 }
542 }
543
543
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+
544 Launcher {
553 Launcher {
545 id: launcher
554 id: launcher
546 objectName: "launcher"
555 objectName: "launcher"
qml/Stages/AbstractStage.qml+1
@@ -52,6 +52,7 @@ FocusScope {
52
52
53 // To be read from outside
53 // To be read from outside
54 property var mainApp: null
54 property var mainApp: null
55+ property var mainAppDelegate: null
55 property int mainAppWindowOrientationAngle: 0
56 property int mainAppWindowOrientationAngle: 0
56 property bool orientationChangesEnabled
57 property bool orientationChangesEnabled
57 property int supportedOrientations: Qt.PortraitOrientation
58 property int supportedOrientations: Qt.PortraitOrientation
qml/Stages/DesktopStage.qml+2−8
@@ -40,6 +40,7 @@ AbstractStage {
40 property bool spreadShown: spread.state == "altTab"
40 property bool spreadShown: spread.state == "altTab"
41
41
42 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
42 mainApp: priv.focusedAppDelegate ? priv.focusedAppDelegate.application : null
43+ mainAppDelegate: priv.focusedAppDelegate
43
44
44 // application windows never rotate independently
45 // application windows never rotate independently
45 mainAppWindowOrientationAngle: shellOrientationAngle
46 mainAppWindowOrientationAngle: shellOrientationAngle
@@ -283,6 +284,7 @@ AbstractStage {
283 property bool visuallyMinimized: false
284 property bool visuallyMinimized: false
284
285
285 readonly property var surface: model.surface
286 readonly property var surface: model.surface
287+ readonly property alias resizeArea: resizeArea
286
288
287 function claimFocus() {
289 function claimFocus() {
288 if (spread.state == "altTab") {
290 if (spread.state == "altTab") {
@@ -604,14 +606,6 @@ AbstractStage {
604 onDecorationPressed: { appDelegate.focus = true; }
606 onDecorationPressed: { appDelegate.focus = true; }
605 }
607 }
606
608
607− WindowControlsOverlay {
608− anchors.fill: resizeArea
609− target: appDelegate
610− resizeTarget: resizeArea
611− borderThickness: resizeArea.borderThickness
612− onActivated: ApplicationManager.focusApplication(model.appId)
613− }
614−
615 WindowedFullscreenPolicy {
609 WindowedFullscreenPolicy {
616 id: fullscreenPolicy
610 id: fullscreenPolicy
617 active: true
611 active: true
qml/Stages/WindowControlsOverlay.qml+65−66
@@ -21,10 +21,9 @@ import "../Components/PanelState"
21
21
22Item {
22Item {
23 id: root
23 id: root
24+
24 // to be set from outside
25 // to be set from outside
25 property Item target // appDelegate
26 property Item target // appDelegate
26− property Item resizeTarget // WindowResizeArea
27− property int borderThickness
28
27
29 signal activated
28 signal activated
30
29
@@ -33,7 +32,7 @@ Item {
33 anchors.fill: parent
32 anchors.fill: parent
34
33
35 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
34 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
36− minimumTouchPoints: 3
35+ minimumTouchPoints: 2
37 maximumTouchPoints: minimumTouchPoints
36 maximumTouchPoints: minimumTouchPoints
38
37
39 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
38 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
@@ -53,49 +52,7 @@ Item {
53 Timer {
52 Timer {
54 id: overlayTimer
53 id: overlayTimer
55 interval: 2000
54 interval: 2000
56− repeat: priv.dragging || root.resizeTarget.dragging
55+ repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.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− }
99 }
56 }
100
57
101 QtObject {
58 QtObject {
@@ -103,6 +60,9 @@ Item {
103 property real distanceX
60 property real distanceX
104 property real distanceY
61 property real distanceY
105 property bool dragging
62 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
106 }
66 }
107
67
108
68
@@ -129,80 +89,119 @@ Item {
129 anchors.centerIn: parent
89 anchors.centerIn: parent
130 opacity: 0.95
90 opacity: 0.95
131 visible: target && target.width > units.gu(12) && target.height > units.gu(12)
91 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+ }
132 }
131 }
133
132
134 ResizeGrip { // top left
133 ResizeGrip { // top left
135 anchors.horizontalCenter: parent.left
134 anchors.horizontalCenter: parent.left
136− anchors.horizontalCenterOffset: borderThickness
135+ //anchors.horizontalCenterOffset: priv.borderThickness
137 anchors.verticalCenter: parent.top
136 anchors.verticalCenter: parent.top
138− anchors.verticalCenterOffset: borderThickness
137+ //anchors.verticalCenterOffset: priv.borderThickness
139 visible: !overlay.anyMaximized
138 visible: !overlay.anyMaximized
140− resizeTarget: root.resizeTarget
139+ resizeTarget: priv.resizeArea
141 }
140 }
142
141
143 ResizeGrip { // top center
142 ResizeGrip { // top center
144 anchors.horizontalCenter: parent.horizontalCenter
143 anchors.horizontalCenter: parent.horizontalCenter
145 anchors.verticalCenter: parent.top
144 anchors.verticalCenter: parent.top
146− anchors.verticalCenterOffset: borderThickness
145+ //anchors.verticalCenterOffset: priv.borderThickness
147 rotation: 45
146 rotation: 45
148 visible: !overlay.anyMaximized
147 visible: !overlay.anyMaximized
149− resizeTarget: root.resizeTarget
148+ resizeTarget: priv.resizeArea
150 }
149 }
151
150
152 ResizeGrip { // top right
151 ResizeGrip { // top right
153 anchors.horizontalCenter: parent.right
152 anchors.horizontalCenter: parent.right
154− anchors.horizontalCenterOffset: -borderThickness
153+ //anchors.horizontalCenterOffset: -priv.borderThickness
155 anchors.verticalCenter: parent.top
154 anchors.verticalCenter: parent.top
156− anchors.verticalCenterOffset: borderThickness
155+ //anchors.verticalCenterOffset: priv.borderThickness
157 rotation: 90
156 rotation: 90
158 visible: !overlay.anyMaximized
157 visible: !overlay.anyMaximized
159− resizeTarget: root.resizeTarget
158+ resizeTarget: priv.resizeArea
160 }
159 }
161
160
162 ResizeGrip { // right
161 ResizeGrip { // right
163 anchors.horizontalCenter: parent.right
162 anchors.horizontalCenter: parent.right
164− anchors.horizontalCenterOffset: -borderThickness
163+ //anchors.horizontalCenterOffset: -priv.borderThickness
165 anchors.verticalCenter: parent.verticalCenter
164 anchors.verticalCenter: parent.verticalCenter
166 rotation: 135
165 rotation: 135
167 visible: target && !target.maximizedRight && !target.maximized
166 visible: target && !target.maximizedRight && !target.maximized
168− resizeTarget: root.resizeTarget
167+ resizeTarget: priv.resizeArea
169 }
168 }
170
169
171 ResizeGrip { // bottom right
170 ResizeGrip { // bottom right
172 anchors.horizontalCenter: parent.right
171 anchors.horizontalCenter: parent.right
173− anchors.horizontalCenterOffset: -borderThickness
172+ //anchors.horizontalCenterOffset: -priv.borderThickness
174 anchors.verticalCenter: parent.bottom
173 anchors.verticalCenter: parent.bottom
175− anchors.verticalCenterOffset: -borderThickness
174+ //anchors.verticalCenterOffset: -priv.borderThickness
176 visible: !overlay.anyMaximized
175 visible: !overlay.anyMaximized
177− resizeTarget: root.resizeTarget
176+ resizeTarget: priv.resizeArea
178 }
177 }
179
178
180 ResizeGrip { // bottom center
179 ResizeGrip { // bottom center
181 anchors.horizontalCenter: parent.horizontalCenter
180 anchors.horizontalCenter: parent.horizontalCenter
182 anchors.verticalCenter: parent.bottom
181 anchors.verticalCenter: parent.bottom
183− anchors.verticalCenterOffset: -borderThickness
182+ //anchors.verticalCenterOffset: -priv.borderThickness
184 rotation: 45
183 rotation: 45
185 visible: !overlay.anyMaximized
184 visible: !overlay.anyMaximized
186− resizeTarget: root.resizeTarget
185+ resizeTarget: priv.resizeArea
187 }
186 }
188
187
189 ResizeGrip { // bottom left
188 ResizeGrip { // bottom left
190 anchors.horizontalCenter: parent.left
189 anchors.horizontalCenter: parent.left
191− anchors.horizontalCenterOffset: borderThickness
190+ //anchors.horizontalCenterOffset: priv.borderThickness
192 anchors.verticalCenter: parent.bottom
191 anchors.verticalCenter: parent.bottom
193− anchors.verticalCenterOffset: -borderThickness
192+ //anchors.verticalCenterOffset: -priv.borderThickness
194 rotation: 90
193 rotation: 90
195 visible: !overlay.anyMaximized
194 visible: !overlay.anyMaximized
196− resizeTarget: root.resizeTarget
195+ resizeTarget: priv.resizeArea
197 }
196 }
198
197
199 ResizeGrip { // left
198 ResizeGrip { // left
200 anchors.horizontalCenter: parent.left
199 anchors.horizontalCenter: parent.left
201− anchors.horizontalCenterOffset: borderThickness
200+ //anchors.horizontalCenterOffset: priv.borderThickness
202 anchors.verticalCenter: parent.verticalCenter
201 anchors.verticalCenter: parent.verticalCenter
203 rotation: 135
202 rotation: 135
204 visible: target && !target.maximizedLeft && !target.maximized
203 visible: target && !target.maximizedLeft && !target.maximized
205− resizeTarget: root.resizeTarget
204+ resizeTarget: priv.resizeArea
206 }
205 }
207 }
206 }
208}
207}