Merge lp:~dandrader/qtubuntu/shellRotation into lp:qtubuntu

Proposed by Daniel d'Andrada on 2014-11-19
Status: Merged
Approved by: Gerry Boland on 2015-03-05
Approved revision: 255
Merged at revision: 260
Proposed branch: lp:~dandrader/qtubuntu/shellRotation
Merge into: lp:qtubuntu
Diff against target: 171 lines (+72/-9)
4 files modified
debian/changelog (+6/-0)
src/ubuntumirclient/input.cpp (+7/-0)
src/ubuntumirclient/screen.cpp (+57/-7)
src/ubuntumirclient/screen.h (+2/-2)
To merge this branch: bzr merge lp:~dandrader/qtubuntu/shellRotation
Reviewer Review Type Date Requested Status
Michał Sawicz Needs Information on 2015-04-30
Gerry Boland 2014-11-19 Approve on 2015-03-05
PS Jenkins bot continuous-integration Approve on 2015-03-04
Review via email: mp+242215@code.launchpad.net

Commit Message

Flip screen dimensions to compensate for a rotated window

And unify logging switch in input.cpp

Description of the Change

Part of the "shell rotation" feature.

For its changes to have any effect it needs all other branches present in this PPA:
https://launchpad.net/~unity-team/+archive/ubuntu/demo-stuff

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :

+ } break;
break on new line please;

+ // The window aspect ratio differ's from the screen one. This means that
+ // unity8 has rotated the window in its scene.
Only for phone though, for tablet/desktop case this will be far from correct. Dash on desktop with this is rotated 90 degrees with this change. We can't regress the desktop.

Instead of guessing based on window & screen geometry, we need a better way to notify Qt that the Screen orientation actually changed. Mir's DisplayConfiguration is an option, if we can make it work.

You're welcome to find a hack to fix tablet/desktop case, but this is definitely something we need to fix properly when Mir allows us to.

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

On 19/11/14 15:32, Gerry Boland wrote:
> [...]
> Only for phone though, for tablet/desktop case this will be far from correct. Dash on desktop with this is rotated 90 degrees with this change. We can't regress the desktop.
>

Dash on desktop is rotated 90 degrees because in OrientedShell.qml,
"primaryOrientation: Qt.PortraitOrientation".

Daniel d'Andrada (dandrader) wrote :

On 19/11/14 16:03, Daniel d'Andrada wrote:
> On 19/11/14 15:32, Gerry Boland wrote:
>> [...]
>> Only for phone though, for tablet/desktop case this will be far from correct. Dash on desktop with this is rotated 90 degrees with this change. We can't regress the desktop.
>>
> Dash on desktop is rotated 90 degrees because in OrientedShell.qml,
> "primaryOrientation: Qt.PortraitOrientation".
>
Or maybe not. I've to actually try the stuff on something other than
phone to stop guessing.

Gerry Boland (gerboland) wrote :

+ } break;
break on new line please;

Code is functional otherwise, so ok to approve

Daniel d'Andrada (dandrader) wrote :

> + } break;
> break on new line please;

Done.

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~dandrader/qtubuntu/shellRotation updated on 2015-01-12
251. By Robert Carr on 2014-12-12

Utilize repeat_count value from Mir in constructing QKeyEvents. Fixes: #1349416
Approved by: Daniel d'Andrada, PS Jenkins bot

252. By Gerry Boland on 2014-12-12

Fix raster-based (QWidget) application rendering.

Replace the QOpenGLPainter-based renderer with a CPU-bound pixmap one (on advice from Qt developers due to (a) it being unreliable and (b) not rendering perfectly).
Approved by: Michael Zanetti, PS Jenkins bot

253. By CI Train Bot Account on 2014-12-12

Releasing 0.60+15.04.20141212-0ubuntu1

254. By Daniel d'Andrada on 2015-01-12

Flip screen dimensions to compensate for a rotated window

And unify logging switch in input.cpp

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :
review: Needs Fixing
lp:~dandrader/qtubuntu/shellRotation updated on 2015-03-04
255. By Daniel d'Andrada on 2015-03-04

Adapt to changes in Qt's platform API

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :

