[gtk/present-toplevel-2: 20/34] Move edge-constraints to GdkToplevel



commit 65d4848496758cca77fb4b702116be8e07686528
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Mar 9 11:38:08 2020 -0700

    Move edge-constraints to GdkToplevel

 gdk/gdk-private.h                |  2 --
 gdk/gdksurface.c                 | 15 ---------------
 gdk/gdksurfaceprivate.h          |  1 -
 gdk/gdktoplevel.c                | 25 +++++++++++++++++++++++++
 gdk/gdktoplevel.h                |  3 +++
 gdk/gdktoplevelprivate.h         |  1 +
 gdk/wayland/gdksurface-wayland.c |  8 +++++++-
 gdk/x11/gdkdisplay-x11.c         |  2 +-
 gdk/x11/gdkprivate-x11.h         |  1 +
 gdk/x11/gdksurface-x11.c         | 10 ++++++++--
 gtk/gtkwindow.c                  |  2 +-
 11 files changed, 47 insertions(+), 23 deletions(-)
---
diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h
index b5551b750c..5a8d2fe657 100644
--- a/gdk/gdk-private.h
+++ b/gdk/gdk-private.h
@@ -18,8 +18,6 @@ void            gdk_pre_parse                   (void);
 void            gdk_surface_freeze_toplevel_updates      (GdkSurface *surface);
 void            gdk_surface_thaw_toplevel_updates        (GdkSurface *surface);
 
-gboolean        gdk_surface_supports_edge_constraints    (GdkSurface *surface);
-
 guint32         gdk_display_get_last_seen_time  (GdkDisplay *display);
 
 void gdk_display_set_double_click_time     (GdkDisplay   *display,
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index c383c8ec18..e213ce48bc 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2920,21 +2920,6 @@ gdk_surface_set_shadow_width (GdkSurface *surface,
     class->set_shadow_width (surface, left, right, top, bottom);
 }
 
-gboolean
-gdk_surface_supports_edge_constraints (GdkSurface *surface)
-{
-  GdkSurfaceClass *class;
-
-  g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
-  g_return_val_if_fail (!GDK_SURFACE_DESTROYED (surface), FALSE);
-
-  class = GDK_SURFACE_GET_CLASS (surface);
-  if (class->supports_edge_constraints)
-    return class->supports_edge_constraints (surface);
-  else
-    return FALSE;
-}
-
 void
 gdk_surface_set_state (GdkSurface      *surface,
                        GdkSurfaceState  new_state)
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index 714cc9f02f..23bd733e5d 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -186,7 +186,6 @@ struct _GdkSurfaceClass
                                            gboolean        attached,
                                            GdkGLContext   *share,
                                            GError        **error);
