diff options
author | Ryan Lortie <desrt@desrt.ca> | 2014-05-29 11:36:37 +0200 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-10-22 11:02:53 -0500 |
commit | b96718d38bced86a99afaa1df715a7172f114927 (patch) | |
tree | 6f7718a219bf7e2c17e07e8758bab2194d031a52 | |
parent | ca5c465af1825ba9e0d72ef052dd1f745a544864 (diff) | |
download | gtk+-b96718d38bced86a99afaa1df715a7172f114927.tar.gz |
mir: handle resize events
...including the possibility that we don't receive the buffer size that
we request.
-rw-r--r-- | gdk/mir/gdkmireventsource.c | 29 | ||||
-rw-r--r-- | gdk/mir/gdkmirwindowimpl.c | 20 |
2 files changed, 46 insertions, 3 deletions
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c index 78ea4c3a56..c63b801caf 100644 --- a/gdk/mir/gdkmireventsource.c +++ b/gdk/mir/gdkmireventsource.c @@ -627,6 +627,32 @@ handle_surface_event (GdkWindow *window, const MirSurfaceEvent *event) } } +static void +generate_configure_event (GdkWindow *window, + gint width, + gint height) +{ + GdkEvent *event; + + event = gdk_event_new (GDK_CONFIGURE); + event->configure.send_event = FALSE; + event->configure.width = width; + event->configure.height = height; + + send_event (window, get_pointer (window), event); +} + +static void +handle_resize_event (GdkWindow *window, + const MirResizeEvent *event) +{ + window->width = event->width; + window->height = event->height; + _gdk_window_update_size (window); + + generate_configure_event (window, event->width, event->height); +} + typedef struct { GdkWindow *window; @@ -654,9 +680,10 @@ gdk_mir_event_source_queue_event (GdkDisplay *display, handle_surface_event (window, &event->surface); break; case mir_event_type_resize: - // FIXME: Generate configure event + handle_resize_event (window, &event->resize); break; default: + g_assert_not_reached (); // FIXME? break; } diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c index 79dbe7353a..ab0bcc7d9c 100644 --- a/gdk/mir/gdkmirwindowimpl.c +++ b/gdk/mir/gdkmirwindowimpl.c @@ -82,6 +82,7 @@ ensure_surface (GdkWindow *window) unsigned int n_formats, i; MirSurfaceParameters parameters; MirEventDelegate event_delegate = { event_cb, NULL }; + GdkMirWindowReference *window_ref; if (impl->surface) return; @@ -89,7 +90,9 @@ ensure_surface (GdkWindow *window) /* no destroy notify -- we must leak for now * https://bugs.launchpad.net/mir/+bug/1324100 */ - event_delegate.context = _gdk_mir_event_source_get_window_reference (window); + window_ref = _gdk_mir_event_source_get_window_reference (window); + + event_delegate.context = window_ref; // Should probably calculate this once? // Should prefer certain formats over others @@ -108,6 +111,20 @@ ensure_surface (GdkWindow *window) parameters.buffer_usage = mir_buffer_usage_software; parameters.output_id = mir_display_output_id_invalid; impl->surface = mir_connection_create_surface_sync (get_connection (window), ¶meters); + + MirGraphicsRegion region; + MirEvent resize_event; + + mir_surface_get_graphics_region (impl->surface, ®ion); + + /* Send the initial configure with the size the server gave... */ + resize_event.resize.type = mir_event_type_resize; + resize_event.resize.surface_id = 0; + resize_event.resize.width = region.width; + resize_event.resize.height = region.height; + + _gdk_mir_event_source_queue (window_ref, &resize_event); + mir_surface_set_event_handler (impl->surface, &event_delegate); // FIXME: Ignore some events until shown set_surface_state (impl, impl->surface_state); } @@ -116,7 +133,6 @@ static void ensure_no_surface (GdkWindow *window) { GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl); - GdkMirWindowReference *window_ref; if (impl->cairo_surface) { |