LGTM. LP claims debian/changelog has a conflict, but trying manually it merges fine

review: Approve
lp:~dandrader/qtubuntu/shellRotation updated on 2015-03-19
256. By Daniel d'Andrada on 2015-03-19

Merge trunk

[ Alberto Aguirre ]
* Port qtubuntu to direct mirclient usage for window creation and
  input handling.
[ Daniel d'Andrada ]
* Port qtubuntu to direct mirclient usage for window creation and
  input handling.
[ Robert Carr ]
* Port qtubuntu to direct mirclient usage for window creation and
  input handling.
* No-change rebuild against Qt 5.4.1.
* No-change rebuild against Qt 5.4.0.

257. By Daniel d'Andrada on 2015-03-19

Remove unused variable

Michał Sawicz (saviq) wrote :

Are these changes backwards-compatible? If not, we need to add versioned Breaks/Depends as needed.

review: Needs Information
Daniel d'Andrada (dandrader) wrote :

> Are these changes backwards-compatible? If not, we need to add versioned
> Breaks/Depends as needed.

Yes, they are.
If you install only qtubuntu/shellRotation, without unity8/shellRotation and qtmir/supportedOrientations, it all keeps working normally.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-03-18 10:12:48 +0000
3+++ debian/changelog 2015-03-19 16:22:37 +0000
4@@ -1,3 +1,9 @@
5+qtubuntu (0.61) UNRELEASED; urgency=medium
6+
7+ * Flip screen dimensions to compensate for a rotated window
8+
9+ -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 31 Oct 2014 16:39:11 -0200
10+
11 qtubuntu (0.60+15.04.20150318-0ubuntu1) vivid; urgency=medium
12
13 [ Alberto Aguirre ]
14
15=== modified file 'src/ubuntumirclient/input.cpp'
16--- src/ubuntumirclient/input.cpp 2015-02-17 17:39:47 +0000
17+++ src/ubuntumirclient/input.cpp 2015-03-19 16:22:37 +0000
18@@ -219,7 +219,14 @@
19 break;
20 case mir_event_type_resize:
21 {
22+ Q_ASSERT(ubuntuEvent->window->screen() == mIntegration->screen());
23+
24 auto resizeEvent = mir_event_get_resize_event(nativeEvent);
25+
26+ mIntegration->screen()->handleWindowSurfaceResize(
27+ mir_resize_event_get_width(resizeEvent),
28+ mir_resize_event_get_height(resizeEvent));
29+
30 ubuntuEvent->window->handleSurfaceResize(mir_resize_event_get_width(resizeEvent),
31 mir_resize_event_get_height(resizeEvent));
32 break;
33
34=== modified file 'src/ubuntumirclient/screen.cpp'
35--- src/ubuntumirclient/screen.cpp 2014-09-09 14:10:21 +0000
36+++ src/ubuntumirclient/screen.cpp 2015-03-19 16:22:37 +0000
37@@ -34,6 +34,24 @@
38 static const int kSwapInterval = 1;
39
40 #if !defined(QT_NO_DEBUG)
41+
42+static const char *orientationToStr(Qt::ScreenOrientation orientation) {
43+ switch (orientation) {
44+ case Qt::PrimaryOrientation:
45+ return "primary";
46+ case Qt::PortraitOrientation:
47+ return "portrait";
48+ case Qt::LandscapeOrientation:
49+ return "landscape";
50+ case Qt::InvertedPortraitOrientation:
51+ return "inverted portrait";
52+ case Qt::InvertedLandscapeOrientation:
53+ return "inverted landscape";
54+ default:
55+ return "INVALID!";
56+ }
57+}
58+
59 static void printEglConfig(EGLDisplay display, EGLConfig config) {
60 DASSERT(display != EGL_NO_DISPLAY);
61 DASSERT(config != nullptr);
62@@ -146,12 +164,11 @@
63 ua_ui_display_destroy(display);
64
65 mGeometry = QRect(0, 0, kScreenWidth, kScreenHeight);
66- mAvailableGeometry = QRect(0, 0, kScreenWidth, kScreenHeight);
67
68 DLOG("QUbuntuScreen::QUbuntuScreen (this=%p)", this);
69
70 // Set the default orientation based on the initial screen dimmensions.
71- mNativeOrientation = (mAvailableGeometry.width() >= mAvailableGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
72+ mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
73
74 // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait
75 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
76@@ -168,22 +185,22 @@
77 OrientationChangeEvent* oReadingEvent = static_cast<OrientationChangeEvent*>(event);
78 switch (oReadingEvent->mOrientation) {
79 case QOrientationReading::LeftUp: {
80- mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?
81+ mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
82 Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation;
83 break;
84 }
85 case QOrientationReading::TopUp: {
86- mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?
87+ mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
88 Qt::LandscapeOrientation : Qt::PortraitOrientation;
89 break;
90 }
91 case QOrientationReading::RightUp: {
92- mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?
93+ mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
94 Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation;
95 break;
96 }
97 case QOrientationReading::TopDown: {
98- mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?
99+ mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
100 Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation;
101 break;
102 }
103@@ -194,6 +211,39 @@
104 }
105
106 // Raise the event signal so that client apps know the orientation changed
107+ DLOG("UbuntuScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation));
108 QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation);
109- DLOG("UbuntuScreen::customEvent - handling orientation change to %d", mCurrentOrientation);
110+}
111+
112+void UbuntuScreen::handleWindowSurfaceResize(int windowWidth, int windowHeight)
113+{
114+ if ((windowWidth > windowHeight && mGeometry.width() < mGeometry.height())
115+ || (windowWidth < windowHeight && mGeometry.width() > mGeometry.height())) {
116+
117+ // The window aspect ratio differ's from the screen one. This means that
118+ // unity8 has rotated the window in its scene.
119+ // As there's no way to express window rotation in Qt's API, we have
120+ // Flip QScreen's dimensions so that orientation properties match
121+ // (primaryOrientation particularly).
122+ // FIXME: This assumes a phone scenario. Won't work, or make sense,
123+ // on the desktop
124+
125+ QRect currGeometry = mGeometry;
126+ mGeometry.setWidth(currGeometry.height());
127+ mGeometry.setHeight(currGeometry.width());
128+
129+ DLOG("UbuntuScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)",
130+ mGeometry.width(), mGeometry.height());
131+ QWindowSystemInterface::handleScreenGeometryChange(screen(),
132+ mGeometry /* newGeometry */,
133+ mGeometry /* newAvailableGeometry */);
134+
135+ if (mGeometry.width() < mGeometry.height()) {
136+ mCurrentOrientation = Qt::PortraitOrientation;
137+ } else {
138+ mCurrentOrientation = Qt::LandscapeOrientation;
139+ }
140+ DLOG("UbuntuScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation));
141+ QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation);
142+ }
143 }
144
145=== modified file 'src/ubuntumirclient/screen.h'
146--- src/ubuntumirclient/screen.h 2014-08-25 15:24:02 +0000
147+++ src/ubuntumirclient/screen.h 2015-03-19 16:22:37 +0000
148@@ -32,7 +32,7 @@
149 QImage::Format format() const override { return mFormat; }
150 int depth() const override { return mDepth; }
151 QRect geometry() const override { return mGeometry; }
152- QRect availableGeometry() const override { return mAvailableGeometry; }
153+ QRect availableGeometry() const override { return mGeometry; }
154 Qt::ScreenOrientation nativeOrientation() const override { return mNativeOrientation; }
155 Qt::ScreenOrientation orientation() const override { return mNativeOrientation; }
156
157@@ -41,13 +41,13 @@
158 EGLDisplay eglDisplay() const { return mEglDisplay; }
159 EGLConfig eglConfig() const { return mEglConfig; }
160 EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; }
161+ void handleWindowSurfaceResize(int width, int height);
162
163 // QObject methods.
164 void customEvent(QEvent* event);
165
166 private:
167 QRect mGeometry;
168- QRect mAvailableGeometry;
169 Qt::ScreenOrientation mNativeOrientation;
170 Qt::ScreenOrientation mCurrentOrientation;
171 QImage::Format mFormat;

Subscribers

People subscribed via source and target branches