diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-07-15 00:04:51 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-07-15 00:04:51 -0400 |
commit | 286b27e55fd78f23d1004c65f99f41bf78e01c60 (patch) | |
tree | 91f89301014d960bab579cf723a4ffc4a0abe3c2 | |
parent | 6a7de806ddd7e7dbd3f1fc972e1002070ef1e17b (diff) | |
download | gtk+-286b27e55fd78f23d1004c65f99f41bf78e01c60.tar.gz |
gdk: Make surface width and height properties
This is the first step to removing configure events.
-rw-r--r-- | gdk/broadway/gdksurface-broadway.c | 5 | ||||
-rw-r--r-- | gdk/gdkinternals.h | 4 | ||||
-rw-r--r-- | gdk/gdksurface.c | 54 | ||||
-rw-r--r-- | gdk/wayland/gdksurface-wayland.c | 13 | ||||
-rw-r--r-- | gdk/x11/gdksurface-x11.c | 19 |
5 files changed, 74 insertions, 21 deletions
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index cdacb5d0fc..0c66141dc8 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -397,8 +397,8 @@ gdk_surface_broadway_move_resize (GdkSurface *surface, impl->dirty = TRUE; impl->last_synced = FALSE; - surface->width = width; - surface->height = height; + g_object_freeze_notify (G_OBJECT (surface)); + gdk_surface_set_size (surface, width, height); } } @@ -412,6 +412,7 @@ gdk_surface_broadway_move_resize (GdkSurface *surface, { surface->resize_count++; _gdk_surface_update_size (surface); + g_object_thaw_notify (G_OBJECT (surface)); } } diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 69b5f844f1..1fb95feda7 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -292,6 +292,10 @@ void gdk_surface_get_unscaled_size (GdkSurface *surface, int *unscaled_width, int *unscaled_height); +void gdk_surface_set_size (GdkSurface *surface, + int width, + int height); + /***************************************** * Interfaces provided by windowing code * *****************************************/ diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index bb9785a0a5..9d5988996b 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -105,6 +105,8 @@ enum { PROP_CURSOR, PROP_DISPLAY, PROP_STATE, + PROP_WIDTH, + PROP_HEIGHT, LAST_PROP }; @@ -271,6 +273,21 @@ gdk_surface_class_init (GdkSurfaceClass *klass) GDK_TYPE_SURFACE_STATE, GDK_SURFACE_STATE_WITHDRAWN, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + properties[PROP_WIDTH] = + g_param_spec_int ("width", + P_("Width"), + P_("Width"), + 1, G_MAXINT, 1, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + properties[PROP_HEIGHT] = + g_param_spec_int ("height", + P_("Width"), + P_("Width"), + 1, G_MAXINT, 1, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, properties); /** @@ -416,6 +433,14 @@ gdk_surface_get_property (GObject *object, g_value_set_flags (value, surface->state); break; + case PROP_WIDTH: + g_value_set_int (value, surface->width); + break; + + case PROP_HEIGHT: + g_value_set_int (value, surface->height); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2652,6 +2677,26 @@ gdk_surface_move_resize_toplevel (GdkSurface *surface, recompute_visible_regions (surface, FALSE); } +void +gdk_surface_set_size (GdkSurface *surface, + int width, + int height) +{ + g_object_freeze_notify (G_OBJECT (surface)); + + if (surface->width != width) + { + surface->width = width; + g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_WIDTH]); + } + if (surface->height != height) + { + surface->height = height; + g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_HEIGHT]); + } + + g_object_thaw_notify (G_OBJECT (surface)); +} static void gdk_surface_move_resize_internal (GdkSurface *surface, @@ -2690,6 +2735,8 @@ gdk_surface_move_resize_internal (GdkSurface *surface, /* Handle child surfaces */ + g_object_freeze_notify (G_OBJECT (surface)); + expose = FALSE; old_region = NULL; @@ -2715,10 +2762,7 @@ gdk_surface_move_resize_internal (GdkSurface *surface, surface->y = y; } if (!(width < 0 && height < 0)) - { - surface->width = width; - surface->height = height; - } + gdk_surface_set_size (surface, width, height); recompute_visible_regions (surface, FALSE); @@ -2740,6 +2784,8 @@ gdk_surface_move_resize_internal (GdkSurface *surface, cairo_region_destroy (old_region); cairo_region_destroy (new_region); } + + g_object_thaw_notify (G_OBJECT (surface)); } diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 2aedc995d7..7113d8c2ea 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -306,8 +306,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface, (impl->scale == scale)) return; - surface->width = width; - surface->height = height; + g_object_freeze_notify (G_OBJECT (surface)); + + gdk_surface_set_size (surface, width, height); impl->scale = scale; if (impl->display_server.egl_window) @@ -316,6 +317,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface, wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale); gdk_surface_invalidate_rect (surface, NULL); + _gdk_surface_update_size (surface); + + g_object_thaw_notify (G_OBJECT (surface)); } static const gchar * @@ -701,15 +705,14 @@ gdk_wayland_surface_configure (GdkSurface *surface, GdkDisplay *display; GdkEvent *event; + gdk_wayland_surface_update_size (surface, width, height, scale); + event = gdk_event_new (GDK_CONFIGURE); event->any.surface = g_object_ref (surface); event->any.send_event = FALSE; event->configure.width = width; event->configure.height = height; - gdk_wayland_surface_update_size (surface, width, height, scale); - _gdk_surface_update_size (surface); - display = gdk_surface_get_display (surface); _gdk_wayland_display_deliver_event (display, event); } diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index f04f74d486..774c606061 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -923,11 +923,9 @@ _gdk_x11_display_create_surface_impl (GdkDisplay *display, surface->height * impl->surface_scale > 32767) { g_warning ("Native Windows wider or taller than 32767 pixels are not supported"); - - if (surface->width * impl->surface_scale > 32767) - surface->width = 32767 / impl->surface_scale; - if (surface->height * impl->surface_scale > 32767) - surface->height = 32767 / impl->surface_scale; + gdk_surface_set_size (surface, + MIN (surface->width, 32767 / impl->surface_scale), + MIN (surface->height, 32767 / impl->surface_scale)); } impl->unscaled_width = surface->width * impl->surface_scale; @@ -1371,9 +1369,10 @@ surface_x11_resize (GdkSurface *surface, { impl->unscaled_width = width * impl->surface_scale; impl->unscaled_height = height * impl->surface_scale; - surface->width = width; - surface->height = height; + g_object_freeze_notify (G_OBJECT (surface)); + gdk_surface_set_size (surface, width, height); _gdk_x11_surface_update_size (GDK_SURFACE_IMPL_X11 (surface->impl)); + g_object_thaw_notify (G_OBJECT (surface)); } else { @@ -1411,10 +1410,10 @@ surface_x11_move_resize (GdkSurface *surface, impl->unscaled_width = width * impl->surface_scale; impl->unscaled_height = height * impl->surface_scale; - surface->width = width; - surface->height = height; - + g_object_freeze_notify (G_OBJECT (surface)); + gdk_surface_set_size (surface, width, height); _gdk_x11_surface_update_size (GDK_SURFACE_IMPL_X11 (surface->impl)); + g_object_thaw_notify (G_OBJECT (surface)); } else { |