Merge lp:~unity-team/qtubuntu/low_crome_mode into lp:qtubuntu

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp:~unity-team/qtubuntu/low_crome_mode
Merge into: lp:qtubuntu
Diff against target: 175 lines (+54/-19)
2 files modified
src/ubuntumirclient/window.cpp (+52/-18)
src/ubuntumirclient/window.h (+2/-1)
To merge this branch: bzr merge lp:~unity-team/qtubuntu/low_crome_mode
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+283827@code.launchpad.net

Commit message

Separate fullscreen and low crome modes

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~nick-dedekind/qtmir/low_crome_mode/+merge/283826
https://code.launchpad.net/~nick-dedekind/unity8/low_crome_mode/+merge/283828

 * 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?
N/A

To post a comment you must log in.
308. By Nick Dedekind

fixed state update

Unmerged revisions

308. By Nick Dedekind

fixed state update

307. By Nick Dedekind

hideDecorations

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/window.cpp'
2--- src/ubuntumirclient/window.cpp 2015-12-16 11:28:09 +0000
3+++ src/ubuntumirclient/window.cpp 2016-01-25 17:36:53 +0000
4@@ -63,10 +63,11 @@
5 return reinterpret_cast<EGLNativeWindowType>(mir_buffer_stream_get_egl_native_window(stream));
6 }
7
8-MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state)
9+MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state, Qt::WindowFlags flags)
10 {
11 switch (state) {
12 case Qt::WindowNoState:
13+ if (flags & Qt::FramelessWindowHint) return mir_surface_state_horizmaximized;
14 return mir_surface_state_restored;
15 case Qt::WindowFullScreen:
16 return mir_surface_state_fullscreen;
17@@ -96,6 +97,27 @@
18 return "!?";
19 }
20 }
21+const QString qtWindowFlagsToStr(Qt::WindowFlags flags)
22+{
23+ QString res;
24+ // Types
25+ if (flags & Qt::Window) res += "Window|";
26+ if (flags & Qt::Dialog) res += "Dialog|";
27+ if (flags & Qt::Sheet) res += "Sheet|";
28+ if (flags & Qt::Drawer) res += "Drawer|";
29+ if (flags & Qt::Popup) res += "Popup|";
30+ if (flags & Qt::Tool) res += "Tool|";
31+ if (flags & Qt::ToolTip) res += "ToolTip|";
32+ if (flags & Qt::SplashScreen) res += "SplashScreen|";
33+ if (flags & Qt::Desktop) res += "Desktop|";
34+ if (flags & Qt::SubWindow) res += "SubWindow|";
35+ if (flags & Qt::ForeignWindow) res += "ForeignWindow|";
36+ if (flags & Qt::CoverWindow) res += "CoverWindow|";
37+
38+ // Flags
39+ if (flags & Qt::FramelessWindowHint) res += "FramelessWindowHint|";
40+ return res;
41+}
42 #endif
43
44 WId makeId()
45@@ -247,7 +269,6 @@
46 , mVisible(false)
47 , mNeedsRepaint(false)
48 , mParented(mWindow->transientParent() || mWindow->parent())
49- , mWindowState(mWindow->windowState())
50
51 {
52 mir_surface_set_event_handler(mMirSurface, surfaceEventCallback, this);
53@@ -260,7 +281,8 @@
54 auto geom = mWindow->geometry();
55 geom.setWidth(parameters.width);
56 geom.setHeight(parameters.height);
57- if (mWindowState == Qt::WindowFullScreen) {
58+ if (mWindow->windowState() == Qt::WindowFullScreen ||
59+ (mWindow->windowState() == Qt::WindowNoState && mWindow->flags() & Qt::FramelessWindowHint)) {
60 geom.setY(0);
61 } else {
62 geom.setY(panelHeight());
63@@ -288,6 +310,7 @@
64
65 void resize(const QSize& newSize);
66 void setState(Qt::WindowState newState);
67+ void setFlags(Qt::WindowFlags newFlags);
68 void setVisible(bool state);
69 void updateTitle(const QString& title);
70 void setSizingConstraints(const QSize& minSize, const QSize& maxSize, const QSize& increment);
71@@ -316,7 +339,6 @@
72 bool mVisible;
73 bool mNeedsRepaint;
74 bool mParented;
75- Qt::WindowState mWindowState;
76 QSize mBufferSize;
77
78 QMutex mTargetSizeMutex;
79@@ -327,7 +349,8 @@
80 {
81 DLOG("[ubuntumirclient QPA] resize(window=%p, width=%d, height=%d)", mWindow, size.width(), size.height());
82
83- if (mWindowState == Qt::WindowFullScreen || mWindowState == Qt::WindowMaximized) {
84+ if (mWindow->windowState() == Qt::WindowFullScreen || mWindow->windowState() == Qt::WindowMaximized ||
85+ (mWindow->windowState() == Qt::WindowNoState && mWindow->flags() & Qt::FramelessWindowHint)) {
86 DLOG("[ubuntumirclient QPA] resize(window=%p) - not resizing, window is maximized or fullscreen", mWindow);
87 return;
88 }
89@@ -345,8 +368,12 @@
90
91 void UbuntuSurface::setState(Qt::WindowState newState)
92 {
93- mir_wait_for(mir_surface_set_state(mMirSurface, qtWindowStateToMirSurfaceState(newState)));
94- mWindowState = newState;
95+ mir_wait_for(mir_surface_set_state(mMirSurface, qtWindowStateToMirSurfaceState(newState, mWindow->flags())));
96+}
97+
98+void UbuntuSurface::setFlags(Qt::WindowFlags newFlags)
99+{
100+ mir_wait_for(mir_surface_set_state(mMirSurface, qtWindowStateToMirSurfaceState(mWindow->windowState(), newFlags)));
101 }
102
103 void UbuntuSurface::setVisible(bool visible)
104@@ -361,7 +388,7 @@
105
106 // TODO: Use the new mir_surface_state_hidden state instead of mir_surface_state_minimized.
107 // Will have to change qtmir and unity8 for that.
108- const auto newState = visible ? qtWindowStateToMirSurfaceState(mWindowState) : mir_surface_state_minimized;
109+ const auto newState = visible ? qtWindowStateToMirSurfaceState(mWindow->windowState(), mWindow->flags()) : mir_surface_state_minimized;
110 mir_wait_for(mir_surface_set_state(mMirSurface, newState));
111 }
112
113@@ -545,7 +572,16 @@
114 DLOG("[ubuntumirclient QPA] setWindowState(window=%p, %s)", this, qtWindowStateToStr(state));
115 mSurface->setState(state);
116
117- updatePanelHeightHack(state);
118+ updatePanelHeightHack(state, window()->flags());
119+}
120+
121+void UbuntuWindow::setWindowFlags(Qt::WindowFlags flags)
122+{
123+ QMutexLocker lock(&mMutex);
124+ DLOG("[ubuntumirclient QPA] setWindowFlags(window=%p, %s)", this, qPrintable(qtWindowFlagsToStr(flags)));
125+ mSurface->setFlags(flags);
126+
127+ updatePanelHeightHack(window()->windowState(), flags);
128 }
129
130 /*
131@@ -554,16 +590,14 @@
132 window is always on the top-left corner, right below the indicators panel if not
133 in fullscreen.
134 */
135-void UbuntuWindow::updatePanelHeightHack(Qt::WindowState state)
136+void UbuntuWindow::updatePanelHeightHack(Qt::WindowState state, Qt::WindowFlags flags)
137 {
138- if (state == Qt::WindowFullScreen && geometry().y() != 0) {
139- QRect newGeometry = geometry();
140- newGeometry.setY(0);
141- QPlatformWindow::setGeometry(newGeometry);
142- QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
143- } else if (geometry().y() == 0) {
144- QRect newGeometry = geometry();
145- newGeometry.setY(panelHeight());
146+ int newY = state == Qt::WindowFullScreen ||
147+ (state == Qt::WindowNoState && flags & Qt::FramelessWindowHint) ? 0 : panelHeight();
148+
149+ if (geometry().y() != newY) {
150+ QRect newGeometry = geometry();
151+ newGeometry.setY(newY);
152 QPlatformWindow::setGeometry(newGeometry);
153 QWindowSystemInterface::handleGeometryChange(window(), newGeometry);
154 }
155
156=== modified file 'src/ubuntumirclient/window.h'
157--- src/ubuntumirclient/window.h 2015-12-07 16:20:58 +0000
158+++ src/ubuntumirclient/window.h 2016-01-25 17:36:53 +0000
159@@ -42,6 +42,7 @@
160 WId winId() const override;
161 void setGeometry(const QRect&) override;
162 void setWindowState(Qt::WindowState state) override;
163+ void setWindowFlags(Qt::WindowFlags flags) override;
164 void setVisible(bool visible) override;
165 void setWindowTitle(const QString &title) override;
166 void propagateSizeHints() override;
167@@ -54,7 +55,7 @@
168 void onSwapBuffersDone();
169
170 private:
171- void updatePanelHeightHack(Qt::WindowState);
172+ void updatePanelHeightHack(Qt::WindowState state, Qt::WindowFlags flags);
173 mutable QMutex mMutex;
174 const WId mId;
175 const QSharedPointer<UbuntuClipboard> mClipboard;

Subscribers

People subscribed via source and target branches