diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2019-07-15 11:35:24 +0200 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2019-07-25 10:24:50 +0200 |
commit | fc68d1b1e65699571a2a5cef4c51481577667808 (patch) | |
tree | 0c5f83811b0d2ebbc34263f453df34f60b70a8f7 | |
parent | b329090e69e3c4697029aa14d1f471736b2ed2a8 (diff) | |
download | gtk+-fc68d1b1e65699571a2a5cef4c51481577667808.tar.gz |
gdk: Make backends implement move_to_rect()
The generic layer still does the heavy lifting, leaving the backends
more or less just act as thin wrappers, dealing a bit with global
coordinate transformations. The end goal is to remove explicit surface
moving from the generic gdk layer.
-rw-r--r-- | gdk/broadway/gdksurface-broadway.c | 50 | ||||
-rw-r--r-- | gdk/gdksurface.c | 25 | ||||
-rw-r--r-- | gdk/gdksurfaceprivate.h | 13 | ||||
-rw-r--r-- | gdk/quartz/gdksurface-quartz.c | 49 | ||||
-rw-r--r-- | gdk/win32/gdksurface-win32.c | 50 | ||||
-rw-r--r-- | gdk/x11/gdksurface-x11.c | 50 |
6 files changed, 223 insertions, 14 deletions
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index d3da074030..90f14563c5 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -441,6 +441,55 @@ gdk_broadway_surface_move (GdkSurface *surface, } static void +gdk_broadway_surface_moved_to_rect (GdkSurface *surface, + GdkRectangle final_rect) +{ + GdkSurface *toplevel; + int x, y; + + if (surface->surface_type == GDK_SURFACE_POPUP) + toplevel = surface->parent; + else + toplevel = surface->transient_for; + + gdk_surface_get_origin (toplevel, &x, &y); + x += final_rect.x; + y += final_rect.y; + + if (final_rect.width != surface->width || + final_rect.height != surface->height) + { + gdk_broadway_surface_move_resize (surface, + TRUE, + x, y, + final_rect.width, final_rect.height); + } + else + { + gdk_broadway_surface_move (surface, x, y); + } +} + +static void +gdk_broadway_surface_move_to_rect (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy) +{ + gdk_surface_move_to_rect_helper (surface, + rect, + rect_anchor, + surface_anchor, + anchor_hints, + rect_anchor_dx, + rect_anchor_dy, + gdk_broadway_surface_moved_to_rect); +} + +static void gdk_broadway_surface_raise (GdkSurface *surface) { } @@ -1329,6 +1378,7 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass) impl_class->restack_toplevel = gdk_broadway_surface_restack_toplevel; impl_class->move_resize = gdk_broadway_surface_move_resize; impl_class->toplevel_resize = gdk_broadway_surface_toplevel_resize; + impl_class->move_to_rect = gdk_broadway_surface_move_to_rect; impl_class->get_geometry = gdk_broadway_surface_get_geometry; impl_class->get_root_coords = gdk_broadway_surface_get_root_coords; impl_class->get_device_state = gdk_broadway_surface_get_device_state; diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index e5c41e68c4..8c52953972 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -253,14 +253,15 @@ maybe_flip_position (gint bounds_pos, return primary; } -static void -gdk_surface_real_move_to_rect (GdkSurface *surface, - const GdkRectangle *rect, - GdkGravity rect_anchor, - GdkGravity surface_anchor, - GdkAnchorHints anchor_hints, - gint rect_anchor_dx, - gint rect_anchor_dy) +void +gdk_surface_move_to_rect_helper (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy, + GdkSurfaceMovedToRect moved_to_rect) { GdkSurface *toplevel; GdkDisplay *display; @@ -369,17 +370,14 @@ gdk_surface_real_move_to_rect (GdkSurface *surface, final_rect.width += surface->shadow_left + surface->shadow_right; final_rect.height += surface->shadow_top + surface->shadow_bottom; - if (final_rect.width != surface->width || final_rect.height != surface->height) - gdk_surface_move_resize (surface, final_rect.x, final_rect.y, final_rect.width, final_rect.height); - else - gdk_surface_move_resize_internal (surface, TRUE, final_rect.x, final_rect.y, -1, -1); - gdk_surface_get_origin (toplevel, &x, &y); final_rect.x -= x; final_rect.y -= y; flipped_rect.x -= x; flipped_rect.y -= y; + moved_to_rect (surface, final_rect); + g_signal_emit_by_name (surface, "moved-to-rect", &flipped_rect, @@ -418,7 +416,6 @@ gdk_surface_class_init (GdkSurfaceClass *klass) object_class->get_property = gdk_surface_get_property; klass->beep = gdk_surface_real_beep; - klass->move_to_rect = gdk_surface_real_move_to_rect; /** * GdkSurface:cursor: diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index eb7702f09b..c6d9134ffc 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -261,6 +261,19 @@ struct _GdkSurfaceClass void gdk_surface_set_state (GdkSurface *surface, GdkSurfaceState new_state); +typedef void (* GdkSurfaceMovedToRect) (GdkSurface *surface, + GdkRectangle final_rect); + +void +gdk_surface_move_to_rect_helper (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy, + GdkSurfaceMovedToRect moved_to_rect); + G_END_DECLS #endif /* __GDK_SURFACE_PRIVATE_H__ */ diff --git a/gdk/quartz/gdksurface-quartz.c b/gdk/quartz/gdksurface-quartz.c index f77dc3f9bd..5d7240a52f 100644 --- a/gdk/quartz/gdksurface-quartz.c +++ b/gdk/quartz/gdksurface-quartz.c @@ -1263,6 +1263,54 @@ gdk_surface_quartz_toplevel_resize (GdkSurface *surface, window_quartz_resize (window, width, height); } +static void +gdk_quartz_surface_moved_to_rect (GdkSurface *surface, + GdkRectangle final_rect) +{ + GdkSurface *toplevel; + int x, y; + + if (surface->surface_type == GDK_SURFACE_POPUP) + toplevel = surface->parent; + else + toplevel = surface->transient_for; + + gdk_surface_get_origin (toplevel, &x, &y); + x += final_rect.x; + y += final_rect.y; + + if (final_rect.width != surface->width || + final_rect.height != surface->height) + { + window_quartz_move_resize (surface, + x, y, + final_rect.width, final_rect.height); + } + else + { + window_quartz_resize (surface, final_rect.width, final_rect.height); + } +} + +static void +gdk_quartz_surface_move_to_rect (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy) +{ + gdk_surface_move_to_rect_helper (surface, + rect, + rect_anchor, + surface_anchor, + anchor_hints, + rect_anchor_dx, + rect_anchor_dy, + gdk_quartz_surface_moved_to_rect); +} + /* Get the toplevel ordering from NSApp and update our own list. We do * this on demand since the NSApp’s list is not up to date directly * after we get windowDidBecomeMain. @@ -2651,6 +2699,7 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass) impl_class->restack_toplevel = gdk_surface_quartz_restack_toplevel; impl_class->move_resize = gdk_surface_quartz_move_resize; impl_class->toplevel_resize = gdk_surface_quartz_toplevel_resize; + impl_class->move_to_rect = gdk_surface_quartz_move_to_rect; impl_class->get_geometry = gdk_surface_quartz_get_geometry; impl_class->get_root_coords = gdk_surface_quartz_get_root_coords; impl_class->get_device_state = gdk_surface_quartz_get_device_state; diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 32d853b8d7..b6b739ba9a 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -1279,6 +1279,55 @@ gdk_win32_surface_move (GdkSurface *surface, } static void +gdk_win32_surface_moved_to_rect (GdkSurface *surface, + GdkRectangle final_rect) +{ + GdkSurface *toplevel; + int x, y; + + if (surface->surface_type == GDK_SURFACE_POPUP) + toplevel = surface->parent; + else + toplevel = surface->transient_for; + + gdk_surface_get_origin (toplevel, &x, &y); + x += final_rect.x; + y += final_rect.y; + + if (final_rect.width != surface->width || + final_rect.height != surface->height) + { + gdk_win32_surface_move_resize (surface, + TRUE, + x, y, + final_rect.width, final_rect.height); + } + else + { + gdk_win32_surface_move (surface, x, y); + } +} + +static void +gdk_win32_surface_move_to_rect (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy) +{ + gdk_surface_move_to_rect_helper (surface, + rect, + rect_anchor, + surface_anchor, + anchor_hints, + rect_anchor_dx, + rect_anchor_dy, + gdk_win32_surface_moved_to_rect); +} + +static void gdk_win32_surface_raise (GdkSurface *window) { if (!GDK_SURFACE_DESTROYED (window)) @@ -5100,6 +5149,7 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass) impl_class->restack_toplevel = gdk_win32_surface_restack_toplevel; impl_class->move_resize = gdk_win32_surface_move_resize; impl_class->toplevel_resize = gdk_win32_surface_toplevel_resize; + impl_class->move_to_rect = gdk_win32_surface_move_to_rect; impl_class->get_geometry = gdk_win32_surface_get_geometry; impl_class->get_device_state = gdk_surface_win32_get_device_state; impl_class->get_root_coords = gdk_win32_surface_get_root_coords; diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 1ad97c2f7f..690b72faaf 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -1408,6 +1408,55 @@ gdk_x11_surface_move (GdkSurface *surface, gdk_x11_surface_move_resize (surface, TRUE, x, y, -1, -1); } +static void +gdk_x11_surface_moved_to_rect (GdkSurface *surface, + GdkRectangle final_rect) +{ + GdkSurface *toplevel; + int x, y; + + if (surface->surface_type == GDK_SURFACE_POPUP) + toplevel = surface->parent; + else + toplevel = surface->transient_for; + + gdk_surface_get_origin (toplevel, &x, &y); + x += final_rect.x; + y += final_rect.y; + + if (final_rect.width != surface->width || + final_rect.height != surface->height) + { + gdk_x11_surface_move_resize (surface, + TRUE, + x, y, + final_rect.width, final_rect.height); + } + else + { + gdk_x11_surface_move (surface, x, y); + } +} + +static void +gdk_x11_surface_move_to_rect (GdkSurface *surface, + const GdkRectangle *rect, + GdkGravity rect_anchor, + GdkGravity surface_anchor, + GdkAnchorHints anchor_hints, + gint rect_anchor_dx, + gint rect_anchor_dy) +{ + gdk_surface_move_to_rect_helper (surface, + rect, + rect_anchor, + surface_anchor, + anchor_hints, + rect_anchor_dx, + rect_anchor_dy, + gdk_x11_surface_moved_to_rect); +} + static void gdk_x11_surface_restack_toplevel (GdkSurface *surface, GdkSurface *sibling, gboolean above); @@ -4607,6 +4656,7 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass) impl_class->restack_toplevel = gdk_x11_surface_restack_toplevel; impl_class->move_resize = gdk_x11_surface_move_resize; impl_class->toplevel_resize = gdk_x11_surface_toplevel_resize; + impl_class->move_to_rect = gdk_x11_surface_move_to_rect; impl_class->get_geometry = gdk_x11_surface_get_geometry; impl_class->get_root_coords = gdk_x11_surface_get_root_coords; impl_class->get_device_state = gdk_x11_surface_get_device_state; |