1
0
Fork 0

wayland: Make gtk_shell handle our private window states

Instead of using the "allocated" state ranges of xdg_shell, lets just
use our own gtk_shell by adding a state enum and a configure event.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
This commit is contained in:
Jonas Ådahl 2016-06-28 14:57:27 +08:00
parent cfb3d10e1b
commit a8d86b4876
3 changed files with 50 additions and 16 deletions

View file

@ -40,6 +40,7 @@ typedef struct _MetaWaylandGtkSurface
struct wl_resource *resource;
MetaWaylandSurface *surface;
gboolean is_modal;
gulong configure_handler_id;
} MetaWaylandGtkSurface;
static void
@ -48,8 +49,12 @@ gtk_surface_destructor (struct wl_resource *resource)
MetaWaylandGtkSurface *gtk_surface = wl_resource_get_user_data (resource);
if (gtk_surface->surface)
g_object_steal_qdata (G_OBJECT (gtk_surface->surface),
quark_gtk_surface_data);
{
g_object_steal_qdata (G_OBJECT (gtk_surface->surface),
quark_gtk_surface_data);
g_signal_handler_disconnect (gtk_surface->surface,
gtk_surface->configure_handler_id);
}
g_free (gtk_surface);
}
@ -142,6 +147,34 @@ gtk_surface_surface_destroyed (MetaWaylandGtkSurface *gtk_surface)
gtk_surface->surface = NULL;
}
static void
fill_states (struct wl_array *states,
MetaWindow *window)
{
uint32_t *s;
if (window->tile_mode == META_TILE_LEFT ||
window->tile_mode == META_TILE_RIGHT)
{
s = wl_array_add (states, sizeof *s);
*s = GTK_SURFACE1_STATE_TILED;
}
}
static void
on_configure (MetaWaylandSurface *surface,
MetaWaylandGtkSurface *gtk_surface)
{
struct wl_array states;
wl_array_init (&states);
fill_states (&states, surface->window);
gtk_surface1_send_configure (gtk_surface->resource, &states);
wl_array_release (&states);
}
static void
gtk_shell_get_gtk_surface (struct wl_client *client,
struct wl_resource *resource,
@ -170,6 +203,11 @@ gtk_shell_get_gtk_surface (struct wl_client *client,
&meta_wayland_gtk_surface_interface,
gtk_surface, gtk_surface_destructor);
gtk_surface->configure_handler_id = g_signal_connect (surface,
"configure",
G_CALLBACK (on_configure),
gtk_surface);
g_object_set_qdata_full (G_OBJECT (surface),
quark_gtk_surface_data,
gtk_surface,

View file

@ -35,13 +35,6 @@
#include "wayland/meta-window-wayland.h"
#include "xdg-shell-unstable-v5-server-protocol.h"
/*
* Define GNOME additional states to xdg-shell
* The current reserved range for GNOME is 0x1000 - 0x1FFF
*/
#define XDG_SURFACE_STATE_GNOME_TILED 0x1000
struct _MetaWaylandXdgSurface
{
MetaWaylandSurfaceRoleShellSurface parent;
@ -406,13 +399,6 @@ fill_states (struct wl_array *states, MetaWindow *window)
s = wl_array_add (states, sizeof *s);
*s = XDG_SURFACE_STATE_ACTIVATED;
}
/* GNOME extension to xdg-shell states */
if (window->tile_mode == META_TILE_LEFT ||
window->tile_mode == META_TILE_RIGHT)
{
s = wl_array_add (states, sizeof *s);
*s = XDG_SURFACE_STATE_GNOME_TILED;
}
}
static void

View file

@ -46,6 +46,16 @@
<request name="present">
<arg name="time" type="uint"/>
</request>
<!-- Version 2 additions -->
<enum name="state">
<entry name="tiled" value="1"/>
</enum>
<event name="configure">
<arg name="states" type="array"/>
</event>
</interface>
</protocol>