Merge lp:~gerboland/qtubuntu/fix_1351024 into lp:qtubuntu

Proposed by Gerry Boland
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 237
Merged at revision: 236
Proposed branch: lp:~gerboland/qtubuntu/fix_1351024
Merge into: lp:qtubuntu
Diff against target: 150 lines (+33/-41)
3 files modified
src/ubuntumirclient/input.cpp (+2/-2)
src/ubuntumirclient/window.cpp (+31/-34)
src/ubuntumirclient/window.h (+0/-5)
To merge this branch: bzr merge lp:~gerboland/qtubuntu/fix_1351024
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Timo Jyrinki Approve
Review via email: mp+230094@code.launchpad.net

Commit message

Workaround for bug 1346633 broke QGuiApplication::topLevelWindows(), perform a different workaround.

This workaround guesses the window geometry relative to the screen (mainly setting y=panelHeight), defining it using QPlatformWindow::setGeometry and then Qt uses it to calculate mapToGlobal internally

Description of the change

Workaround for bug 1346633 broke QGuiApplication::topLevelWindows(), perform a different workaround

To post a comment you must log in.
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Tested with a local build, works with this branch! (ie. similar to #157)

Revision history for this message
Timo Jyrinki (timo-jyrinki) :
review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

There's no need to store panelHeight as it's only used inside createWindow()

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> There's no need to store panelHeight as it's only used inside createWindow()

And please put the code that calculates it into a helper method.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

I wanted a small diff, but ok

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

     } else if (d->state == Qt::WindowMaximized) {
         printf("UbuntuWindow - maximized geometry\n");
         geometry = screen()->availableGeometry();
+ /*
+ * FIXME: Autopilot relies on being able to convert coordinates relative of the window
+ * into absolute screen coordinates. Mir does not allow this, see bug lp:1346633
+ * Until there's a correct way to perform this transformation agreed, this horrible hack
+ * guesses the transformation heuristically.
+ *
+ * Assumption: this method only used on phone devices!
+ */
+ geometry.setY(d->panelHeight);

Shouldn't we deduct panelHeight from the geometry.height?
Ie, it's either

(0, 0, screenWidth, screenHeight) or (0, panelHeight, screenWidth, screenHeight - panelHeight),
but here it seems you're setting it to (0, panelHeight, screenWidth, screenHeight), which is wrong

review: Needs Fixing
lp:~gerboland/qtubuntu/fix_1351024 updated
237. By Gerry Boland

Review comments addressed

Revision history for this message
Gerry Boland (gerboland) wrote :

Shouldn't we deduct panelHeight from the geometry.height?
Ie, it's either

(0, 0, screenWidth, screenHeight) or (0, panelHeight, screenWidth, screenHeight - panelHeight),
but here it seems you're setting it to (0, panelHeight, screenWidth, screenHeight), which is wrong

I disagree. The client is asking for a surface with a particular geometry, we should not shrink it. Shell is the one which decides to shrink it anyway

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

    // Use client geometry if set explicitly, use available screen geometry otherwise.
    d->geometry = window()->geometry() != screen->geometry() ?
        window()->geometry() : screen->availableGeometry();

I would also move that to inside createWindow(), more specifically to here:

    } else {
        printf("UbuntuWindow - regular geometry\n");
        geometry = d->geometry;
        geometry.setY(d->panelHeight);
    }

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

[ubuntumirclient QPA] creating surface at (0, 58) with size (1800, 1382) with title 'qmlscene: calendar'

UbuntuWindowPrivate::createEGLSurface (this=0x2293838, nativeWindow=0xb2200998)
[ubuntumirclient QPA] created surface has size (768, 1280)

those are the log outputs that show the surface width/height the client asks for is inappropriate for phone, so shell overrides it with fullscreen (shell bug to be fixed)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

> // Use client geometry if set explicitly, use available screen geometry
> otherwise.
> d->geometry = window()->geometry() != screen->geometry() ?
> window()->geometry() : screen->availableGeometry();
>
>
> I would also move that to inside createWindow(), more specifically to here:
>
> } else {
> printf("UbuntuWindow - regular geometry\n");
> geometry = d->geometry;
> geometry.setY(d->panelHeight);
> }

