Merge lp:~dandrader/unity8/allowClientResize into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Lukáš Tinkl
Approved revision: 2869
Merged at revision: 2880
Proposed branch: lp:~dandrader/unity8/allowClientResize
Merge into: lp:unity8
Prerequisite: lp:~mzanetti/unity8/surfacetitles-in-quicklist
Diff against target: 190 lines (+56/-5)
6 files modified
debian/control (+2/-2)
plugins/WindowManager/Window.cpp (+26/-1)
plugins/WindowManager/Window.h (+14/-1)
qml/Stage/Stage.qml (+8/-0)
tests/mocks/Unity/Application/MirSurface.h (+3/-0)
tests/plugins/Unity/Launcher/launchermodeltest.cpp (+3/-1)
To merge this branch: bzr merge lp:~dandrader/unity8/allowClientResize
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Gerry Boland (community) Approve
Lukáš Tinkl Pending
Review via email: mp+319812@code.launchpad.net

This proposal supersedes a proposal from 2017-03-14.

Commit message

Don't let clients resize their surfaces while in staged (phone/tablet) mode

Description of the change

Prereq-archive: ppa:ci-train-ppa-service/2555

That doesn't fix the bug for gtk+ apps though. I think gtk-mir needs some work.

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~dandrader/qtmir/allowClientResize/+merge/319209
https://code.launchpad.net/~dandrader/unity-api/surfaceAllowClientResize/+merge/319730

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

* If you changed the UI, has there been a design review?
Not applicable

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

The code looks good, except why use this lambda?

