[mutter/wip/gbsneto/edge-constraints: 1/3] wayland: Send edge constraints
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gbsneto/edge-constraints: 1/3] wayland: Send edge constraints
- Date: Sun, 20 Aug 2017 14:01:32 +0000 (UTC)
commit e4bd3863f10f325f2e773437ea0b55f26b60479a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 17 00:49:36 2017 -0300
wayland: Send edge constraints
Following up the previous patch, this patch makes the
Wayland backend send the edge constraints through a
custom protocol extension internal to GTK.
As it mature, we can think of upstreaming the protocol
to Wayland itself.
https://bugzilla.gnome.org/show_bug.cgi?id=751857
src/wayland/meta-wayland-gtk-shell.c | 82 ++++++++++++++++++++++++++++++++++
src/wayland/protocol/gtk-shell.xml | 19 +++++++-
2 files changed, 99 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c
index d6e249f..ec79886 100644
--- a/src/wayland/meta-wayland-gtk-shell.c
+++ b/src/wayland/meta-wayland-gtk-shell.c
@@ -40,6 +40,7 @@ typedef struct _MetaWaylandGtkSurface
struct wl_resource *resource;
MetaWaylandSurface *surface;
gboolean is_modal;
+ gulong configure_edges_handler_id;
gulong configure_handler_id;
} MetaWaylandGtkSurface;
@@ -54,6 +55,8 @@ gtk_surface_destructor (struct wl_resource *resource)
quark_gtk_surface_data);
g_signal_handler_disconnect (gtk_surface->surface,
gtk_surface->configure_handler_id);
+ g_signal_handler_disconnect (gtk_surface->surface,
+ gtk_surface->configure_edges_handler_id);
}
g_free (gtk_surface);
@@ -148,6 +151,56 @@ gtk_surface_surface_destroyed (MetaWaylandGtkSurface *gtk_surface)
}
static void
+fill_edge_states (struct wl_array *states,
+ MetaWindow *window)
+{
+ uint32_t *s;
+
+ /* Top */
+ if (window->edge_constraints[0] != META_EDGE_CONSTRAINT_MONITOR)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_TOP;
+ }
+
+ /* Right */
+ if (window->edge_constraints[1] != META_EDGE_CONSTRAINT_MONITOR)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_RIGHT;
+ }
+
+ /* Bottom */
+ if (window->edge_constraints[2] != META_EDGE_CONSTRAINT_MONITOR)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_BOTTOM;
+ }
+
+ /* Left */
+ if (window->edge_constraints[3] != META_EDGE_CONSTRAINT_MONITOR)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_LEFT;
+ }
+}
+
+static void
+on_configure_edges (MetaWaylandSurface *surface,
+ MetaWaylandGtkSurface *gtk_surface)
+{
+ struct wl_array states;
+
+ wl_array_init (&states);
+ fill_edge_states (&states, surface->window);
+
+ gtk_surface1_send_configure_edges (gtk_surface->resource, &states);
+
+ wl_array_release (&states);
+}
+
+
+static void
fill_states (struct wl_array *states,
MetaWindow *window)
{
@@ -159,6 +212,30 @@ fill_states (struct wl_array *states,
s = wl_array_add (states, sizeof *s);
*s = GTK_SURFACE1_STATE_TILED;
}
+
+ if (window->edge_constraints[0] != META_EDGE_CONSTRAINT_NONE)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_STATE_TILED_TOP;
+ }
+
+ if (window->edge_constraints[1] != META_EDGE_CONSTRAINT_NONE)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_STATE_TILED_RIGHT;
+ }
+
+ if (window->edge_constraints[2] != META_EDGE_CONSTRAINT_NONE)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_STATE_TILED_BOTTOM;
+ }
+
+ if (window->edge_constraints[3] != META_EDGE_CONSTRAINT_NONE)
+ {
+ s = wl_array_add (states, sizeof *s);
+ *s = GTK_SURFACE1_STATE_TILED_LEFT;
+ }
}
static void
@@ -208,6 +285,11 @@ gtk_shell_get_gtk_surface (struct wl_client *client,
G_CALLBACK (on_configure),
gtk_surface);
+ gtk_surface->configure_edges_handler_id = g_signal_connect (surface,
+ "configure_edges",
+ G_CALLBACK (on_configure_edges),
+ gtk_surface);
+
g_object_set_qdata_full (G_OBJECT (surface),
quark_gtk_surface_data,
gtk_surface,
diff --git a/src/wayland/protocol/gtk-shell.xml b/src/wayland/protocol/gtk-shell.xml
index 5cfdd42..0dd44d9 100644
--- a/src/wayland/protocol/gtk-shell.xml
+++ b/src/wayland/protocol/gtk-shell.xml
@@ -1,6 +1,6 @@
<protocol name="gtk">
- <interface name="gtk_shell1" version="1">
+ <interface name="gtk_shell1" version="2">
<description summary="gtk specific extensions">
gtk_shell is a protocol extension providing additional features for
clients implementing it.
@@ -30,7 +30,7 @@
</request>
</interface>
- <interface name="gtk_surface1" version="1">
+ <interface name="gtk_surface1" version="2">
<request name="set_dbus_properties">
<arg name="application_id" type="string" allow-null="true"/>
<arg name="app_menu_path" type="string" allow-null="true"/>
@@ -51,11 +51,26 @@
<enum name="state">
<entry name="tiled" value="1"/>
+ <entry name="tiled_top" value="2"/>
+ <entry name="tiled_right" value="3"/>
+ <entry name="tiled_bottom" value="4"/>
+ <entry name="tiled_left" value="5"/>
+ </enum>
+
+ <enum name="edge_constraint">
+ <entry name="resizable_top" value="1"/>
+ <entry name="resizable_right" value="2"/>
+ <entry name="resizable_bottom" value="3"/>
+ <entry name="resizable_left" value="4"/>
</enum>
<event name="configure">
<arg name="states" type="array"/>
</event>
+
+ <event name="configure_edges">
+ <arg name="constraints" type="array"/>
+ </event>
</interface>
</protocol>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]