Mir

Merge lp:~vanvugt/mir/fix-1655804 into lp:mir

Proposed by Daniel van Vugt
Status: Work in progress
Proposed branch: lp:~vanvugt/mir/fix-1655804
Merge into: lp:mir
Diff against target: 77 lines (+27/-4)
1 file modified
examples/eglapp.c (+27/-4)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1655804
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Review via email: mp+314601@code.launchpad.net

Commit message

Fix distorted mir_demo_client_target on start-up (LP: #1655804)
by adding a workaround for the Unity8 bug that triggers it (LP: #1542029)

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

How is a client ignoring the size allocated by the server a Unity8 bug? There are all sorts of reasons that a server may allocate a size that isn't requested (e.g. a tiling shell).

review: Needs Information
lp:~vanvugt/mir/fix-1655804 updated
3924. By Daniel van Vugt

Add a mutex too (because LP: #1194384)

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Resizing a window is perfectly valid, expected and supported. Resizing a window immediately on creation before the user has even seen it (and before the app has set a callback) is a bit unusual. No other windowing system (not tiling) I've ever seen does that. But indeed it's allowed if there are no resize constraints set.

So it's allowed but unexpected. Continue discussion in LP: #1542029...

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Resizing a window is perfectly valid, expected and supported. Resizing a
> window immediately on creation before the user has even seen it (and before
> the app has set a callback) is a bit unusual.

The app ought to set the callback on creation (that's why it is a property of the spec). And, if this fix is working, then it is clearly being called.

> No other windowing system (not
> tiling) I've ever seen does that. But indeed it's allowed if there are no
> resize constraints set.

It is allowed even if resize constraints have been set. (And required for some cases by the Mir & Unity8 design doc.)

> So it's allowed but unexpected. Continue discussion in LP: #1542029...

This is simply fixing a client bug, not working around a server issue.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

If anyone can explain why Unity8 picks a random window size over the application specified size, then please explain. Keep in mind that scaling is not an excuse, because many legacy apps and non-toolkit apps simply don't care about scaling, only pixels.

And yes I agree using the newer APIs to fix this is more appropriate. Obviously they did not exist when this code was written.

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

> If anyone can explain why Unity8 picks a random window size over the
> application specified size, then please explain. Keep in mind that scaling is
> not an excuse, because many legacy apps and non-toolkit apps simply don't care
> about scaling, only pixels.

1 - in phone and tablet mode, window size must be exactly what unity8 wants. application doesn't have a say on that

2 - in desktop mode unity8 remembers the size the window had when it was last closed. so when you launch it again it will give that size. But the first time an application is ever launched that size is a generic default unity8 guesses indeed. That needs more thought and work.

Unmerged revisions

3924. By Daniel van Vugt

Add a mutex too (because LP: #1194384)

3923. By Daniel van Vugt

Forward-port from 0.25 experiment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/eglapp.c'
2--- examples/eglapp.c 2017-01-11 18:13:25 +0000
3+++ examples/eglapp.c 2017-01-12 10:50:44 +0000
4@@ -25,6 +25,7 @@
5 #include <string.h>
6 #include <EGL/egl.h>
7 #include <GLES2/gl2.h>
8+#include <pthread.h>
9
10 #include <xkbcommon/xkbcommon-keysyms.h>
11
12@@ -37,7 +38,10 @@
13 static EGLDisplay egldisplay;
14 static EGLSurface eglsurface;
15 static volatile sig_atomic_t running = 0;
16+
17+static pthread_mutex_t event_mutex = PTHREAD_MUTEX_INITIALIZER;
18 static double refresh_rate = 0.0;
19+static int resized_width = -1, resized_height = -1;
20
21 #define CHECK(_cond, _err) \
22 if (!(_cond)) \
23@@ -136,7 +140,9 @@
24 unsigned ff = mir_window_output_event_get_form_factor(out);
25 char const* form_factor = (ff < 6) ? form_factor_name[ff] : "out-of-range";
26
27+ pthread_mutex_lock(&event_mutex);
28 refresh_rate = mir_window_output_event_get_refresh_rate(out);
29+ pthread_mutex_unlock(&event_mutex);
30
31 printf("Window is on output %u: %d DPI, scale %.1fx, %s form factor, %.2fHz\n",
32 mir_window_output_event_get_output_id(out),
33@@ -148,7 +154,10 @@
34
35 double mir_eglapp_display_hz(void)
36 {
37- return refresh_rate;
38+ pthread_mutex_lock(&event_mutex);
39+ double rate = refresh_rate;
40+ pthread_mutex_unlock(&event_mutex);
41+ return rate;
42 }
43
44 void mir_eglapp_handle_event(MirWindow* window, MirEvent const* ev, void* unused)
45@@ -177,9 +186,11 @@
46 */
47 {
48 MirResizeEvent const* resize = mir_event_get_resize_event(ev);
49- printf("Resized to %dx%d\n",
50- mir_resize_event_get_width(resize),
51- mir_resize_event_get_height(resize));
52+ pthread_mutex_lock(&event_mutex);
53+ resized_width = mir_resize_event_get_width(resize);
54+ resized_height = mir_resize_event_get_height(resize);
55+ printf("Resized to %dx%d\n", resized_width, resized_height);
56+ pthread_mutex_unlock(&event_mutex);
57 }
58 break;
59 case mir_event_type_close_window:
60@@ -518,6 +529,18 @@
61
62 running = 1;
63
64+ /*
65+ * Work around Unity8 behaving badly (LP: #1542029), which then caused
66+ * LP: #1655804 ...
67+ */
68+ pthread_mutex_lock(&event_mutex);
69+ if (resized_width >= 0 || resized_height >= 0)
70+ {
71+ *width = resized_width;
72+ *height = resized_height;
73+ }
74+ pthread_mutex_unlock(&event_mutex);
75+
76 return 1;
77 }
78

Subscribers

People subscribed via source and target branches