Mir

Merge lp:~vanvugt/mir/fix-1207145 into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt on 2013-08-01
Status: Merged
Approved by: Alan Griffiths on 2013-08-01
Approved revision: 910
Merged at revision: 909
Proposed branch: lp:~vanvugt/mir/fix-1207145
Merge into: lp:~mir-team/mir/trunk
Diff against target: 132 lines (+82/-15)
2 files modified
examples/eglapp.c (+49/-13)
examples/fingerpaint.c (+33/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1207145
Reviewer Review Type Date Requested Status
Alan Griffiths Approve on 2013-08-01
PS Jenkins bot (community) continuous-integration Approve on 2013-08-01
Robert Ancell Approve on 2013-08-01
Alexandros Frantzis (community) 2013-08-01 Approve on 2013-08-01
Review via email: mp+177992@code.launchpad.net

Commit message

Fix crashing demo clients, since the introduction of multimonitor.
(LP: #1207145)

Description of the change

In future, when the fullscreen state is hooked up to surface resizing (which does not exist yet), this logic will no longer be necessary. The server will resize fullscreen surfaces accordingly. But until then, clients have to figure out what the fullscreen size is...

To post a comment you must log in.
Alexandros Frantzis (afrantzis) wrote :

8 + if (out->connected &&
19 + out->num_modes &&
20 + out->current_mode < out->num_modes)

We should also (or, actually, primarily) check whether the output is 'out->used'. Right now our default configuration policy uses all connected outputs, but any server/shell can override this policy.

review: Needs Fixing
lp:~vanvugt/mir/fix-1207145 updated on 2013-08-01
910. By Daniel van Vugt on 2013-08-01

Check the output is actually in use, too.

Alexandros Frantzis (afrantzis) wrote :

Looks good.

In some multi-monitor scenarios (e.g. when cloning) this may not have the expected result because we are just taking a single (the first active) output into account, but I think this is enough for demo purposes.

review: Approve
Daniel van Vugt (vanvugt) wrote :

Yeah, I thought of that. But I think this is enough until Mir supports resizing or at least automatic creation of fullscreen surfaces.

Robert Ancell (robert-ancell) wrote :

LGTM

review: Approve
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve

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 2013-07-26 05:12:14 +0000
3+++ examples/eglapp.c 2013-08-01 07:13:28 +0000
4@@ -114,6 +114,29 @@
5 }
6 }
7
8+static const MirDisplayOutput *find_active_output(
9+ const MirDisplayConfiguration *conf)
10+{
11+ const MirDisplayOutput *output = NULL;
12+ int d;
13+
14+ for (d = 0; d < (int)conf->num_displays; d++)
15+ {
16+ const MirDisplayOutput *out = conf->displays + d;
17+
18+ if (out->used &&
19+ out->connected &&
20+ out->num_modes &&
21+ out->current_mode < out->num_modes)
22+ {
23+ output = out;
24+ break;
25+ }
26+ }
27+
28+ return output;
29+}
30+
31 mir_eglapp_bool mir_eglapp_init(int argc, char *argv[],
32 unsigned int *width, unsigned int *height)
33 {
34@@ -180,20 +203,33 @@
35 connection = mir_connect_sync(NULL, appname);
36 CHECK(mir_connection_is_valid(connection), "Can't get connection");
37
38- /* eglapps are interested in the screen size, so use mir_connection_create_display_config */
39- MirDisplayConfiguration* display_config = mir_connection_create_display_config(connection);
40- MirDisplayOutput* display_state = &display_config->displays[0];
41- MirDisplayMode mode = display_state->modes[display_state->current_mode];
42+ /* eglapps are interested in the screen size, so
43+ use mir_connection_create_display_config */
44+ MirDisplayConfiguration* display_config =
45+ mir_connection_create_display_config(connection);
46+
47+ const MirDisplayOutput *output = find_active_output(display_config);
48+
49+ if (output == NULL)
50+ {
51+ printf("No active outputs found.\n");
52+ return 0;
53+ }
54+
55+ const MirDisplayMode *mode = &output->modes[0];
56+
57 unsigned int valid_formats;
58- mir_connection_get_available_surface_formats(connection, &surfaceparm.pixel_format, 1, &valid_formats);
59-
60- printf("Connected to display: resolution (%dx%d), position(%dx%d), supports %d pixel formats\n",
61- mode.horizontal_resolution, mode.vertical_resolution,
62- display_state->position_x, display_state->position_y,
63- display_state->num_output_formats);
64-
65- surfaceparm.width = *width > 0 ? *width : mode.horizontal_resolution;
66- surfaceparm.height = *height > 0 ? *height : mode.vertical_resolution;
67+ mir_connection_get_available_surface_formats(connection,
68+ &surfaceparm.pixel_format, 1, &valid_formats);
69+
70+ printf("Connected to display: resolution (%dx%d), position(%dx%d), "
71+ "supports %d pixel formats\n",
72+ mode->horizontal_resolution, mode->vertical_resolution,
73+ output->position_x, output->position_y,
74+ output->num_output_formats);
75+
76+ surfaceparm.width = *width > 0 ? *width : mode->horizontal_resolution;
77+ surfaceparm.height = *height > 0 ? *height : mode->vertical_resolution;
78
79 mir_display_config_destroy(display_config);
80
81
82=== modified file 'examples/fingerpaint.c'
83--- examples/fingerpaint.c 2013-07-26 05:12:14 +0000
84+++ examples/fingerpaint.c 2013-08-01 07:13:28 +0000
85@@ -248,6 +248,29 @@
86 }
87 }
88
89+static const MirDisplayOutput *find_active_output(
90+ const MirDisplayConfiguration *conf)
91+{
92+ const MirDisplayOutput *output = NULL;
93+ int d;
94+
95+ for (d = 0; d < (int)conf->num_displays; d++)
96+ {
97+ const MirDisplayOutput *out = conf->displays + d;
98+
99+ if (out->used &&
100+ out->connected &&
101+ out->num_modes &&
102+ out->current_mode < out->num_modes)
103+ {
104+ output = out;
105+ break;
106+ }
107+ }
108+
109+ return output;
110+}
111+
112 int main(int argc, char *argv[])
113 {
114 static const Color background = {0x40, 0x40, 0x40, 0xff};
115@@ -267,8 +290,16 @@
116 return 1;
117 }
118
119- MirDisplayConfiguration* display_config = mir_connection_create_display_config(conn);
120- MirDisplayOutput* dinfo = &display_config->displays[0];
121+ MirDisplayConfiguration *display_config =
122+ mir_connection_create_display_config(conn);
123+
124+ const MirDisplayOutput *dinfo = find_active_output(display_config);
125+ if (dinfo == NULL)
126+ {
127+ fprintf(stderr, "No active outputs found.\n");
128+ mir_connection_release(conn);
129+ return 1;
130+ }
131
132 parm.buffer_usage = mir_buffer_usage_software;
133

Subscribers

People subscribed via source and target branches