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
1=== modified file 'src/ubuntumirclient/input.cpp'
2--- src/ubuntumirclient/input.cpp 2014-07-15 12:45:14 +0000
3+++ src/ubuntumirclient/input.cpp 2014-08-08 14:04:28 +0000
4@@ -278,8 +278,8 @@
5 for (int i = 0; i < kPointerCount; ++i) {
6 QWindowSystemInterface::TouchPoint touchPoint;
7
8- const float kX = event->motion.pointer_coordinates[i].raw_x;
9- const float kY = event->motion.pointer_coordinates[i].raw_y;
10+ const float kX = event->motion.pointer_coordinates[i].raw_x + kWindowGeometry.x();
11+ const float kY = event->motion.pointer_coordinates[i].raw_y + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere
12 const float kW = event->motion.pointer_coordinates[i].touch_major;
13 const float kH = event->motion.pointer_coordinates[i].touch_minor;
14 const float kP = event->motion.pointer_coordinates[i].pressure;
15
16=== modified file 'src/ubuntumirclient/window.cpp'
17--- src/ubuntumirclient/window.cpp 2014-07-21 23:47:20 +0000
18+++ src/ubuntumirclient/window.cpp 2014-08-08 14:04:28 +0000
19@@ -41,6 +41,7 @@
20 public:
21 void createEGLSurface(EGLNativeWindowType nativeWindow);
22 void destroyEGLSurface();
23+ int panelHeight();
24
25 UbuntuScreen* screen;
26 EGLSurface eglSurface;
27@@ -54,7 +55,6 @@
28 QSize bufferSize;
29 QSize targetBufferSize;
30 QMutex mutex;
31- int panelHeight; // FIXME - should be removed
32 };
33
34 static void eventCallback(void* context, const WindowEvent* event)
35@@ -86,21 +86,6 @@
36 window()->geometry() : screen->availableGeometry();
37 createWindow();
38 DLOG("UbuntuWindow::UbuntuWindow (this=%p, w=%p, screen=%p, input=%p)", this, w, screen, input);
39-
40- // FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
41- // we need to guess the panel height (3GU + 2DP)
42- const int defaultGridUnit = 8;
43- int gridUnit = defaultGridUnit;
44- QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
45- if (!gridUnitString.isEmpty()) {
46- bool ok;
47- gridUnit = gridUnitString.toInt(&ok);
48- if (!ok) {
49- gridUnit = defaultGridUnit;
50- }
51- }
52- qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
53- d->panelHeight = gridUnit * 3 + qFloor(densityPixelRatio) * 2;
54 }
55
56 UbuntuWindow::~UbuntuWindow()
57@@ -131,6 +116,24 @@
58 }
59 }
60
61+// FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
62+// we need to guess the panel height (3GU + 2DP)
63+int UbuntuWindowPrivate::panelHeight()
64+{
65+ const int defaultGridUnit = 8;
66+ int gridUnit = defaultGridUnit;
67+ QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
68+ if (!gridUnitString.isEmpty()) {
69+ bool ok;
70+ gridUnit = gridUnitString.toInt(&ok);
71+ if (!ok) {
72+ gridUnit = defaultGridUnit;
73+ }
74+ }
75+ qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
76+ return gridUnit * 3 + qFloor(densityPixelRatio) * 2;
77+}
78+
79 void UbuntuWindow::createWindow()
80 {
81 DLOG("UbuntuWindow::createWindow (this=%p)", this);
82@@ -147,8 +150,10 @@
83 flags |= static_cast<uint>(IS_OPAQUE_FLAG);
84
85 const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title
86+ const int panelHeight = d->panelHeight();
87
88 #if !defined(QT_NO_DEBUG)
89+ LOG("panelHeight: '%d'", panelHeight);
90 LOG("role: '%d'", role);
91 LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque");
92 LOG("title: '%s'", title.constData());
93@@ -162,9 +167,19 @@
94 } else if (d->state == Qt::WindowMaximized) {
95 printf("UbuntuWindow - maximized geometry\n");
96 geometry = screen()->availableGeometry();
97+ /*
98+ * FIXME: Autopilot relies on being able to convert coordinates relative of the window
99+ * into absolute screen coordinates. Mir does not allow this, see bug lp:1346633
100+ * Until there's a correct way to perform this transformation agreed, this horrible hack
101+ * guesses the transformation heuristically.
102+ *
103+ * Assumption: this method only used on phone devices!
104+ */
105+ geometry.setY(panelHeight);
106 } else {
107 printf("UbuntuWindow - regular geometry\n");
108 geometry = d->geometry;
109+ geometry.setY(panelHeight);
110 }
111
112 DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n",
113@@ -379,21 +394,3 @@
114 }
115 }
116 }
117-
118-QPoint UbuntuWindow::mapToGlobal(const QPoint &position) const
119-{
120- /*
121- * FIXME: Autopilot relies on being able to convert coordinates relative of the window
122- * into absolute screen coordinates. Mir does not allow this, see bug lp:1346633
123- * Until there's a correct way to perform this transformation agreed, this horrible hack
124- * guesses the transformation heuristically.
125- *
126- * Assumption: this method only used on phone devices!
127- */
128-
129- if (d->state == Qt::WindowFullScreen)
130- return position;
131-
132- // FIXME: update when enabling rotation in shell
133- return QPoint(position.x(), position.y() + d->panelHeight);
134-}
135
136=== modified file 'src/ubuntumirclient/window.h'
137--- src/ubuntumirclient/window.h 2014-07-21 23:47:20 +0000
138+++ src/ubuntumirclient/window.h 2014-08-08 14:04:28 +0000
139@@ -45,11 +45,6 @@
140
141 UbuntuWindowPrivate* priv() { return d; }
142
143- // Begin methods implemented as workaround for lp:1346633
144- bool isEmbedded(const QPlatformWindow *) const override { return true; }
145- QPoint mapToGlobal(const QPoint &position) const override;
146- // End methods implemented as workaround for lp:1346633
147-
148 public Q_SLOTS:
149 void handleBufferResize(int width, int height);
150 void forceRedraw();

Subscribers

People subscribed via source and target branches