wayland: consider edge constraints in surface configuration

Now that GTK windows have the ability to properly handle
per-edge tiling constraints, this patch extends GTK's
internal Wayland protocol to have a proper enum with the
relevant edge data.

Once this approach is validated, we can think of upstreaming
this work as an official Wayland protocol extension.

https://bugzilla.gnome.org/show_bug.cgi?id=783669
This commit is contained in:
Georges Basile Stavracas Neto 2017-08-17 00:35:52 -03:00
parent d73c49ecef
commit 3bae80dfc1
3 changed files with 74 additions and 4 deletions

View File

@ -82,6 +82,8 @@
#define MIN_SYSTEM_BELL_DELAY_MS 20
#define GTK_SHELL1_VERSION 2
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
G_DEFINE_TYPE (GdkWaylandDisplay, gdk_wayland_display, GDK_TYPE_DISPLAY)
@ -371,7 +373,7 @@ gdk_registry_handle_global (void *data,
display_wayland->gtk_shell =
wl_registry_bind(display_wayland->wl_registry, id,
&gtk_shell1_interface,
1);
MIN (version, GTK_SHELL1_VERSION));
_gdk_wayland_screen_set_has_gtk_shell (display_wayland->screen);
display_wayland->gtk_shell_version = version;
}

View File

@ -2961,6 +2961,57 @@ gtk_surface_configure (void *data,
case GTK_SURFACE1_STATE_TILED:
new_state |= GDK_WINDOW_STATE_TILED;
break;
/* Since v2 */
case GTK_SURFACE1_STATE_TILED_TOP:
new_state |= GDK_WINDOW_STATE_TOP_TILED;
break;
case GTK_SURFACE1_STATE_TILED_RIGHT:
new_state |= GDK_WINDOW_STATE_RIGHT_TILED;
break;
case GTK_SURFACE1_STATE_TILED_BOTTOM:
new_state |= GDK_WINDOW_STATE_BOTTOM_TILED;
break;
case GTK_SURFACE1_STATE_TILED_LEFT:
new_state |= GDK_WINDOW_STATE_LEFT_TILED;
break;
default:
/* Unknown state */
break;
}
}
impl->pending.state |= new_state;
}
static void
gtk_surface_configure_edges (void *data,
struct gtk_surface1 *gtk_surface,
struct wl_array *edge_constraints)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWindowState new_state = 0;
uint32_t *p;
wl_array_for_each (p, edge_constraints)
{
uint32_t constraint = *p;
switch (constraint)
{
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_TOP:
new_state |= GDK_WINDOW_STATE_TOP_RESIZABLE;
break;
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_RIGHT:
new_state |= GDK_WINDOW_STATE_TOP_TILED;
break;
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_BOTTOM:
new_state |= GDK_WINDOW_STATE_BOTTOM_RESIZABLE;
break;
case GTK_SURFACE1_EDGE_CONSTRAINT_RESIZABLE_LEFT:
new_state |= GDK_WINDOW_STATE_LEFT_RESIZABLE;
break;
default:
/* Unknown state */
break;
@ -2971,7 +3022,8 @@ gtk_surface_configure (void *data,
}
static const struct gtk_surface1_listener gtk_surface_listener = {
gtk_surface_configure
gtk_surface_configure,
gtk_surface_configure_edges
};
static void

View File

@ -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,27 @@
<enum name="state">
<entry name="tiled" value="1"/>
<entry name="tiled_top" value="2" since="2" />
<entry name="tiled_right" value="3" since="2" />
<entry name="tiled_bottom" value="4" since="2" />
<entry name="tiled_left" value="5" since="2" />
</enum>
<enum name="edge_constraint" since="2">
<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" since="2">
<arg name="constraints" type="array"/>
</event>
</interface>
</protocol>