on xenial help sign in
Don't let clients resize their surfaces while in staged (phone/tablet) mode
4900a5fDaniel d'Andrada
debian/control+2−2
@@ -162,7 +162,7 @@ Depends: qml-module-qtquick-layouts,
162 qttranslations5-l10n,
162 qttranslations5-l10n,
163 ubuntu-thumbnailer-impl-0,
163 ubuntu-thumbnailer-impl-0,
164 ubuntu-wallpapers,
164 ubuntu-wallpapers,
165− unity-application-impl-26,
165+ unity-application-impl-27,
166 unity-notifications-impl-3,
166 unity-notifications-impl-3,
167 unity-plugin-scopes | unity-scopes-impl,
167 unity-plugin-scopes | unity-scopes-impl,
168 unity-scopes-impl-12,
168 unity-scopes-impl-12,
@@ -212,7 +212,7 @@ Depends: dbus-test-runner,
212 ${misc:Depends},
212 ${misc:Depends},
213 ${shlibs:Depends},
213 ${shlibs:Depends},
214Provides: unity-application-impl,
214Provides: unity-application-impl,
215− unity-application-impl-26,
215+ unity-application-impl-27,
216 unity8-fake-env,
216 unity8-fake-env,
217Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1),
217Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1),
218 unity8-fake-env,
218 unity8-fake-env,
plugins/WindowManager/Window.cpp+26−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2016 Canonical, Ltd.
2+ * Copyright (C) 2016-2017 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -67,6 +67,23 @@ void Window::setRequestedPosition(const QPoint &value)
67 }
67 }
68}
68}
69
69
70+bool Window::allowClientResize() const
71+{
72+ return m_allowClientResize;
73+}
74+
75+void Window::setAllowClientResize(bool value)
76+{
77+ if (value != m_allowClientResize) {
78+ DEBUG_MSG << "("<<value<<")";
79+ m_allowClientResize = value;
80+ if (m_surface) {
81+ m_surface->setAllowClientResize(value);
82+ }
83+ Q_EMIT allowClientResizeChanged(m_allowClientResize);
84+ }
85+}
86+
70Mir::State Window::state() const
87Mir::State Window::state() const
71{
88{
72 return m_state;
89 return m_state;
@@ -154,6 +171,13 @@ void Window::setSurface(unityapi::MirSurfaceInterface *surface)
154 updateFocused();
171 updateFocused();
155 });
172 });
156
173
174+ connect(surface, &unityapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {
175+ if (m_surface->allowClientResize() != m_allowClientResize) {
176+ m_allowClientResize = m_surface->allowClientResize();
177+ Q_EMIT allowClientResizeChanged(m_allowClientResize);
178+ }
179+ });
180+
157 // bring it up to speed
181 // bring it up to speed
158 if (m_positionRequested) {
182 if (m_positionRequested) {
159 m_surface->setRequestedPosition(m_requestedPosition);
183 m_surface->setRequestedPosition(m_requestedPosition);
@@ -161,6 +185,7 @@ void Window::setSurface(unityapi::MirSurfaceInterface *surface)
161 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
185 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
162 m_surface->requestState(m_state);
186 m_surface->requestState(m_state);
163 }
187 }
188+ m_surface->setAllowClientResize(m_allowClientResize);
164
189
165 // and sync with surface
190 // and sync with surface
166 updatePosition();
191 updatePosition();
plugins/WindowManager/Window.h+14−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2016 Canonical, Ltd.
2+ * Copyright (C) 2016-2017 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -89,6 +89,13 @@ class Window : public QObject
89 */
89 */
90 Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
90 Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
91
91
92+ /**
93+ * @brief Whether to comply to resize requests coming from the client side
94+ *
95+ * It's true by default
96+ */
97+ Q_PROPERTY(bool allowClientResize READ allowClientResize WRITE setAllowClientResize NOTIFY allowClientResizeChanged)
98+
92public:
99public:
93 Window(int id, QObject *parent = nullptr);
100 Window(int id, QObject *parent = nullptr);
94 virtual ~Window();
101 virtual ~Window();
@@ -104,6 +111,9 @@ public:
104 void setSurface(unity::shell::application::MirSurfaceInterface *surface);
111 void setSurface(unity::shell::application::MirSurfaceInterface *surface);
105 void setFocused(bool value);
112 void setFocused(bool value);
106
113
114+ bool allowClientResize() const;
115+ void setAllowClientResize(bool);
116+
107 QString toString() const;
117 QString toString() const;
108
118
109public Q_SLOTS:
119public Q_SLOTS:
@@ -133,6 +143,7 @@ Q_SIGNALS:
133 void focusedChanged(bool value);
143 void focusedChanged(bool value);
134 void confinesMousePointerChanged(bool value);
144 void confinesMousePointerChanged(bool value);
135 void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
145 void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
146+ void allowClientResizeChanged(bool value);
136
147
137 /**
148 /**
138 * @brief Emitted when focus for this window is requested by an external party
149 * @brief Emitted when focus for this window is requested by an external party
@@ -152,6 +163,8 @@ private:
152 Mir::State m_state{Mir::RestoredState};
163 Mir::State m_state{Mir::RestoredState};
153 bool m_stateRequested{false};
164 bool m_stateRequested{false};
154 unity::shell::application::MirSurfaceInterface *m_surface{nullptr};
165 unity::shell::application::MirSurfaceInterface *m_surface{nullptr};
166+
167+ bool m_allowClientResize{true};
155};
168};
156
169
157QDebug operator<<(QDebug dbg, const Window *window);
170QDebug operator<<(QDebug dbg, const Window *window);
qml/Stage/Stage.qml+8
@@ -1302,6 +1302,10 @@ FocusScope {
1302 target: stageMaths
1302 target: stageMaths
1303 animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
1303 animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
1304 }
1304 }
1305+ PropertyChanges {
1306+ target: appDelegate.window
1307+ allowClientResize: false
1308+ }
1305 },
1309 },
1306 State {
1310 State {
1307 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
1311 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
@@ -1327,6 +1331,10 @@ FocusScope {
1327 target: resizeArea
1331 target: resizeArea
1328 enabled: false
1332 enabled: false
1329 }
1333 }
1334+ PropertyChanges {
1335+ target: appDelegate.window
1336+ allowClientResize: false
1337+ }
1330 },
1338 },
1331 State {
1339 State {
1332 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
1340 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
tests/mocks/Unity/Application/MirSurface.h+3
@@ -93,6 +93,9 @@ public:
93
93
94 bool confinesMousePointer() const override { return false; }
94 bool confinesMousePointer() const override { return false; }
95
95
96+ bool allowClientResize() const override { return true; }
97+ void setAllowClientResize(bool) override {}
98+
96 QPoint requestedPosition() const override { return m_requestedPosition; }
99 QPoint requestedPosition() const override { return m_requestedPosition; }
97 void setRequestedPosition(const QPoint &) override;
100 void setRequestedPosition(const QPoint &) override;
98
101
tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013-2016 Canonical Ltd.
2+ * Copyright 2013-2017 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,6 +68,8 @@ public:
68 bool focused() const override { return true; }
68 bool focused() const override { return true; }
69 QRect inputBounds() const override { return QRect(); }
69 QRect inputBounds() const override { return QRect(); }
70 bool confinesMousePointer() const override { return false; }
70 bool confinesMousePointer() const override { return false; }
71+ bool allowClientResize() const override { return true; }
72+ void setAllowClientResize(bool) override {}
71 QPoint requestedPosition() const override { return QPoint(); }
73 QPoint requestedPosition() const override { return QPoint(); }
72 void setRequestedPosition(const QPoint &) override {}
74 void setRequestedPosition(const QPoint &) override {}
73 MirSurfaceInterface* parentSurface() const override { return nullptr; }
75 MirSurfaceInterface* parentSurface() const override { return nullptr; }