-  gboolean     (* supports_edge_constraints)(GdkSurface    *surface);
 };
 
 void gdk_surface_set_state (GdkSurface      *surface,
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
index c2c64f368e..007f80845e 100644
--- a/gdk/gdktoplevel.c
+++ b/gdk/gdktoplevel.c
@@ -71,6 +71,12 @@ gdk_toplevel_default_show_window_menu (GdkToplevel *toplevel,
   return FALSE;
 }
 
+static gboolean
+gdk_toplevel_default_supports_edge_constraints (GdkToplevel *toplevel)
+{
+  return FALSE;
+}
+
 static void
 gdk_toplevel_default_init (GdkToplevelInterface *iface)
 {
@@ -79,6 +85,7 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
   iface->lower = gdk_toplevel_default_lower;
   iface->focus = gdk_toplevel_default_focus;
   iface->show_window_menu = gdk_toplevel_default_show_window_menu;
+  iface->supports_edge_constraints = gdk_toplevel_default_supports_edge_constraints;
 
   g_object_interface_install_property (iface,
       g_param_spec_flags ("state",
@@ -516,3 +523,21 @@ gdk_toplevel_set_deletable (GdkToplevel *toplevel,
 
   g_object_set (toplevel, "deletable", deletable, NULL);
 }
+
+/**
+ * gdk_toplevel_supports_edge_constraints:
+ * @toplevel: a #GdkToplevel
+ *
+ * Returns whether the desktop environment supports
+ * tiled window states.
+ *
+ * Returns: %TRUE if the desktop environment supports
+ *     tiled window states
+ */
+gboolean
+gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
+{
+  g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
+
+  return GDK_TOPLEVEL_GET_IFACE (toplevel)->supports_edge_constraints (toplevel);
+}
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
index e513ad9adf..0827c5bf38 100644
--- a/gdk/gdktoplevel.h
+++ b/gdk/gdktoplevel.h
@@ -103,6 +103,9 @@ void          gdk_toplevel_set_decorated         (GdkToplevel      *toplevel,
 GDK_AVAILABLE_IN_ALL
 void          gdk_toplevel_set_deletable         (GdkToplevel      *toplevel,
                                                   gboolean          deletable);
+GDK_AVAILABLE_IN_ALL
+gboolean      gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel);
+
 G_END_DECLS
 
 #endif /* __GDK_TOPLEVEL_H__ */
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
index bd5c9672f3..ac1aae2725 100644
--- a/gdk/gdktoplevelprivate.h
+++ b/gdk/gdktoplevelprivate.h
@@ -20,6 +20,7 @@ struct _GdkToplevelInterface
                                          guint32            timestamp);
   gboolean      (* show_window_menu)    (GdkToplevel       *toplevel,
                                          GdkEvent          *event);
+  gboolean      (* supports_edge_constraints) (GdkToplevel *toplevel);
 };
 
 typedef enum
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 83291f69e4..0c795e8d82 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -3711,7 +3711,6 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
   impl_class->set_opaque_region = gdk_wayland_surface_set_opaque_region;
   impl_class->set_shadow_width = gdk_wayland_surface_set_shadow_width;
   impl_class->create_gl_context = gdk_wayland_surface_create_gl_context;
-  impl_class->supports_edge_constraints = gdk_wayland_surface_supports_edge_constraints;
 
   signals[COMMITTED] = g_signal_new (g_intern_static_string ("committed"),
                                      G_TYPE_FROM_CLASS (object_class),
@@ -4551,6 +4550,12 @@ gdk_wayland_toplevel_show_window_menu (GdkToplevel *toplevel,
   return gdk_wayland_surface_show_window_menu (GDK_SURFACE (toplevel), event);
 }
 
+static gboolean
+gdk_wayland_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
+{
+  return gdk_wayland_surface_supports_edge_constraints (GDK_SURFACE (toplevel));
+}
+
 static void
 gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
 {
@@ -4559,6 +4564,7 @@ gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->lower = gdk_wayland_toplevel_lower;
   iface->focus = gdk_wayland_toplevel_focus;
   iface->show_window_menu = gdk_wayland_toplevel_show_window_menu;
+  iface->supports_edge_constraints = gdk_wayland_toplevel_supports_edge_constraints;
 }
 
 typedef struct
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 24e1636bb3..7d0786eb48 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -241,7 +241,7 @@ do_edge_constraint_state_check (GdkSurface      *surface,
    * GDK_SURFACE_STATE_TILED to be set if any edge is tiled, and cleared
    * if no edge is tiled.
    */
-  if (!gdk_surface_supports_edge_constraints (surface))
+  if (!gdk_x11_surface_supports_edge_constraints (surface))
     {
       /* FIXME: we rely on implementation details of mutter here:
        * mutter only tiles horizontally, and sets maxvert when it does
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 71f5d2e75e..70c12159d5 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -235,6 +235,7 @@ void gdk_x11_surface_show (GdkSurface *surface,
 void gdk_x11_surface_raise (GdkSurface *surface);
 void gdk_x11_surface_set_opacity (GdkSurface *surface,
                                   double      opacity);
+gboolean gdk_x11_surface_supports_edge_constraints (GdkSurface *surface);
 
 GdkGrabStatus _gdk_x11_convert_grab_status (gint status);
 
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 96e88ad3bf..222bc550e8 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -184,7 +184,7 @@ gdk_x11_surface_get_unscaled_size (GdkSurface *surface,
     *unscaled_height = impl->unscaled_height;
 }
 
-static gboolean
+gboolean
 gdk_x11_surface_supports_edge_constraints (GdkSurface *surface)
 {
   return gdk_x11_screen_supports_net_wm_hint (GDK_SURFACE_SCREEN (surface),
@@ -4670,7 +4670,6 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass)
   impl_class->set_shadow_width = gdk_x11_surface_set_shadow_width;
   impl_class->create_gl_context = gdk_x11_surface_create_gl_context;
   impl_class->get_unscaled_size = gdk_x11_surface_get_unscaled_size;
-  impl_class->supports_edge_constraints = gdk_x11_surface_supports_edge_constraints;
 }
 
 #define LAST_PROP 1
@@ -5082,6 +5081,12 @@ gdk_x11_toplevel_show_window_menu (GdkToplevel *toplevel,
   return gdk_x11_surface_show_window_menu (GDK_SURFACE (toplevel), event);
 }
 
+static gboolean
+gdk_x11_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
+{
+  return gdk_x11_surface_supports_edge_constraints (GDK_SURFACE (toplevel));
+}
+
 static void
 gdk_x11_toplevel_iface_init (GdkToplevelInterface *iface)
 {
@@ -5090,6 +5095,7 @@ gdk_x11_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->lower = gdk_x11_toplevel_lower;
   iface->focus = gdk_x11_toplevel_focus;
   iface->show_window_menu = gdk_x11_toplevel_show_window_menu;
+  iface->supports_edge_constraints = gdk_x11_toplevel_supports_edge_constraints;
 }
 
 typedef struct {
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f59b9429da..8442fd53a9 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1619,7 +1619,7 @@ edge_under_coordinates (GtkWindow     *window,
       priv->maximized)
     return FALSE;
 
-  supports_edge_constraints = gdk_surface_supports_edge_constraints (priv->surface);
+  supports_edge_constraints = gdk_toplevel_supports_edge_constraints (GDK_TOPLEVEL (priv->surface));
   constraints = constraints_for_edge (edge);
 
   if (!supports_edge_constraints && priv->tiled)


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