Merge lp:~phablet-team/qtubuntu/shellRotation into lp:qtubuntu

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Michael Zanetti
Approved revision: 258
Merged at revision: 260
Proposed branch: lp:~phablet-team/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:~phablet-team/qtubuntu/shellRotation
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+259044@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

Needed for shell rotation.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-03-20 12:37:32 +0000
+++ debian/changelog 2015-05-13 19:27:06 +0000
@@ -1,3 +1,9 @@
1qtubuntu (0.61) UNRELEASED; urgency=medium
2
3 * Flip screen dimensions to compensate for a rotated window
4
5 -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 31 Oct 2014 16:39:11 -0200
6
1qtubuntu (0.60+15.04.20150318-0ubuntu3) vivid; urgency=medium7qtubuntu (0.60+15.04.20150318-0ubuntu3) vivid; urgency=medium
28
3 * No-change rebuild against latest platform-api9 * No-change rebuild against latest platform-api
410
=== modified file 'src/ubuntumirclient/input.cpp'
--- src/ubuntumirclient/input.cpp 2015-02-17 17:39:47 +0000
+++ src/ubuntumirclient/input.cpp 2015-05-13 19:27:06 +0000
@@ -219,7 +219,14 @@
219 break;219 break;
220 case mir_event_type_resize:220 case mir_event_type_resize:
221 {221 {
222 Q_ASSERT(ubuntuEvent->window->screen() == mIntegration->screen());
223
222 auto resizeEvent = mir_event_get_resize_event(nativeEvent);224 auto resizeEvent = mir_event_get_resize_event(nativeEvent);
225
226 mIntegration->screen()->handleWindowSurfaceResize(
227 mir_resize_event_get_width(resizeEvent),
228 mir_resize_event_get_height(resizeEvent));
229
223 ubuntuEvent->window->handleSurfaceResize(mir_resize_event_get_width(resizeEvent),230 ubuntuEvent->window->handleSurfaceResize(mir_resize_event_get_width(resizeEvent),
224 mir_resize_event_get_height(resizeEvent));231 mir_resize_event_get_height(resizeEvent));
225 break;232 break;
226233
=== modified file 'src/ubuntumirclient/screen.cpp'
--- src/ubuntumirclient/screen.cpp 2014-09-09 14:10:21 +0000
+++ src/ubuntumirclient/screen.cpp 2015-05-13 19:27:06 +0000
@@ -34,6 +34,24 @@
34static const int kSwapInterval = 1;34static const int kSwapInterval = 1;
3535
36#if !defined(QT_NO_DEBUG)36#if !defined(QT_NO_DEBUG)
37
38static const char *orientationToStr(Qt::ScreenOrientation orientation) {
39 switch (orientation) {
40 case Qt::PrimaryOrientation:
41 return "primary";
42 case Qt::PortraitOrientation:
43 return "portrait";
44 case Qt::LandscapeOrientation:
45 return "landscape";
46 case Qt::InvertedPortraitOrientation:
47 return "inverted portrait";
48 case Qt::InvertedLandscapeOrientation:
49 return "inverted landscape";
50 default:
51 return "INVALID!";
52 }
53}
54
37static void printEglConfig(EGLDisplay display, EGLConfig config) {55static void printEglConfig(EGLDisplay display, EGLConfig config) {
38 DASSERT(display != EGL_NO_DISPLAY);56 DASSERT(display != EGL_NO_DISPLAY);
39 DASSERT(config != nullptr);57 DASSERT(config != nullptr);
@@ -146,12 +164,11 @@
146 ua_ui_display_destroy(display);164 ua_ui_display_destroy(display);
147165
148 mGeometry = QRect(0, 0, kScreenWidth, kScreenHeight);166 mGeometry = QRect(0, 0, kScreenWidth, kScreenHeight);
149 mAvailableGeometry = QRect(0, 0, kScreenWidth, kScreenHeight);
150167
151 DLOG("QUbuntuScreen::QUbuntuScreen (this=%p)", this);168 DLOG("QUbuntuScreen::QUbuntuScreen (this=%p)", this);
152169
153 // Set the default orientation based on the initial screen dimmensions.170 // Set the default orientation based on the initial screen dimmensions.
154 mNativeOrientation = (mAvailableGeometry.width() >= mAvailableGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;171 mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
155172
156 // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait173 // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait
157 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;174 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
@@ -168,22 +185,22 @@
168 OrientationChangeEvent* oReadingEvent = static_cast<OrientationChangeEvent*>(event);185 OrientationChangeEvent* oReadingEvent = static_cast<OrientationChangeEvent*>(event);
169 switch (oReadingEvent->mOrientation) {186 switch (oReadingEvent->mOrientation) {
170 case QOrientationReading::LeftUp: {187 case QOrientationReading::LeftUp: {
171 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?188 mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
172 Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation;189 Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation;
173 break;190 break;
174 }191 }
175 case QOrientationReading::TopUp: {192 case QOrientationReading::TopUp: {
176 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?193 mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
177 Qt::LandscapeOrientation : Qt::PortraitOrientation;194 Qt::LandscapeOrientation : Qt::PortraitOrientation;
178 break;195 break;
179 }196 }
180 case QOrientationReading::RightUp: {197 case QOrientationReading::RightUp: {
181 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?198 mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
182 Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation;199 Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation;
183 break;200 break;
184 }201 }
185 case QOrientationReading::TopDown: {202 case QOrientationReading::TopDown: {
186 mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ?203 mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ?
187 Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation;204 Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation;
188 break;205 break;
189 }206 }
@@ -194,6 +211,39 @@
194 }211 }
195212
196 // Raise the event signal so that client apps know the orientation changed213 // Raise the event signal so that client apps know the orientation changed
214 DLOG("UbuntuScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation));
197 QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation);215 QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation);
198 DLOG("UbuntuScreen::customEvent - handling orientation change to %d", mCurrentOrientation);216}
217
218void UbuntuScreen::handleWindowSurfaceResize(int windowWidth, int windowHeight)
219{
220 if ((windowWidth > windowHeight && mGeometry.width() < mGeometry.height())
221 || (windowWidth < windowHeight && mGeometry.width() > mGeometry.height())) {
222
223 // The window aspect ratio differ's from the screen one. This means that
224 // unity8 has rotated the window in its scene.
225 // As there's no way to express window rotation in Qt's API, we have
226 // Flip QScreen's dimensions so that orientation properties match
227 // (primaryOrientation particularly).
228 // FIXME: This assumes a phone scenario. Won't work, or make sense,
229 // on the desktop
230
231 QRect currGeometry = mGeometry;
232 mGeometry.setWidth(currGeometry.height());
233 mGeometry.setHeight(currGeometry.width());
234
235 DLOG("UbuntuScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)",
236 mGeometry.width(), mGeometry.height());
237 QWindowSystemInterface::handleScreenGeometryChange(screen(),
238 mGeometry /* newGeometry */,
239 mGeometry /* newAvailableGeometry */);
240
241 if (mGeometry.width() < mGeometry.height()) {
242 mCurrentOrientation = Qt::PortraitOrientation;
243 } else {
244 mCurrentOrientation = Qt::LandscapeOrientation;
245 }
246 DLOG("UbuntuScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation));
247 QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation);
248 }
199}249}
200250
=== modified file 'src/ubuntumirclient/screen.h'
--- src/ubuntumirclient/screen.h 2014-08-25 15:24:02 +0000
+++ src/ubuntumirclient/screen.h 2015-05-13 19:27:06 +0000
@@ -32,7 +32,7 @@
32 QImage::Format format() const override { return mFormat; }32 QImage::Format format() const override { return mFormat; }
33 int depth() const override { return mDepth; }33 int depth() const override { return mDepth; }
34 QRect geometry() const override { return mGeometry; }34 QRect geometry() const override { return mGeometry; }
35 QRect availableGeometry() const override { return mAvailableGeometry; }35 QRect availableGeometry() const override { return mGeometry; }
36 Qt::ScreenOrientation nativeOrientation() const override { return mNativeOrientation; }36 Qt::ScreenOrientation nativeOrientation() const override { return mNativeOrientation; }
37 Qt::ScreenOrientation orientation() const override { return mNativeOrientation; }37 Qt::ScreenOrientation orientation() const override { return mNativeOrientation; }
3838
@@ -41,13 +41,13 @@
41 EGLDisplay eglDisplay() const { return mEglDisplay; }41 EGLDisplay eglDisplay() const { return mEglDisplay; }
42 EGLConfig eglConfig() const { return mEglConfig; }42 EGLConfig eglConfig() const { return mEglConfig; }
43 EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; }43 EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; }
44 void handleWindowSurfaceResize(int width, int height);
4445
45 // QObject methods.46 // QObject methods.
46 void customEvent(QEvent* event);47 void customEvent(QEvent* event);
4748
48private:49private:
49 QRect mGeometry;50 QRect mGeometry;
50 QRect mAvailableGeometry;
51 Qt::ScreenOrientation mNativeOrientation;51 Qt::ScreenOrientation mNativeOrientation;
52 Qt::ScreenOrientation mCurrentOrientation;52 Qt::ScreenOrientation mCurrentOrientation;
53 QImage::Format mFormat;53 QImage::Format mFormat;

Subscribers

People subscribed via source and target branches