connect(surface, &unityapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {...}

Can't you just connect to the &Window::setAllowClientResize slot?

review: Needs Information
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 07/03/2017 11:27, Lukáš Tinkl wrote:
> Review: Needs Information
>
> The code looks good, except why use this lambda?
>
> connect(surface, &unityapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {...}
>
> Can't you just connect to the &Window::setAllowClientResize slot?

No, they are different.

Window::setAllowClientResize is called from unity8. It sets the Window
property and then the Window forwards that to its surface, if any. So
the direction is Window -> Surface

That lambda comes in response to a change in the surface property.
Window then updates its value appropriately. So the direction is Surface
-> Window

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Thx for the explanation

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

+{
+ if (value != m_allowClientResize) {
+ DEBUG_MSG << "("<<value<<")";
+ m_allowClientResize = value;
+ Q_EMIT allowClientResizeChanged(m_allowClientResize);
+ if (m_surface) {
+ m_surface->setAllowClientResize(value);
+ }
+ }
Why emit the signal before doing the operation? Typically a signal is emitted after the new state has been applied.

Rest looks fine

review: Needs Information
Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 08/03/2017 09:20, Gerry Boland wrote:
> Review: Needs Information
>
> +{
> + if (value != m_allowClientResize) {
> + DEBUG_MSG << "("<<value<<")";
> + m_allowClientResize = value;
> + Q_EMIT allowClientResizeChanged(m_allowClientResize);
> + if (m_surface) {
> + m_surface->setAllowClientResize(value);
> + }
> + }
> Why emit the signal before doing the operation? Typically a signal is emitted after the new state has been applied.
>

Because m_allowClientResize is already changed, which is what the getter
uses. Anyway, moved the signal emission to the bottom.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

You forgot to update the other mocks, it doesn't compile:

/<<BUILDDIR>>/unity8-8.15+16.04.20170314/tests/plugins/Unity/Launcher/launchermodeltest.cpp: In member function ‘void LauncherModelTest::testSurfaceCountUpdates()’:
/<<BUILDDIR>>/unity8-8.15+16.04.20170314/tests/plugins/Unity/Launcher/launchermodeltest.cpp:814:60: error: invalid new-expression of abstract class type ‘MockSurface’
         surfaces->append(new MockSurface("foobar", surfaces));
                                                            ^
/<<BUILDDIR>>/unity8-8.15+16.04.20170314/tests/plugins/Unity/Launcher/launchermodeltest.cpp:41:7: note: because the following virtual functions are pure within ‘MockSurface’:
 class MockSurface: public unity::shell::application::MirSurfaceInterface
       ^
In file included from /<<BUILDDIR>>/unity8-8.15+16.04.20170314/plugins/Unity/Launcher/launcheritem.h:26:0,
                 from /<<BUILDDIR>>/unity8-8.15+16.04.20170314/tests/plugins/Unity/Launcher/launchermodeltest.cpp:22:
/usr/include/unity/shell/application/MirSurfaceInterface.h:231:18: note: virtual bool unity::shell::application::MirSurfaceInterface::allowClientResize() const
     virtual bool allowClientResize() const = 0;
                  ^
/usr/include/unity/shell/application/MirSurfaceInterface.h:232:18: note: virtual void unity::shell::application::MirSurfaceInterface::setAllowClientResize(bool)
     virtual void setAllowClientResize(bool) = 0;
                  ^

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Gerry Boland (gerboland) :
review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2869
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3463/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4566
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2751
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2751
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4594
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4424/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4424/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4424/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4424/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4424/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4424
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4424/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3463/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2869
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3465/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4574
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2757
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2757
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4602
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4429/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4429/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4429/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4429/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4429/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4429
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4429/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3465/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2017-03-16 12:52:57 +0000
3+++ debian/control 2017-03-16 12:52:59 +0000
4@@ -162,7 +162,7 @@
5 qttranslations5-l10n,
6 ubuntu-thumbnailer-impl-0,
7 ubuntu-wallpapers,
8- unity-application-impl-26,
9+ unity-application-impl-27,
10 unity-notifications-impl-3,
11 unity-plugin-scopes | unity-scopes-impl,
12 unity-scopes-impl-12,
13@@ -212,7 +212,7 @@
14 ${misc:Depends},
15 ${shlibs:Depends},
16 Provides: unity-application-impl,
17- unity-application-impl-26,
18+ unity-application-impl-27,
19 unity8-fake-env,
20 Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1),
21 unity8-fake-env,
22
23=== modified file 'plugins/WindowManager/Window.cpp'
24--- plugins/WindowManager/Window.cpp 2016-12-06 14:41:54 +0000
25+++ plugins/WindowManager/Window.cpp 2017-03-16 12:52:59 +0000
26@@ -1,5 +1,5 @@
27 /*
28- * Copyright (C) 2016 Canonical, Ltd.
29+ * Copyright (C) 2016-2017 Canonical, Ltd.
30 *
31 * This program is free software; you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by
33@@ -67,6 +67,23 @@
34 }
35 }
36
37+bool Window::allowClientResize() const
38+{
39+ return m_allowClientResize;
40+}
41+
42+void Window::setAllowClientResize(bool value)
43+{
44+ if (value != m_allowClientResize) {
45+ DEBUG_MSG << "("<<value<<")";
46+ m_allowClientResize = value;
47+ if (m_surface) {
48+ m_surface->setAllowClientResize(value);
49+ }
50+ Q_EMIT allowClientResizeChanged(m_allowClientResize);
51+ }
52+}
53+
54 Mir::State Window::state() const
55 {
56 return m_state;
57@@ -154,6 +171,13 @@
58 updateFocused();
59 });
60
61+ connect(surface, &unityapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {
62+ if (m_surface->allowClientResize() != m_allowClientResize) {
63+ m_allowClientResize = m_surface->allowClientResize();
64+ Q_EMIT allowClientResizeChanged(m_allowClientResize);
65+ }
66+ });
67+
68 // bring it up to speed
69 if (m_positionRequested) {
70 m_surface->setRequestedPosition(m_requestedPosition);
71@@ -161,6 +185,7 @@
72 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
73 m_surface->requestState(m_state);
74 }
75+ m_surface->setAllowClientResize(m_allowClientResize);
76
77 // and sync with surface
78 updatePosition();
79
80=== modified file 'plugins/WindowManager/Window.h'
81--- plugins/WindowManager/Window.h 2017-01-26 11:10:01 +0000
82+++ plugins/WindowManager/Window.h 2017-03-16 12:52:59 +0000
83@@ -1,5 +1,5 @@
84 /*
85- * Copyright (C) 2016 Canonical, Ltd.
86+ * Copyright (C) 2016-2017 Canonical, Ltd.
87 *
88 * This program is free software; you can redistribute it and/or modify
89 * it under the terms of the GNU General Public License as published by
90@@ -89,6 +89,13 @@
91 */
92 Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
93
94+ /**
95+ * @brief Whether to comply to resize requests coming from the client side
96+ *
97+ * It's true by default
98+ */
99+ Q_PROPERTY(bool allowClientResize READ allowClientResize WRITE setAllowClientResize NOTIFY allowClientResizeChanged)
100+
101 public:
102 Window(int id, QObject *parent = nullptr);
103 virtual ~Window();
104@@ -104,6 +111,9 @@
105 void setSurface(unity::shell::application::MirSurfaceInterface *surface);
106 void setFocused(bool value);
107
108+ bool allowClientResize() const;
109+ void setAllowClientResize(bool);
110+
111 QString toString() const;
112
113 public Q_SLOTS:
114@@ -133,6 +143,7 @@
115 void focusedChanged(bool value);
116 void confinesMousePointerChanged(bool value);
117 void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
118+ void allowClientResizeChanged(bool value);
119
120 /**
121 * @brief Emitted when focus for this window is requested by an external party
122@@ -152,6 +163,8 @@
123 Mir::State m_state{Mir::RestoredState};
124 bool m_stateRequested{false};
125 unity::shell::application::MirSurfaceInterface *m_surface{nullptr};
126+
127+ bool m_allowClientResize{true};
128 };
129
130 QDebug operator<<(QDebug dbg, const Window *window);
131
132=== modified file 'qml/Stage/Stage.qml'
133--- qml/Stage/Stage.qml 2017-03-08 09:51:58 +0000
134+++ qml/Stage/Stage.qml 2017-03-16 12:52:59 +0000
135@@ -1302,6 +1302,10 @@
136 target: stageMaths
137 animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
138 }
139+ PropertyChanges {
140+ target: appDelegate.window
141+ allowClientResize: false
142+ }
143 },
144 State {
145 name: "stagedWithSideStage"; when: root.state == "stagedWithSideStage"
146@@ -1327,6 +1331,10 @@
147 target: resizeArea
148 enabled: false
149 }
150+ PropertyChanges {
151+ target: appDelegate.window
152+ allowClientResize: false
153+ }
154 },
155 State {
156 name: "maximized"; when: appDelegate.maximized && !appDelegate.minimized
157
158=== modified file 'tests/mocks/Unity/Application/MirSurface.h'
159--- tests/mocks/Unity/Application/MirSurface.h 2017-03-16 12:52:57 +0000
160+++ tests/mocks/Unity/Application/MirSurface.h 2017-03-16 12:52:59 +0000
161@@ -93,6 +93,9 @@
162
163 bool confinesMousePointer() const override { return false; }
164
165+ bool allowClientResize() const override { return true; }
166+ void setAllowClientResize(bool) override {}
167+
168 QPoint requestedPosition() const override { return m_requestedPosition; }
169 void setRequestedPosition(const QPoint &) override;
170
171
172=== modified file 'tests/plugins/Unity/Launcher/launchermodeltest.cpp'
173--- tests/plugins/Unity/Launcher/launchermodeltest.cpp 2017-03-16 12:52:57 +0000
174+++ tests/plugins/Unity/Launcher/launchermodeltest.cpp 2017-03-16 12:52:59 +0000
175@@ -1,5 +1,5 @@
176 /*
177- * Copyright 2013-2016 Canonical Ltd.
178+ * Copyright 2013-2017 Canonical Ltd.
179 *
180 * This program is free software; you can redistribute it and/or modify
181 * it under the terms of the GNU Lesser General Public License as published by
182@@ -68,6 +68,8 @@
183 bool focused() const override { return true; }
184 QRect inputBounds() const override { return QRect(); }
185 bool confinesMousePointer() const override { return false; }
186+ bool allowClientResize() const override { return true; }
187+ void setAllowClientResize(bool) override {}
188 QPoint requestedPosition() const override { return QPoint(); }
189 void setRequestedPosition(const QPoint &) override {}
190 MirSurfaceInterface* parentSurface() const override { return nullptr; }

Subscribers

People subscribed via source and target branches