[gtk: 4/16] wayland: Remove position method split



commit f284e1d48357d16db6fbec617f85ff95559fb46e
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Jul 24 18:44:32 2019 +0200

    wayland: Remove position method split
    
    Position can only be done via gdk_surface_queue_relayout(); the legacy
    way is no longer possible, so remove the legacy positioning code.

 gdk/wayland/gdksurface-wayland.c | 91 ++++------------------------------------
 1 file changed, 7 insertions(+), 84 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index c93ec998b1..b3608dab3b 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -52,13 +52,6 @@ static guint signals[LAST_SIGNAL];
 
 #define MAX_WL_BUFFER_SIZE (4083) /* 4096 minus header, string argument length and NUL byte */
 
-typedef enum _PositionMethod
-{
-  POSITION_METHOD_NONE,
-  POSITION_METHOD_MOVE_RESIZE,
-  POSITION_METHOD_MOVE_TO_RECT
-} PositionMethod;
-
 struct _GdkWaylandSurface
 {
   GdkSurface parent_instance;
@@ -95,7 +88,7 @@ struct _GdkWaylandSurface
   GdkSurfaceTypeHint hint;
   GdkSurface *transient_for;
   GdkSurface *popup_parent;
-  PositionMethod position_method;
+  gboolean has_layout_data;
 
   int pending_buffer_offset_x;
   int pending_buffer_offset_y;
@@ -1174,9 +1167,6 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
                                      impl->pending.serial);
     }
 
-  if (impl->position_method != POSITION_METHOD_MOVE_TO_RECT)
-    return;
-
   x = impl->pending.popup.x;
   y = impl->pending.popup.y;
   width = impl->pending.popup.width;
@@ -1192,8 +1182,6 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
                                   &flipped_x,
                                   &flipped_y);
 
-  impl->position_method = POSITION_METHOD_MOVE_TO_RECT;
-
   g_signal_emit_by_name (surface,
                          "moved-to-rect",
                          &flipped_rect,
@@ -2037,6 +2025,8 @@ create_dynamic_positioner (GdkSurface *surface)
   gint real_anchor_rect_x, real_anchor_rect_y;
   gint anchor_rect_width, anchor_rect_height;
 
+  g_warn_if_fail (impl->has_layout_data);
+
   gdk_wayland_surface_get_window_geometry (surface, &geometry);
 
   real_anchor_rect_x = impl->pending_move_to_rect.rect.x;
@@ -2139,70 +2129,6 @@ create_dynamic_positioner (GdkSurface *surface)
   g_assert_not_reached ();
 }
 
-static gpointer
-create_simple_positioner (GdkSurface *surface,
-                          GdkSurface *parent)
-{
-  GdkWaylandDisplay *display =
-    GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
-  GdkRectangle geometry;
-  GdkRectangle parent_geometry;
-  int parent_x, parent_y;
-
-  gdk_wayland_surface_get_window_geometry (surface, &geometry);
-
-  parent_x = parent->x;
-  parent_y = parent->y;
-
-  gdk_wayland_surface_get_window_geometry (parent, &parent_geometry);
-  parent_x += parent_geometry.x;
-  parent_y += parent_geometry.y;
-
-  switch (display->shell_variant)
-    {
-    case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
-      {
-        struct xdg_positioner *positioner;
-
-        positioner = xdg_wm_base_create_positioner (display->xdg_wm_base);
-        xdg_positioner_set_size (positioner, geometry.width, geometry.height);
-        xdg_positioner_set_anchor_rect (positioner,
-                                        (surface->x + geometry.x) - parent_x,
-                                        (surface->y + geometry.y) - parent_y,
-                                        1, 1);
-        xdg_positioner_set_anchor (positioner,
-                                   XDG_POSITIONER_ANCHOR_TOP_LEFT);
-        xdg_positioner_set_gravity (positioner,
-                                    XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
-
-        return positioner;
-      }
-    case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
-      {
-        struct zxdg_positioner_v6 *positioner;
-
-        positioner = zxdg_shell_v6_create_positioner (display->zxdg_shell_v6);
-        zxdg_positioner_v6_set_size (positioner, geometry.width, geometry.height);
-        zxdg_positioner_v6_set_anchor_rect (positioner,
-                                            (surface->x + geometry.x) - parent_x,
-                                            (surface->y + geometry.y) - parent_y,
-                                            1, 1);
-        zxdg_positioner_v6_set_anchor (positioner,
-                                       (ZXDG_POSITIONER_V6_ANCHOR_TOP |
-                                        ZXDG_POSITIONER_V6_ANCHOR_LEFT));
-        zxdg_positioner_v6_set_gravity (positioner,
-                                        (ZXDG_POSITIONER_V6_GRAVITY_BOTTOM |
-                                         ZXDG_POSITIONER_V6_GRAVITY_RIGHT));
-
-        return positioner;
-      }
-    default:
-      g_assert_not_reached ();
-    }
-
-  g_assert_not_reached ();
-}
-
 static void
 gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
                                       GdkSurface     *parent,
@@ -2241,10 +2167,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
 
   gdk_surface_freeze_updates (surface);
 
-  if (impl->position_method == POSITION_METHOD_MOVE_TO_RECT)
-    positioner = create_dynamic_positioner (surface);
-  else
-    positioner = create_simple_positioner (surface, parent);
+  positioner = create_dynamic_positioner (surface);
 
   switch (display->shell_variant)
     {
@@ -2404,7 +2327,7 @@ should_map_as_popup (GdkSurface *surface)
       break;
     }
 
-  if (impl->position_method == POSITION_METHOD_MOVE_TO_RECT)
+  if (impl->has_layout_data)
     return TRUE;
 
   return FALSE;
@@ -2489,7 +2412,7 @@ gdk_wayland_surface_map (GdkSurface *surface)
           /* If the position was not explicitly set, start the popup at the
            * position of the device that holds the grab.
            */
-          if (impl->position_method == POSITION_METHOD_NONE && grab_device)
+          if (!impl->has_layout_data && grab_device)
             {
               double px, py;
               gdk_surface_get_device_position (transient_for, grab_device,
@@ -2776,7 +2699,7 @@ gdk_wayland_surface_move_to_rect (GdkSurface         *surface,
   impl->pending_move_to_rect.rect_anchor_dx = rect_anchor_dx;
   impl->pending_move_to_rect.rect_anchor_dy = rect_anchor_dy;
 
-  impl->position_method = POSITION_METHOD_MOVE_TO_RECT;
+  impl->has_layout_data = TRUE;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]