on xenial help sign in
Don't let clients resize their surfaces while in staged (phone/tablet) mode
commit4900a5fcf72c7b7dc895b32dd0f300ac28ee7584 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 16 Mar 2017, 09:51 (10 years ago) parentfc6e1e9
6 files changed+56−5
debian/control+2−2 plugins/WindowManager/Window.cpp+26−1 plugins/WindowManager/Window.h+14−1 qml/Stage/Stage.qml+8 tests/mocks/Unity/Application/MirSurface.h+3 tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−1
debian/control+2−2
@@ -162,7 +162,7 @@ Depends: qml-module-qtquick-layouts,
162162 qttranslations5-l10n,
163163 ubuntu-thumbnailer-impl-0,
164164 ubuntu-wallpapers,
165− unity-application-impl-26,
165+ unity-application-impl-27,
166166 unity-notifications-impl-3,
167167 unity-plugin-scopes | unity-scopes-impl,
168168 unity-scopes-impl-12,
@@ -212,7 +212,7 @@ Depends: dbus-test-runner,
212212 ${misc:Depends},
213213 ${shlibs:Depends},
214214Provides: unity-application-impl,
215− unity-application-impl-26,
215+ unity-application-impl-27,
216216 unity8-fake-env,
217217Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1),
218218 unity8-fake-env,
plugins/WindowManager/Window.cpp+26−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2016 Canonical, Ltd.
2+ * Copyright (C) 2016-2017 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -67,6 +67,23 @@ void Window::setRequestedPosition(const QPoint &value)
6767 }
6868}
6969
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+
7087Mir::State Window::state() const
7188{
7289 return m_state;
@@ -154,6 +171,13 @@ void Window::setSurface(unityapi::MirSurfaceInterface *surface)
154171 updateFocused();
155172 });
156173
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+
157181 // bring it up to speed
158182 if (m_positionRequested) {
159183 m_surface->setRequestedPosition(m_requestedPosition);
@@ -161,6 +185,7 @@ void Window::setSurface(unityapi::MirSurfaceInterface *surface)
161185 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
162186 m_surface->requestState(m_state);
163187 }
188+ m_surface->setAllowClientResize(m_allowClientResize);
164189
165190 // and sync with surface
166191 updatePosition();
plugins/WindowManager/Window.h+14−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2016 Canonical, Ltd.
2+ * Copyright (C) 2016-2017 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -89,6 +89,13 @@ class Window : public QObject
8989 */
9090 Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
9191
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+
9299public:
93100 Window(int id, QObject *parent = nullptr);
94101 virtual ~Window();
@@ -104,6 +111,9 @@ public:
104111 void setSurface(unity::shell::application::MirSurfaceInterface *surface);
105112 void setFocused(bool value);
106113
114+ bool allowClientResize() const;
115+ void setAllowClientResize(bool);
116+
107117 QString toString() const;
108118
109119public Q_SLOTS:
@@ -133,6 +143,7 @@ Q_SIGNALS:
133143 void focusedChanged(bool value);
134144 void confinesMousePointerChanged(bool value);
135145 void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
146+ void allowClientResizeChanged(bool value);
136147
137148 /**
138149 * @brief Emitted when focus for this window is requested by an external party
@@ -152,6 +163,8 @@ private:
152163 Mir::State m_state{Mir::RestoredState};
153164 bool m_stateRequested{false};
154165 unity::shell::application::MirSurfaceInterface *m_surface{nullptr};
166+
167+ bool m_allowClientResize{true};
155168};
156169
157170QDebug operator<<(QDebug dbg, const Window *window);
qml/Stage/Stage.qml+8
@@ -1302,6 +1302,10 @@ FocusScope {
13021302 target: stageMaths
13031303 animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
13041304 }
1305+ PropertyChanges {
1306+ target: appDelegate.window
1307+ allowClientResize: false
1308+ }
13051309 },
13061310 State {
13071311 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
@@ -1327,6 +1331,10 @@ FocusScope {
13271331 target: resizeArea
13281332 enabled: false
13291333 }
1334+ PropertyChanges {
1335+ target: appDelegate.window
1336+ allowClientResize: false
1337+ }
13301338 },
13311339 State {
13321340 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
tests/mocks/Unity/Application/MirSurface.h+3
@@ -93,6 +93,9 @@ public:
9393
9494 bool confinesMousePointer() const override { return false; }
9595
96+ bool allowClientResize() const override { return true; }
97+ void setAllowClientResize(bool) override {}
98+
9699 QPoint requestedPosition() const override { return m_requestedPosition; }
97100 void setRequestedPosition(const QPoint &) override;
98101
tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2013-2016 Canonical Ltd.
2+ * Copyright 2013-2017 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU Lesser General Public License as published by
@@ -68,6 +68,8 @@ public:
6868 bool focused() const override { return true; }
6969 QRect inputBounds() const override { return QRect(); }
7070 bool confinesMousePointer() const override { return false; }
71+ bool allowClientResize() const override { return true; }
72+ void setAllowClientResize(bool) override {}
7173 QPoint requestedPosition() const override { return QPoint(); }
7274 void setRequestedPosition(const QPoint &) override {}
7375 MirSurfaceInterface* parentSurface() const override { return nullptr; }