Mir

Merge lp:~alan-griffiths/mir/mir_create_window_spec into lp:mir

Proposed by Alan Griffiths
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~alan-griffiths/mir/mir_create_window_spec
Merge into: lp:mir
Diff against target: 224 lines (+55/-46)
5 files modified
examples/flicker.c (+16/-24)
examples/progressbar.c (+10/-19)
include/client/mir_toolkit/mir_window.h (+15/-3)
src/client/mir_surface_api.cpp (+13/-0)
src/client/symbols.map (+1/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/mir_create_window_spec
Reviewer Review Type Date Requested Status
Alan Griffiths Disapprove
Brandon Schaefer (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+324878@code.launchpad.net

Commit message

Add mir_window_create_spec() to make resizing Render Surfaces simpler to code.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:4183
https://mir-jenkins.ubuntu.com/job/mir-ci/3425/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/4667
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/4800
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/4790
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/4790
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/4790
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=artful/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=artful/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=artful/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=mesa,release=zesty/4703/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4703
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/4703/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/3425/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Only nit i see is the pointer is on the right "Type *<var>" vs left but lgtm

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

I've thought of an alternative, possibly more general, approach. We should chose after that's proposed.

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

> I've thought of an alternative, possibly more general, approach. We should
> chose after that's proposed.

lp:~alan-griffiths/mir/mir_window_get_connection/+merge/325143

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

Actually, I'm sure the other approach is better.

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/flicker.c'
--- examples/flicker.c 2017-05-19 13:49:04 +0000
+++ examples/flicker.c 2017-05-31 17:11:43 +0000
@@ -101,15 +101,9 @@
101 }101 }
102}102}
103103
104typedef struct Context
105{
106 MirConnection *connection;
107 MirRenderSurface* surface;
108} Context;
109
110static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)104static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)
111{105{
112 Context* context = (Context*)context_;106 MirRenderSurface* surface = (MirRenderSurface*)context_;
113107
114 switch (mir_event_get_type(ev))108 switch (mir_event_get_type(ev))
115 {109 {
@@ -119,9 +113,9 @@
119 int const new_width = mir_resize_event_get_width(resize);113 int const new_width = mir_resize_event_get_width(resize);
120 int const new_height = mir_resize_event_get_height(resize);114 int const new_height = mir_resize_event_get_height(resize);
121115
122 mir_render_surface_set_size(context->surface, new_width, new_height);116 mir_render_surface_set_size(surface, new_width, new_height);
123 MirWindowSpec* spec = mir_create_window_spec(context->connection);117 MirWindowSpec* spec = mir_window_create_spec(window);
124 mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);118 mir_window_spec_add_render_surface(spec, surface, new_width, new_height, 0, 0);
125 mir_window_apply_spec(window, spec);119 mir_window_apply_spec(window, spec);
126 mir_window_spec_release(spec);120 mir_window_spec_release(spec);
127 break;121 break;
@@ -177,30 +171,28 @@
177 }171 }
178 }172 }
179173
180 Context context = { 0, 0 };
181
182 puts("Starting");174 puts("Starting");
183175
184 context.connection = mir_connect_sync(socket_file, __FILE__);176 MirConnection *const connection = mir_connect_sync(socket_file, __FILE__);
185 assert(context.connection != NULL);177 assert(connection != NULL);
186 assert(mir_connection_is_valid(context.connection));178 assert(mir_connection_is_valid(connection));
187 assert(strcmp(mir_connection_get_error_message(context.connection), "") == 0);179 assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
188 puts("Connected");180 puts("Connected");
189181
190 unsigned int const num_formats = 32;182 unsigned int const num_formats = 32;
191 MirPixelFormat pixel_formats[num_formats];183 MirPixelFormat pixel_formats[num_formats];
192 unsigned int valid_formats;184 unsigned int valid_formats;
193 mir_connection_get_available_surface_formats(context.connection, pixel_formats, num_formats, &valid_formats);185 mir_connection_get_available_surface_formats(connection, pixel_formats, num_formats, &valid_formats);
194 MirPixelFormat pixel_format = find_8888_format(pixel_formats, valid_formats);186 MirPixelFormat pixel_format = find_8888_format(pixel_formats, valid_formats);
195187
196 context.surface = mir_connection_create_render_surface_sync(context.connection, width, height);188 MirRenderSurface *const surface = mir_connection_create_render_surface_sync(connection, width, height);
197 puts("Surface created");189 puts("Surface created");
198190
199 MirWindowSpec *spec = mir_create_normal_window_spec(context.connection, width, height);191 MirWindowSpec *spec = mir_create_normal_window_spec(connection, width, height);
200 assert(spec != NULL);192 assert(spec != NULL);
201 mir_window_spec_set_name(spec, __FILE__);193 mir_window_spec_set_name(spec, __FILE__);
202 mir_window_spec_add_render_surface(spec, context.surface, width, height, 0, 0);194 mir_window_spec_add_render_surface(spec, surface, width, height, 0, 0);
203 mir_window_spec_set_event_handler(spec, handle_event, &context);195 mir_window_spec_set_event_handler(spec, handle_event, surface);
204196
205 window = mir_create_window_sync(spec);197 window = mir_create_window_sync(spec);
206 mir_window_spec_release(spec);198 mir_window_spec_release(spec);
@@ -210,7 +202,7 @@
210 assert(strcmp(mir_window_get_error_message(window), "") == 0);202 assert(strcmp(mir_window_get_error_message(window), "") == 0);
211 puts("Window created");203 puts("Window created");
212204
213 MirBufferStream* bs = mir_render_surface_get_buffer_stream(context.surface, width, height, pixel_format);205 MirBufferStream* bs = mir_render_surface_get_buffer_stream(surface, width, height, pixel_format);
214 mir_buffer_stream_set_swapinterval(bs, swapinterval);206 mir_buffer_stream_set_swapinterval(bs, swapinterval);
215207
216 uint32_t pattern[2] = {0};208 uint32_t pattern[2] = {0};
@@ -234,10 +226,10 @@
234 mir_window_release_sync(window);226 mir_window_release_sync(window);
235 puts("Window released");227 puts("Window released");
236228
237 mir_render_surface_release(context.surface);229 mir_render_surface_release(surface);
238 puts("Surface released");230 puts("Surface released");
239231
240 mir_connection_release(context.connection);232 mir_connection_release(connection);
241 puts("Connection released");233 puts("Connection released");
242234
243 return 0;235 return 0;
244236
=== modified file 'examples/progressbar.c'
--- examples/progressbar.c 2017-05-19 15:11:18 +0000
+++ examples/progressbar.c 2017-05-31 17:11:43 +0000
@@ -52,15 +52,9 @@
52 }52 }
53}53}
5454
55typedef struct55static void handle_event(MirWindow* window, MirEvent const* ev, void* context)
56{56{
57 MirConnection *conn;57 MirRenderSurface* surface = (MirRenderSurface*)context;
58 MirRenderSurface* surface;
59} Surface;
60
61static void handle_event(MirWindow* window, MirEvent const* ev, void* context_)
62{
63 Surface* context = (Surface*)context_;
6458
65 switch (mir_event_get_type(ev))59 switch (mir_event_get_type(ev))
66 {60 {
@@ -70,9 +64,9 @@
70 int const new_width = mir_resize_event_get_width(resize);64 int const new_width = mir_resize_event_get_width(resize);
71 int const new_height = mir_resize_event_get_height(resize);65 int const new_height = mir_resize_event_get_height(resize);
7266
73 mir_render_surface_set_size(context->surface, new_width, new_height);67 mir_render_surface_set_size(surface, new_width, new_height);
74 MirWindowSpec* spec = mir_create_window_spec(context->conn);68 MirWindowSpec* spec = mir_window_create_spec(window);
75 mir_window_spec_add_render_surface(spec, context->surface, new_width, new_height, 0, 0);69 mir_window_spec_add_render_surface(spec, surface, new_width, new_height, 0, 0);
76 mir_window_apply_spec(window, spec);70 mir_window_apply_spec(window, spec);
77 mir_window_spec_release(spec);71 mir_window_spec_release(spec);
78 break;72 break;
@@ -286,16 +280,13 @@
286 int width = 500;280 int width = 500;
287 int height = 500;281 int height = 500;
288282
289 Surface surface;283 MirRenderSurface *const surface = mir_connection_create_render_surface_sync(conn, width, height);
290284 MirBufferStream *bs = mir_render_surface_get_buffer_stream(surface, width, height, pixel_format);
291 surface.conn = conn;
292 surface.surface = mir_connection_create_render_surface_sync(conn, width, height);
293 MirBufferStream *bs = mir_render_surface_get_buffer_stream(surface.surface, width, height, pixel_format);
294285
295 MirWindowSpec *spec = mir_create_normal_window_spec(conn, width, height);286 MirWindowSpec *spec = mir_create_normal_window_spec(conn, width, height);
296287
297 mir_window_spec_add_render_surface(spec, surface.surface, width, height, 0, 0);288 mir_window_spec_add_render_surface(spec, surface, width, height, 0, 0);
298 mir_window_spec_set_event_handler(spec, &handle_event, &surface);289 mir_window_spec_set_event_handler(spec, &handle_event, surface);
299290
300 if (spec == NULL)291 if (spec == NULL)
301 {292 {
302293
=== modified file 'include/client/mir_toolkit/mir_window.h'
--- include/client/mir_toolkit/mir_window.h 2017-05-25 08:58:03 +0000
+++ include/client/mir_toolkit/mir_window.h 2017-05-31 17:11:43 +0000
@@ -219,9 +219,8 @@
219 * Create a window specification.219 * Create a window specification.
220 * This can be used with mir_create_window() to create a window or with220 * This can be used with mir_create_window() to create a window or with
221 * mir_window_apply_spec() to change an existing window.221 * mir_window_apply_spec() to change an existing window.
222 * \remark For use with mir_create_window() at least the type, width, height,222 * \remark For use with mir_create_window() at least the type, width and height
223 * format and buffer_usage must be set. (And for types requiring a parent that223 * must be set. (And for types requiring a parent that too must be set.)
224 * too must be set.)
225 *224 *
226 * \param [in] connection a valid mir connection225 * \param [in] connection a valid mir connection
227 * \return A handle that can ultimately be passed to226 * \return A handle that can ultimately be passed to
@@ -230,6 +229,19 @@
230MirWindowSpec* mir_create_window_spec(MirConnection* connection);229MirWindowSpec* mir_create_window_spec(MirConnection* connection);
231230
232/**231/**
232 * Create a window specification.
233 * This can be used with mir_create_window() to create a window or with
234 * mir_window_apply_spec() to change an existing window.
235 * \remark For use with mir_create_window() at least the type, width and height
236 * must be set. (And for types requiring a parent that too must be set.)
237 *
238 * \param [in] window a valid MirWindow
239 * \return A handle that can ultimately be passed to
240 * mir_create_window() or mir_window_apply_spec()
241 */
242MirWindowSpec* mir_window_create_spec(MirWindow* window);
243
244/**
233 * Set the requested parent.245 * Set the requested parent.
234 *246 *
235 * \param [in] spec Specification to mutate247 * \param [in] spec Specification to mutate
236248
=== modified file 'src/client/mir_surface_api.cpp'
--- src/client/mir_surface_api.cpp 2017-05-08 03:04:26 +0000
+++ src/client/mir_surface_api.cpp 2017-05-31 17:11:43 +0000
@@ -184,6 +184,19 @@
184 std::abort(); // If we just failed to allocate a MirWindowSpec returning isn't safe184 std::abort(); // If we just failed to allocate a MirWindowSpec returning isn't safe
185}185}
186186
187MirWindowSpec* mir_window_create_spec(MirWindow* window)
188try
189{
190 mir::require(mir_window_is_valid(window));
191
192 return mir_create_window_spec(window->connection());
193}
194catch (std::exception const& ex)
195{
196 MIR_LOG_UNCAUGHT_EXCEPTION(ex);
197 std::abort(); // If we just failed to allocate a MirWindowSpec returning isn't safe
198}
199
187void mir_window_spec_set_parent(MirWindowSpec* spec, MirWindow* parent)200void mir_window_spec_set_parent(MirWindowSpec* spec, MirWindow* parent)
188try201try
189{202{
190203
=== modified file 'src/client/symbols.map'
--- src/client/symbols.map 2017-05-25 08:58:03 +0000
+++ src/client/symbols.map 2017-05-31 17:11:43 +0000
@@ -607,6 +607,7 @@
607 mir_output_has_custom_logical_size;607 mir_output_has_custom_logical_size;
608 mir_output_set_logical_size;608 mir_output_set_logical_size;
609 mir_output_get_logical_width;609 mir_output_get_logical_width;
610 mir_window_create_spec;
610 mir_window_request_user_move;611 mir_window_request_user_move;
611 mir_window_request_user_resize;612 mir_window_request_user_resize;
612 mir_touchscreen_config_get_mapping_mode;613 mir_touchscreen_config_get_mapping_mode;

Subscribers

People subscribed via source and target branches