That kind of refactoring is unnecessary for this bug fix, we can leave it for later.

Revision history for this message
Daniel d'Andrada (dandrader) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ubuntumirclient/input.cpp'
--- src/ubuntumirclient/input.cpp 2014-07-15 12:45:14 +0000
+++ src/ubuntumirclient/input.cpp 2014-08-08 14:04:28 +0000
@@ -278,8 +278,8 @@
278 for (int i = 0; i < kPointerCount; ++i) {278 for (int i = 0; i < kPointerCount; ++i) {
279 QWindowSystemInterface::TouchPoint touchPoint;279 QWindowSystemInterface::TouchPoint touchPoint;
280280
281 const float kX = event->motion.pointer_coordinates[i].raw_x;281 const float kX = event->motion.pointer_coordinates[i].raw_x + kWindowGeometry.x();
282 const float kY = event->motion.pointer_coordinates[i].raw_y;282 const float kY = event->motion.pointer_coordinates[i].raw_y + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere
283 const float kW = event->motion.pointer_coordinates[i].touch_major;283 const float kW = event->motion.pointer_coordinates[i].touch_major;
284 const float kH = event->motion.pointer_coordinates[i].touch_minor;284 const float kH = event->motion.pointer_coordinates[i].touch_minor;
285 const float kP = event->motion.pointer_coordinates[i].pressure;285 const float kP = event->motion.pointer_coordinates[i].pressure;
286286
=== modified file 'src/ubuntumirclient/window.cpp'
--- src/ubuntumirclient/window.cpp 2014-07-21 23:47:20 +0000
+++ src/ubuntumirclient/window.cpp 2014-08-08 14:04:28 +0000
@@ -41,6 +41,7 @@
41public:41public:
42 void createEGLSurface(EGLNativeWindowType nativeWindow);42 void createEGLSurface(EGLNativeWindowType nativeWindow);
43 void destroyEGLSurface();43 void destroyEGLSurface();
44 int panelHeight();
4445
45 UbuntuScreen* screen;46 UbuntuScreen* screen;
46 EGLSurface eglSurface;47 EGLSurface eglSurface;
@@ -54,7 +55,6 @@
54 QSize bufferSize;55 QSize bufferSize;
55 QSize targetBufferSize;56 QSize targetBufferSize;
56 QMutex mutex;57 QMutex mutex;
57 int panelHeight; // FIXME - should be removed
58};58};
5959
60static void eventCallback(void* context, const WindowEvent* event)60static void eventCallback(void* context, const WindowEvent* event)
@@ -86,21 +86,6 @@
86 window()->geometry() : screen->availableGeometry();86 window()->geometry() : screen->availableGeometry();
87 createWindow();87 createWindow();
88 DLOG("UbuntuWindow::UbuntuWindow (this=%p, w=%p, screen=%p, input=%p)", this, w, screen, input);88 DLOG("UbuntuWindow::UbuntuWindow (this=%p, w=%p, screen=%p, input=%p)", this, w, screen, input);
89
90 // FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
91 // we need to guess the panel height (3GU + 2DP)
92 const int defaultGridUnit = 8;
93 int gridUnit = defaultGridUnit;
94 QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
95 if (!gridUnitString.isEmpty()) {
96 bool ok;
97 gridUnit = gridUnitString.toInt(&ok);
98 if (!ok) {
99 gridUnit = defaultGridUnit;
100 }
101 }
102 qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
103 d->panelHeight = gridUnit * 3 + qFloor(densityPixelRatio) * 2;
104}89}
10590
106UbuntuWindow::~UbuntuWindow()91UbuntuWindow::~UbuntuWindow()
@@ -131,6 +116,24 @@
131 }116 }
132}117}
133118
119// FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
120// we need to guess the panel height (3GU + 2DP)
121int UbuntuWindowPrivate::panelHeight()
122{
123 const int defaultGridUnit = 8;
124 int gridUnit = defaultGridUnit;
125 QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
126 if (!gridUnitString.isEmpty()) {
127 bool ok;
128 gridUnit = gridUnitString.toInt(&ok);
129 if (!ok) {
130 gridUnit = defaultGridUnit;
131 }
132 }
133 qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
134 return gridUnit * 3 + qFloor(densityPixelRatio) * 2;
135}
136
134void UbuntuWindow::createWindow()137void UbuntuWindow::createWindow()
135{138{
136 DLOG("UbuntuWindow::createWindow (this=%p)", this);139 DLOG("UbuntuWindow::createWindow (this=%p)", this);
@@ -147,8 +150,10 @@
147 flags |= static_cast<uint>(IS_OPAQUE_FLAG);150 flags |= static_cast<uint>(IS_OPAQUE_FLAG);
148151
149 const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title152 const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title
153 const int panelHeight = d->panelHeight();
150154
151 #if !defined(QT_NO_DEBUG)155 #if !defined(QT_NO_DEBUG)
156 LOG("panelHeight: '%d'", panelHeight);
152 LOG("role: '%d'", role);157 LOG("role: '%d'", role);
153 LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque");158 LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque");
154 LOG("title: '%s'", title.constData());159 LOG("title: '%s'", title.constData());
@@ -162,9 +167,19 @@
162 } else if (d->state == Qt::WindowMaximized) {167 } else if (d->state == Qt::WindowMaximized) {
163 printf("UbuntuWindow - maximized geometry\n");168 printf("UbuntuWindow - maximized geometry\n");
164 geometry = screen()->availableGeometry();169 geometry = screen()->availableGeometry();
170 /*
171 * FIXME: Autopilot relies on being able to convert coordinates relative of the window
172 * into absolute screen coordinates. Mir does not allow this, see bug lp:1346633
173 * Until there's a correct way to perform this transformation agreed, this horrible hack
174 * guesses the transformation heuristically.
175 *
176 * Assumption: this method only used on phone devices!
177 */
178 geometry.setY(panelHeight);
165 } else {179 } else {
166 printf("UbuntuWindow - regular geometry\n");180 printf("UbuntuWindow - regular geometry\n");
167 geometry = d->geometry;181 geometry = d->geometry;
182 geometry.setY(panelHeight);
168 }183 }
169184
170 DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n",185 DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n",
@@ -379,21 +394,3 @@
379 }394 }
380 }395 }
381}396}
382
383QPoint UbuntuWindow::mapToGlobal(const QPoint &position) const
384{
385 /*
386 * FIXME: Autopilot relies on being able to convert coordinates relative of the window
387 * into absolute screen coordinates. Mir does not allow this, see bug lp:1346633
388 * Until there's a correct way to perform this transformation agreed, this horrible hack
389 * guesses the transformation heuristically.
390 *
391 * Assumption: this method only used on phone devices!
392 */
393
394 if (d->state == Qt::WindowFullScreen)
395 return position;
396
397 // FIXME: update when enabling rotation in shell
398 return QPoint(position.x(), position.y() + d->panelHeight);
399}
400397
=== modified file 'src/ubuntumirclient/window.h'
--- src/ubuntumirclient/window.h 2014-07-21 23:47:20 +0000
+++ src/ubuntumirclient/window.h 2014-08-08 14:04:28 +0000
@@ -45,11 +45,6 @@
4545
46 UbuntuWindowPrivate* priv() { return d; }46 UbuntuWindowPrivate* priv() { return d; }
4747
48 // Begin methods implemented as workaround for lp:1346633
49 bool isEmbedded(const QPlatformWindow *) const override { return true; }
50 QPoint mapToGlobal(const QPoint &position) const override;
51 // End methods implemented as workaround for lp:1346633
52
53public Q_SLOTS:48public Q_SLOTS:
54 void handleBufferResize(int width, int height);49 void handleBufferResize(int width, int height);
55 void forceRedraw();50 void forceRedraw();

Subscribers

People subscribed via source and target branches