[gtk+/saved/mir: 33/47] mir: handle resize events
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/saved/mir: 33/47] mir: handle resize events
- Date: Wed, 22 Oct 2014 16:22:38 +0000 (UTC)
commit b96718d38bced86a99afaa1df715a7172f114927
Author: Ryan Lortie <desrt desrt ca>
Date: Thu May 29 11:36:37 2014 +0200
mir: handle resize events
...including the possibility that we don't receive the buffer size that
we request.
gdk/mir/gdkmireventsource.c | 29 ++++++++++++++++++++++++++++-
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 78ea4c3..c63b801 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 79dbe73..ab0bcc7 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]