on xenial help sign in
Simplify DecoratedWindow
e73b43aDaniel d'Andrada
qml/Stage/DecoratedWindow.qml+36−43
@@ -196,18 +196,19 @@ FocusScope {
196 ]
196 ]
197 }
197 }
198
198
199− MouseArea {
199+ WindowDecoration {
200+ id: decoration
201+ closeButtonVisible: root.application.appId !== "unity8-dash"
202+ objectName: "appWindowDecoration"
203+
200 anchors { left: parent.left; top: parent.top; right: parent.right }
204 anchors { left: parent.left; top: parent.top; right: parent.right }
201 height: units.gu(3)
205 height: units.gu(3)
202
206
203− opacity: root.hasDecoration ? Math.min(1, root.showDecoration) : 0
207+ title: applicationWindow.title
204
208
209+ opacity: root.hasDecoration ? Math.min(1, root.showDecoration) : 0
205 Behavior on opacity { UbuntuNumberAnimation { } }
210 Behavior on opacity { UbuntuNumberAnimation { } }
206
211
207− drag.target: Item {}
208− drag.filterChildren: true
209− drag.threshold: 0
210−
211 onPressed: root.decorationPressed();
212 onPressed: root.decorationPressed();
212 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
213 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
213 onPositionChanged: moveHandler.handlePositionChanged(mouse)
214 onPositionChanged: moveHandler.handlePositionChanged(mouse)
@@ -216,47 +217,39 @@ FocusScope {
216 moveHandler.handleReleased();
217 moveHandler.handleReleased();
217 }
218 }
218
219
219− WindowDecoration {
220− id: decoration
221− closeButtonVisible: root.application.appId !== "unity8-dash"
222− objectName: "appWindowDecoration"
223− anchors.fill: parent
224− title: applicationWindow.title
225−
226− onCloseClicked: root.closeClicked();
220+ onCloseClicked: root.closeClicked();
227− onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
221+ onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
228− onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
222+ onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
229− onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
223+ onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
230− onMinimizeClicked: root.minimizeClicked();
224+ onMinimizeClicked: root.minimizeClicked();
231−
232− enableMenus: {
233− return active &&
234− surface &&
235− (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
236− }
237− menu: sharedAppModel.model
238
225
239− Indicators.SharedUnityMenuModel {
226+ enableMenus: {
240− id: sharedAppModel
227+ return active &&
241− property var menus: surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : []
228+ surface &&
242− property var menuService: menus.length > 0 ? menus[0] : undefined
229+ (PanelState.focusedPersistentSurfaceId === surface.persistentId && !PanelState.decorationsVisible)
230+ }
231+ menu: sharedAppModel.model
243
232
244− busName: menuService ? menuService.service : ""
233+ Indicators.SharedUnityMenuModel {
245− menuObjectPath: menuService && menuService.menuPath ? menuService.menuPath : ""
234+ id: sharedAppModel
246− actions: menuService && menuService.actionPath ? { "unity": menuService.actionPath } : {}
235+ property var menus: surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : []
247− }
236+ property var menuService: menus.length > 0 ? menus[0] : undefined
248
237
238+ busName: menuService ? menuService.service : ""
239+ menuObjectPath: menuService && menuService.menuPath ? menuService.menuPath : ""
240+ actions: menuService && menuService.actionPath ? { "unity": menuService.actionPath } : {}
241+ }
242+
249− Connections {
243+ Connections {
250− target: ApplicationMenuRegistry
244+ target: ApplicationMenuRegistry
251− onSurfaceMenuRegistered: {
245+ onSurfaceMenuRegistered: {
252− if (surface && surfaceId === surface.persistentId) {
246+ if (surface && surfaceId === surface.persistentId) {
253− sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
247+ sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
254− }
255 }
248 }
256− onSurfaceMenuUnregistered: {
249+ }
250+ onSurfaceMenuUnregistered: {
257− if (surface && surfaceId === surface.persistentId) {
251+ if (surface && surfaceId === surface.persistentId) {
258− sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
252+ sharedAppModel.menus = Qt.binding(function() { return surface ? ApplicationMenuRegistry.getMenusForSurface(surface.persistentId) : [] });
259− }
260 }
253 }
261 }
254 }
262 }
255 }
qml/Stage/WindowDecoration.qml+6−2
@@ -38,6 +38,10 @@ MouseArea {
38 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
38 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
39 hoverEnabled: true
39 hoverEnabled: true
40
40
41+ drag.target: Item {}
42+ drag.filterChildren: true
43+ drag.threshold: 0
44+
41 signal closeClicked()
45 signal closeClicked()
42 signal minimizeClicked()
46 signal minimizeClicked()
43 signal maximizeClicked()
47 signal maximizeClicked()
@@ -64,8 +68,8 @@ MouseArea {
64 (menuBar.showRequested || root.containsMouse)
68 (menuBar.showRequested || root.containsMouse)
65 }
69 }
66
70
67− // We dont want touch events to fall through to parent,
71+ // We dont want touch events to fall through to parent as it expect some child MouseArea to have them
68− // otherwise the containsMouse will not work.
72+ // If not some MouseArea in the menu bar, it will be this one.
69 MouseArea {
73 MouseArea {
70 anchors.fill: parent
74 anchors.fill: parent
71 propagateComposedEvents: true
75 propagateComposedEvents: true