Move edge-constraints to GdkToplevel

This commit is contained in:
Matthias Clasen 2020-03-09 11:38:08 -07:00
parent b7f51a362e
commit 81be6ff46b
11 changed files with 47 additions and 23 deletions

View File

@ -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,

View File

@ -2723,21 +2723,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)

View File

@ -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,

View File

@ -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);
}

View File

@ -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__ */

View File

@ -20,6 +20,7 @@ struct _GdkToplevelInterface
guint32 timestamp);
gboolean (* show_window_menu) (GdkToplevel *toplevel,
GdkEvent *event);
gboolean (* supports_edge_constraints) (GdkToplevel *toplevel);
};
typedef enum

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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 {

View File

@ -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)