wayland: Get tiled state from gtk_shell instead of xdg_shell

Use our the 'tiled' entry from our new 'state' enum sent via
xdg_surface.configure.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
This commit is contained in:
Jonas Ådahl 2016-06-28 15:01:22 +08:00
parent 80dd7566d5
commit e53d381430
2 changed files with 52 additions and 11 deletions

View File

@ -45,13 +45,6 @@ enum {
static guint signals[LAST_SIGNAL];
/*
* Define GNOME additional states to xdg-shell
* The current reserved range for GNOME is 0x1000 - 0x1FFF
*/
#define XDG_SURFACE_STATE_GNOME_TILED 0x1000
#define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
(GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \
GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
@ -182,6 +175,10 @@ struct _GdkWindowImplWayland
gint rect_anchor_dx;
gint rect_anchor_dy;
} pending_move_to_rect;
struct {
GdkWindowState state;
} pending;
};
struct _GdkWindowImplWaylandClass
@ -1252,16 +1249,15 @@ xdg_surface_configure (void *data,
break;
case XDG_SURFACE_STATE_RESIZING:
break;
/* GNOME additional states to xdg-shell */
case XDG_SURFACE_STATE_GNOME_TILED:
new_state |= GDK_WINDOW_STATE_TILED;
break;
default:
/* Unknown state */
break;
}
}
new_state |= impl->pending.state;
impl->pending.state = 0;
fixed_size =
new_state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_TILED);
@ -2203,6 +2199,38 @@ gdk_wayland_window_get_type_hint (GdkWindow *window)
return impl->hint;
}
static void
gtk_surface_configure (void *data,
struct gtk_surface1 *gtk_surface,
struct wl_array *states)
{
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, states)
{
uint32_t state = *p;
switch (state)
{
case GTK_SURFACE1_STATE_TILED:
new_state |= GDK_WINDOW_STATE_TILED;
break;
default:
/* Unknown state */
break;
}
}
impl->pending.state |= new_state;
}
static const struct gtk_surface1_listener gtk_surface_listener = {
gtk_surface_configure
};
static void
gdk_wayland_window_init_gtk_surface (GdkWindow *window)
{
@ -2220,6 +2248,9 @@ gdk_wayland_window_init_gtk_surface (GdkWindow *window)
impl->display_server.gtk_surface =
gtk_shell1_get_gtk_surface (display->gtk_shell,
impl->display_server.wl_surface);
gtk_surface1_add_listener (impl->display_server.gtk_surface,
&gtk_surface_listener,
window);
}
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>