wayland: Replace wl_shell_surface with xdg_shell

This commit is contained in:
Jasper St. Pierre 2013-11-11 18:02:19 -05:00
parent a41305135c
commit 9127087e1c
8 changed files with 663 additions and 312 deletions

View File

@ -20,6 +20,8 @@ noinst_LTLIBRARIES = \
libgdk-wayland.la
BUILT_SOURCES = \
xdg-shell-client-protocol.h \
xdg-shell-protocol.c \
gtk-shell-client-protocol.h \
gtk-shell-protocol.c
@ -57,6 +59,8 @@ libgdkwaylandinclude_HEADERS = \
%-client-protocol.h : $(srcdir)/protocol/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
EXTRA_DIST += protocol/gtk-shell.xml
EXTRA_DIST += \
protocol/xdg-shell.xml \
protocol/gtk-shell.xml
-include $(top_srcdir)/git.mk

View File

@ -911,8 +911,6 @@ keyboard_handle_enter (void *data,
device, device->keyboard_focus));
_gdk_wayland_display_deliver_event (device->display, event);
_gdk_wayland_window_add_focus (device->keyboard_focus);
}
static void
@ -935,7 +933,6 @@ keyboard_handle_leave (void *data,
_gdk_wayland_display_update_serial (wayland_display, serial);
_gdk_wayland_window_remove_focus (device->keyboard_focus);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (device->keyboard_focus);
event->focus_change.send_event = FALSE;

View File

@ -164,9 +164,9 @@ gdk_registry_handle_global(void *data, struct wl_registry *registry, uint32_t id
/* SHM interface is prerequisite */
_gdk_wayland_display_load_cursor_theme(display_wayland);
} else if (strcmp(interface, "wl_shell") == 0) {
display_wayland->shell =
wl_registry_bind(display_wayland->wl_registry, id, &wl_shell_interface, 1);
} else if (strcmp(interface, "xdg_shell") == 0) {
display_wayland->xdg_shell =
wl_registry_bind(display_wayland->wl_registry, id, &xdg_shell_interface, 1);
} else if (strcmp(interface, "gtk_shell") == 0) {
display_wayland->gtk_shell =
wl_registry_bind(display_wayland->wl_registry, id, &gtk_shell_interface, 1);
@ -728,21 +728,21 @@ gdk_wayland_display_get_wl_compositor (GdkDisplay *display)
}
/**
* gdk_wayland_display_get_wl_shell
* gdk_wayland_display_get_xdg_shell
* @display: (type GdkWaylandDisplay): a #GdkDisplay
*
* Returns the Wayland global singleton shell of a #GdkDisplay
*
* Returns: (transfer none): a Wayland wl_shell
* Returns: (transfer none): a Wayland xdg_shell
*
* Since: 3.8
*/
struct wl_shell *
gdk_wayland_display_get_wl_shell (GdkDisplay *display)
struct xdg_shell *
gdk_wayland_display_get_xdg_shell (GdkDisplay *display)
{
GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY(display);
g_return_val_if_fail (GDK_IS_WAYLAND_DISPLAY(display), NULL);
return wayland_display->shell;
return wayland_display->xdg_shell;
}

View File

@ -27,6 +27,7 @@
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <gdk/wayland/gtk-shell-client-protocol.h>
#include <gdk/wayland/xdg-shell-client-protocol.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
@ -58,7 +59,7 @@ struct _GdkWaylandDisplay
struct wl_registry *wl_registry;
struct wl_compositor *compositor;
struct wl_shm *shm;
struct wl_shell *shell;
struct xdg_shell *xdg_shell;
struct gtk_shell *gtk_shell;
struct wl_input_device *input_device;
struct wl_data_device_manager *data_device_manager;

View File

@ -42,9 +42,6 @@
#define GDK_WINDOW_IS_WAYLAND(win) (GDK_IS_WINDOW_IMPL_WAYLAND (((GdkWindow *)win)->impl))
void _gdk_wayland_window_add_focus (GdkWindow *window);
void _gdk_wayland_window_remove_focus (GdkWindow *window);
GdkKeymap *_gdk_wayland_keymap_new (void);
void _gdk_wayland_keymap_update_from_fd (GdkKeymap *keymap,
uint32_t format,

View File

@ -47,8 +47,6 @@ GType gdk_wayland_window_get_type (void);
GDK_AVAILABLE_IN_ALL
struct wl_surface *gdk_wayland_window_get_wl_surface (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
struct wl_shell_surface *gdk_wayland_window_get_wl_shell_surface (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
void gdk_wayland_window_set_use_custom_surface (GdkWindow *window);

View File

@ -101,7 +101,10 @@ struct _GdkWindowImplWayland
GSList *outputs;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct xdg_surface *xdg_surface;
struct xdg_popup *xdg_popup;
struct gtk_surface *gtk_surface;
unsigned int mapped : 1;
unsigned int fullscreen : 1;
@ -125,8 +128,6 @@ struct _GdkWindowImplWayland
uint32_t resize_edges;
int focus_count;
/* Time of most recent user interaction. */
gulong user_time;
@ -137,11 +138,6 @@ struct _GdkWindowImplWayland
GdkDevice *grab_device;
struct wl_seat *grab_input_seat;
struct
{
int width, height;
} saved_fullscreen, saved_maximized;
gint64 pending_frame_counter;
guint32 scale;
};
@ -164,26 +160,6 @@ _gdk_window_impl_wayland_init (GdkWindowImplWayland *impl)
impl->scale = 1;
}
void
_gdk_wayland_window_add_focus (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->focus_count++;
if (impl->focus_count == 1)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
}
void
_gdk_wayland_window_remove_focus (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->focus_count--;
if (impl->focus_count == 0)
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
}
/*
* gdk_wayland_window_update_size:
* @drawable: a #GdkDrawableImplWayland.
@ -594,12 +570,12 @@ gdk_wayland_window_attach_image (GdkWindow *window)
data = cairo_surface_get_user_data (impl->cairo_surface,
&gdk_wayland_cairo_key);
if (impl->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT)
if (impl->resize_edges & XDG_SURFACE_RESIZE_EDGE_LEFT)
dx = server_width - data->width;
else
dx = 0;
if (impl->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP)
if (impl->resize_edges & XDG_SURFACE_RESIZE_EDGE_TOP)
dy = server_height - data->height;
else
dy = 0;
@ -859,6 +835,213 @@ gdk_wayland_window_set_user_time (GdkWindow *window,
{
}
static void
gdk_wayland_window_sync_transient_for (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWindowImplWayland *impl_parent = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for);
if (!impl->xdg_surface)
return;
/* XXX: Is this correct? */
if (!impl_parent->surface)
return;
xdg_surface_set_transient_for (impl->xdg_surface, impl_parent->surface);
}
static void
surface_enter (void *data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->outputs = g_slist_prepend (impl->outputs, output);
window_update_scale (window);
}
static void
surface_leave (void *data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->outputs = g_slist_remove (impl->outputs, output);
window_update_scale (window);
}
static const struct wl_surface_listener surface_listener = {
surface_enter,
surface_leave
};
static void
gdk_wayland_window_create_surface (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
impl->surface = wl_compositor_create_surface (display_wayland->compositor);
wl_surface_set_user_data (impl->surface, window);
wl_surface_add_listener (impl->surface,
&surface_listener, window);
if (display_wayland->gtk_shell)
impl->gtk_surface = gtk_shell_get_gtk_surface (display_wayland->gtk_shell,
impl->surface);
}
static void
xdg_surface_ping (void *data,
struct xdg_surface *xdg_surface,
uint32_t serial)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWaylandDisplay *wayland_display =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
_gdk_wayland_display_update_serial (wayland_display, serial);
xdg_surface_pong (xdg_surface, serial);
}
static void
xdg_surface_configure (void *data,
struct xdg_surface *xdg_surface,
uint32_t edges,
int32_t width,
int32_t height,
uint32_t maximized,
uint32_t fullscreen)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
gdk_window_constrain_size (&impl->geometry_hints,
impl->geometry_mask,
width,
height,
&width,
&height);
gdk_wayland_window_configure (window, width, height, edges);
if (maximized)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
else
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
if (fullscreen)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
else
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
}
static void
xdg_surface_focused_set (void *data,
struct xdg_surface *xdg_surface)
{
GdkWindow *window = GDK_WINDOW (data);
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
}
static void
xdg_surface_focused_unset (void *data,
struct xdg_surface *xdg_surface)
{
GdkWindow *window = GDK_WINDOW (data);
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
}
static const struct xdg_surface_listener xdg_surface_listener = {
xdg_surface_ping,
xdg_surface_configure,
xdg_surface_focused_set,
xdg_surface_focused_unset,
};
static void
gdk_wayland_window_create_xdg_surface (GdkWindow *window)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->xdg_surface = xdg_shell_get_xdg_surface (display_wayland->xdg_shell, impl->surface);
xdg_surface_add_listener (impl->xdg_surface, &xdg_surface_listener, window);
}
static void
xdg_popup_ping (void *data,
struct xdg_popup *xdg_popup,
uint32_t serial)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWaylandDisplay *wayland_display =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
_gdk_wayland_display_update_serial (wayland_display, serial);
xdg_popup_pong (xdg_popup, serial);
}
static void
xdg_popup_done (void *data,
struct xdg_popup *xdg_popup,
uint32_t serial)
{
GdkWindow *window = GDK_WINDOW (data);
/* When the popup is complete hide the window - this really relies on the
* fix in https://bugzilla.gnome.org/show_bug.cgi?id=670881 to work
* effectively.
*/
gdk_window_hide (window);
}
static const struct xdg_popup_listener xdg_popup_listener = {
xdg_popup_ping,
xdg_popup_done,
};
static void
gdk_wayland_window_create_xdg_popup (GdkWindow *window,
GdkWindowImplWayland *parent,
struct wl_seat *seat,
uint32_t flags)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandDeviceData *device;
if (!impl->surface)
return;
if (!parent->surface)
return;
device = wl_seat_get_user_data (seat);
impl->xdg_popup = xdg_shell_get_xdg_popup (display_wayland->xdg_shell,
impl->surface,
parent->surface,
seat,
_gdk_wayland_device_get_button_press_serial (device),
window->x,
window->y,
flags);
xdg_popup_add_listener (impl->xdg_popup, &xdg_popup_listener, window);
}
static void
gdk_wayland_window_map (GdkWindow *window)
{
@ -890,7 +1073,6 @@ gdk_wayland_window_map (GdkWindow *window)
{
struct wl_seat *grab_input_seat = NULL;
GdkWindowImplWayland *tmp_impl;
GdkWaylandDeviceData *device;
parent = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl);
@ -916,135 +1098,18 @@ gdk_wayland_window_map (GdkWindow *window)
impl->hint == GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU ||
impl->hint == GDK_WINDOW_TYPE_HINT_COMBO))
{
device = wl_seat_get_user_data (grab_input_seat);
wl_shell_surface_set_popup (impl->shell_surface,
grab_input_seat,
_gdk_wayland_device_get_button_press_serial (device),
parent->surface,
window->x, window->y, 0);
}
else
{
guint32 flags = 0;
if (impl->hint == GDK_WINDOW_TYPE_HINT_TOOLTIP)
flags = WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
wl_shell_surface_set_transient (impl->shell_surface, parent->surface,
window->x, window->y, flags);
gdk_wayland_window_create_xdg_popup (window, parent, grab_input_seat, 0);
goto mapped;
}
}
else
{
wl_shell_surface_set_toplevel (impl->shell_surface);
}
gdk_wayland_window_create_xdg_surface (window);
mapped:
impl->mapped = TRUE;
}
}
static void
surface_enter (void *data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->outputs = g_slist_prepend (impl->outputs, output);
window_update_scale (window);
}
static void
surface_leave (void *data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->outputs = g_slist_remove (impl->outputs, output);
window_update_scale (window);
}
static void
shell_surface_handle_configure (void *data,
struct wl_shell_surface *shell_surface,
uint32_t edges,
int32_t width,
int32_t height)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
gdk_window_constrain_size (&impl->geometry_hints,
impl->geometry_mask,
width,
height,
&width,
&height);
gdk_wayland_window_configure (window, width, height, edges);
}
static void
shell_surface_popup_done (void *data,
struct wl_shell_surface *shell_surface)
{
GdkWindow *window = GDK_WINDOW (data);
/* When the popup is complete hide the window - this really relies on the
* fix in https://bugzilla.gnome.org/show_bug.cgi?id=670881 to work
* effectively.
*/
gdk_window_hide (window);
}
static void
shell_surface_ping (void *data,
struct wl_shell_surface *shell_surface,
uint32_t serial)
{
GdkWindow *window = GDK_WINDOW (data);
GdkWaylandDisplay *wayland_display =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
_gdk_wayland_display_update_serial (wayland_display, serial);
wl_shell_surface_pong(shell_surface, serial);
}
static const struct wl_surface_listener surface_listener = {
surface_enter,
surface_leave
};
static const struct wl_shell_surface_listener shell_surface_listener = {
shell_surface_ping,
shell_surface_handle_configure,
shell_surface_popup_done
};
static void
gdk_wayland_window_create_surface (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
impl->surface = wl_compositor_create_surface (display_wayland->compositor);
wl_surface_set_user_data (impl->surface, window);
wl_surface_add_listener (impl->surface,
&surface_listener, window);
if (display_wayland->gtk_shell)
impl->gtk_surface = gtk_shell_get_gtk_surface (display_wayland->gtk_shell,
impl->surface);
}
static void
gdk_wayland_window_show (GdkWindow *window,
gboolean already_mapped)
@ -1065,22 +1130,12 @@ gdk_wayland_window_show (GdkWindow *window,
if (!impl->surface)
gdk_wayland_window_create_surface (window);
if (!impl->shell_surface &&
!impl->use_custom_surface &&
display_wayland->shell)
{
impl->shell_surface = wl_shell_get_shell_surface (display_wayland->shell,
impl->surface);
wl_shell_surface_add_listener (impl->shell_surface,
&shell_surface_listener, window);
}
if (impl->shell_surface)
if (impl->xdg_surface)
{
if (impl->title)
wl_shell_surface_set_title (impl->shell_surface, impl->title);
xdg_surface_set_title (impl->xdg_surface, impl->title);
wl_shell_surface_set_class (impl->shell_surface, gdk_get_program_class ());
xdg_surface_set_app_id (impl->xdg_surface, gdk_get_program_class ());
}
gdk_window_set_type_hint (window, impl->hint);
@ -1119,10 +1174,15 @@ gdk_wayland_window_hide_surface (GdkWindow *window,
impl->outputs = NULL;
}
if (impl->shell_surface)
if (impl->xdg_surface)
{
wl_shell_surface_destroy (impl->shell_surface);
impl->shell_surface = NULL;
xdg_surface_destroy (impl->xdg_surface);
impl->xdg_surface = NULL;
}
else if (impl->xdg_popup)
{
xdg_popup_destroy (impl->xdg_popup);
impl->xdg_popup = NULL;
}
cairo_surface_destroy (impl->server_surface);
@ -1172,13 +1232,11 @@ gdk_window_wayland_get_events (GdkWindow *window)
static void
gdk_window_wayland_raise (GdkWindow *window)
{
/* FIXME: wl_shell_raise() */
}
static void
gdk_window_wayland_lower (GdkWindow *window)
{
/* FIXME: wl_shell_lower() */
}
static void
@ -1421,7 +1479,6 @@ static void
gdk_wayland_window_focus (GdkWindow *window,
guint32 timestamp)
{
/* FIXME: wl_shell_focus() */
}
static void
@ -1436,31 +1493,6 @@ gdk_wayland_window_set_type_hint (GdkWindow *window,
return;
impl->hint = hint;
switch (hint)
{
case GDK_WINDOW_TYPE_HINT_MENU:
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
case GDK_WINDOW_TYPE_HINT_UTILITY:
case GDK_WINDOW_TYPE_HINT_DOCK:
case GDK_WINDOW_TYPE_HINT_DESKTOP:
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
case GDK_WINDOW_TYPE_HINT_COMBO:
case GDK_WINDOW_TYPE_HINT_DND:
break;
default:
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
/* Fall thru */
case GDK_WINDOW_TYPE_HINT_DIALOG:
case GDK_WINDOW_TYPE_HINT_NORMAL:
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
if (impl->shell_surface)
wl_shell_surface_set_toplevel (impl->shell_surface);
break;
}
}
static GdkWindowTypeHint
@ -1558,6 +1590,8 @@ gdk_wayland_window_set_transient_for (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
impl->transient_for = parent;
gdk_wayland_window_sync_transient_for (window);
}
static void
@ -1661,57 +1695,29 @@ gdk_wayland_window_unstick (GdkWindow *window)
static void
gdk_wayland_window_maximize (GdkWindow *window)
{
GdkWindowImplWayland *impl;
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
if (GDK_WINDOW_DESTROYED (window))
return;
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (!impl->xdg_surface)
return;
if (GDK_WINDOW_IS_MAPPED (window))
{
if (impl->surface)
{
impl->saved_maximized.width = gdk_window_get_width (window);
impl->saved_maximized.height = gdk_window_get_height (window);
if (impl->shell_surface)
wl_shell_surface_set_maximized (impl->shell_surface, NULL);
}
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_MAXIMIZED);
}
xdg_surface_set_maximized (impl->xdg_surface);
}
static void
gdk_wayland_window_unmaximize (GdkWindow *window)
{
GdkWindowImplWayland *impl;
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
if (GDK_WINDOW_DESTROYED (window))
return;
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (!impl->xdg_surface)
return;
if (GDK_WINDOW_IS_MAPPED (window))
{
if (impl->surface)
{
if (impl->shell_surface)
wl_shell_surface_set_toplevel (impl->shell_surface);
}
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
gdk_wayland_window_configure (window,
impl->saved_maximized.width,
impl->saved_maximized.height,
0);
}
xdg_surface_unset_maximized (impl->xdg_surface);
}
static void
@ -1725,19 +1731,10 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
if (impl->fullscreen)
return;
if (!impl->shell_surface)
if (!impl->xdg_surface)
return;
impl->saved_fullscreen.width = gdk_window_get_width (window);
impl->saved_fullscreen.height = gdk_window_get_height (window);
wl_shell_surface_set_fullscreen (impl->shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0,
NULL);
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
xdg_surface_set_fullscreen (impl->xdg_surface);
impl->fullscreen = TRUE;
}
@ -1752,16 +1749,10 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
if (!impl->fullscreen)
return;
if (!impl->shell_surface)
if (!impl->xdg_surface)
return;
wl_shell_surface_set_toplevel (impl->shell_surface);
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
gdk_wayland_window_configure (window,
impl->saved_fullscreen.width,
impl->saved_fullscreen.height,
0);
xdg_surface_unset_fullscreen (impl->xdg_surface);
impl->fullscreen = FALSE;
}
@ -1844,35 +1835,35 @@ gdk_wayland_window_begin_resize_drag (GdkWindow *window,
switch (edge)
{
case GDK_WINDOW_EDGE_NORTH_WEST:
grab_type = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
grab_type = XDG_SURFACE_RESIZE_EDGE_TOP_LEFT;
break;
case GDK_WINDOW_EDGE_NORTH:
grab_type = WL_SHELL_SURFACE_RESIZE_TOP;
grab_type = XDG_SURFACE_RESIZE_EDGE_TOP;
break;
case GDK_WINDOW_EDGE_NORTH_EAST:
grab_type = WL_SHELL_SURFACE_RESIZE_RIGHT;
grab_type = XDG_SURFACE_RESIZE_EDGE_RIGHT;
break;
case GDK_WINDOW_EDGE_WEST:
grab_type = WL_SHELL_SURFACE_RESIZE_LEFT;
grab_type = XDG_SURFACE_RESIZE_EDGE_LEFT;
break;
case GDK_WINDOW_EDGE_EAST:
grab_type = WL_SHELL_SURFACE_RESIZE_RIGHT;
grab_type = XDG_SURFACE_RESIZE_EDGE_RIGHT;
break;
case GDK_WINDOW_EDGE_SOUTH_WEST:
grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
grab_type = XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT;
break;
case GDK_WINDOW_EDGE_SOUTH:
grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM;
grab_type = XDG_SURFACE_RESIZE_EDGE_BOTTOM;
break;
case GDK_WINDOW_EDGE_SOUTH_EAST:
grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
grab_type = XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT;
break;
default:
@ -1882,13 +1873,13 @@ gdk_wayland_window_begin_resize_drag (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (!impl->shell_surface)
if (!impl->xdg_surface)
return;
wl_shell_surface_resize (impl->shell_surface,
gdk_wayland_device_get_wl_seat (device),
_gdk_wayland_display_get_serial (wayland_display),
grab_type);
xdg_surface_resize (impl->xdg_surface,
gdk_wayland_device_get_wl_seat (device),
_gdk_wayland_display_get_serial (wayland_display),
grab_type);
/* This is needed since Wayland will absorb all the pointer events after the
* above function - FIXME: Is this always safe..?
@ -1914,12 +1905,12 @@ gdk_wayland_window_begin_move_drag (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (!impl->shell_surface)
if (!impl->xdg_surface)
return;
wl_shell_surface_move (impl->shell_surface,
gdk_wayland_device_get_wl_seat (device),
_gdk_wayland_display_get_serial (wayland_display));
xdg_surface_move (impl->xdg_surface,
gdk_wayland_device_get_wl_seat (device),
_gdk_wayland_display_get_serial (wayland_display));
/* This is needed since Wayland will absorb all the pointer events after the
* above function - FIXME: Is this always safe..?
@ -2224,28 +2215,6 @@ gdk_wayland_window_get_wl_surface (GdkWindow *window)
return impl->surface;
}
/**
* gdk_wayland_window_get_wl_shell_surface
* @window: (type GdkWaylandWindow): a #GdkWindow
*
* Returns the Wayland shell surface of a #GdkWindow
*
* Returns: (transfer none): a Wayland wl_shell_surface
*
* Since: 3.8
*/
struct wl_shell_surface *
gdk_wayland_window_get_wl_shell_surface (GdkWindow *window)
{
GdkWindowImplWayland *impl;
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
return impl->shell_surface;
}
/**
* gdk_wayland_window_set_use_custom_surface:
* @window: (type GdkWaylandWindow): a #GdkWindow

View File

@ -0,0 +1,385 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_surface">
<copyright>
Copyright © 2008-2013 Kristian Høgsberg
Copyright © 2013 Rafael Antognolli
Copyright © 2013 Jasper St. Pierre
Copyright © 2010-2013 Intel Corporation
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<interface name="xdg_shell" version="1">
<description summary="create desktop-style surfaces">
This interface is implemented by servers that provide
desktop-style user interfaces.
It allows clients to associate a xdg_surface with
a basic surface.
</description>
<enum name="version">
<description summary="latest protocol version">
Use this enum to check the protocol version, and it will be updated
automatically.
</description>
<entry name="current" value="1" summary="Always the latest version"/>
</enum>
<request name="use_unstable_version">
<description summary="enable use of this unstable version">
Use this request in order to enable use of this interface.
Understand and agree that one is using an unstable interface,
that will likely change in the future, breaking the API.
</description>
<arg name="version" type="int"/>
</request>
<request name="get_xdg_surface">
<description summary="create a shell surface from a surface">
Create a shell surface for an existing surface.
Only one shell or popup surface can be associated with a given
surface.
</description>
<arg name="id" type="new_id" interface="xdg_surface"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="get_xdg_popup">
<description summary="create a shell surface from a surface">
Create a popup surface for an existing surface.
Only one shell or popup surface can be associated with a given
surface.
</description>
<arg name="id" type="new_id" interface="xdg_popup"/>
<arg name="surface" type="object" interface="wl_surface"/>
<arg name="parent" type="object" interface="wl_surface"/>
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="flags" type="uint"/>
</request>
</interface>
<interface name="xdg_surface" version="1">
<description summary="desktop-style metadata interface">
An interface that may be implemented by a wl_surface, for
implementations that provide a desktop-style user interface.
It provides requests to treat surfaces like windows, allowing to set
properties like maximized, fullscreen, minimized, and to move and resize
them, and associate metadata like title and app id.
On the server side the object is automatically destroyed when
the related wl_surface is destroyed. On client side,
xdg_surface.destroy() must be called before destroying
the wl_surface object.
</description>
<request name="destroy" type="destructor">
<description summary="remove xdg_surface interface">
The xdg_surface interface is removed from the wl_surface object
that was turned into a xdg_surface with
xdg_shell.get_xdg_surface request. The xdg_surface properties,
like maximized and fullscreen, are lost. The wl_surface loses
its role as a xdg_surface. The wl_surface is unmapped.
</description>
</request>
<request name="set_transient_for">
<description summary="surface is a child of another surface">
Setting a surface as transient of another means that it is child
of another surface.
Child surfaces are stacked above their parents, and will be
unmapped if the parent is unmapped too. They should not appear
on task bars and alt+tab.
</description>
<arg name="parent" type="object" interface="wl_surface"/>
</request>
<request name="set_title">
<description summary="set surface title">
Set a short title for the surface.
This string may be used to identify the surface in a task bar,
window list, or other user interface elements provided by the
compositor.
The string must be encoded in UTF-8.
</description>
<arg name="title" type="string"/>
</request>
<request name="set_app_id">
<description summary="set surface class">
Set an id for the surface.
The app id identifies the general class of applications to which
the surface belongs.
It should be the ID that appears in the new desktop entry
specification, the interface name.
</description>
<arg name="app_id" type="string"/>
</request>
<request name="pong">
<description summary="respond to a ping event">
A client must respond to a ping event with a pong request or
the client may be deemed unresponsive.
</description>
<arg name="serial" type="uint" summary="serial of the ping event"/>
</request>
<event name="ping">
<description summary="ping client">
Ping a client to check if it is receiving events and sending
requests. A client is expected to reply with a pong request.
</description>
<arg name="serial" type="uint"/>
</event>
<request name="move">
<description summary="start an interactive move">
Start a pointer-driven move of the surface.
This request must be used in response to a button press event.
The server may ignore move requests depending on the state of
the surface (e.g. fullscreen or maximized).
</description>
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
</request>
<enum name="resize_edge">
<description summary="edge values for resizing">
These values are used to indicate which edge of a surface
is being dragged in a resize operation. The server may
use this information to adapt its behavior, e.g. choose
an appropriate cursor image.
</description>
<entry name="none" value="0"/>
<entry name="top" value="1"/>
<entry name="bottom" value="2"/>
<entry name="left" value="4"/>
<entry name="top_left" value="5"/>
<entry name="bottom_left" value="6"/>
<entry name="right" value="8"/>
<entry name="top_right" value="9"/>
<entry name="bottom_right" value="10"/>
</enum>
<request name="resize">
<description summary="start an interactive resize">
Start a pointer-driven resizing of the surface.
This request must be used in response to a button press event.
The server may ignore resize requests depending on the state of
the surface (e.g. fullscreen or maximized).
</description>
<arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
<arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
</request>
<event name="configure">
<description summary="suggest resize">
The configure event asks the client to resize its surface.
The size is a hint, in the sense that the client is free to
ignore it if it doesn't resize, pick a smaller size (to
satisfy aspect ratio or resize in steps of NxM pixels).
The edges parameter provides a hint about how the surface
was resized. The client may use this information to decide
how to adjust its content to the new size (e.g. a scrolling
area might adjust its content position to leave the viewable
content unmoved). Valid edge values are from resize_edge enum.
The maximized parameter informs if the surface is in a maximized
state. Same for the fullscreen parameter.
The client is free to dismiss all but the last configure
event it received.
The width and height arguments specify the size of the window
in surface local coordinates.
</description>
<arg name="edges" type="uint"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="maximized" type="uint"/>
<arg name="fullscreen" type="uint"/>
</event>
<request name="set_output">
<description summary="set the default output used by this surface">
Set the default output used by this surface when it is first mapped.
If this value is NULL (default), it's up to the compositor to choose
which display will be used to map this surface.
When fullscreen or maximized state are set on this surface, and it
wasn't mapped yet, the output set with this method will be used.
Otherwise, the output where the surface is currently mapped will be
used.
</description>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request>
<request name="set_fullscreen">
<description summary="set the surface state as fullscreen">
Set the surface as fullscreen.
The compositor must reply to this request with a configure event
with the dimensions for the output on which the surface will be
made fullscreen.
Once the fullscreen state is set, a "fullscreen_set" event will
be sent to the client.
Setting one state won't unset another state. Use
xdg_surface.unset_fullscreen for unsetting it.
</description>
</request>
<request name="unset_fullscreen">
<description summary="unset the surface state as fullscreen">
Unset the surface fullscreen state.
</description>
</request>
<request name="set_maximized">
<description summary="set the surface state as maximized">
Set the surface as maximized.
The compositor must reply to this request with a configure event
with the dimensions for the output on which the surface will be
made maximized.
Once the maximized state is set, a "maximized_set" event will be
sent to the client.
Setting one state won't unset another state. Use
xdg_surface.unset_maximized for unsetting it.
</description>
</request>
<request name="unset_maximized">
<description summary="unset the surface state as maximized">
Unset the surface maximized state.
</description>
</request>
<request name="set_minimized">
<description summary="set the surface state as minimized">
Set the surface minimized state.
Setting one state won't unset another state.
</description>
</request>
<event name="focused_set">
<description summary="surface was focused">
The focused_set event is sent when this surface has been
activated. Window decorations should be updated accordingly.
</description>
</event>
<event name="focused_unset">
<description summary="surface was unfocused">
The focused_unset event is sent when this surface has been
deactivated, because another surface has been activated. Window
decorations should be updated accordingly.
</description>
</event>
</interface>
<interface name="xdg_popup" version="1">
<description summary="desktop-style metadata interface">
An interface that may be implemented by a wl_surface, for
implementations that provide a desktop-style popups/menus. A popup
surface is a transient surface with an added pointer grab.
An existing implicit grab will be changed to owner-events mode,
and the popup grab will continue after the implicit grab ends
(i.e. releasing the mouse button does not cause the popup to be
unmapped).
The popup grab continues until the window is destroyed or a mouse
button is pressed in any other clients window. A click in any of
the clients surfaces is reported as normal, however, clicks in
other clients surfaces will be discarded and trigger the callback.
The x and y arguments specify the locations of the upper left
corner of the surface relative to the upper left corner of the
parent surface, in surface local coordinates.
xdg_popup surfaces are always transient for another surface.
</description>
<request name="destroy" type="destructor">
<description summary="remove xdg_surface interface">
The xdg_surface interface is removed from the wl_surface object
that was turned into a xdg_surface with
xdg_shell.get_xdg_surface request. The xdg_surface properties,
like maximized and fullscreen, are lost. The wl_surface loses
its role as a xdg_surface. The wl_surface is unmapped.
</description>
</request>
<request name="pong">
<description summary="respond to a ping event">
A client must respond to a ping event with a pong request or
the client may be deemed unresponsive.
</description>
<arg name="serial" type="uint" summary="serial of the ping event"/>
</request>
<event name="ping">
<description summary="ping client">
Ping a client to check if it is receiving events and sending
requests. A client is expected to reply with a pong request.
</description>
<arg name="serial" type="uint"/>
</event>
<event name="popup_done">
<description summary="popup interaction is done">
The popup_done event is sent out when a popup grab is broken,
that is, when the users clicks a surface that doesn't belong
to the client owning the popup surface.
</description>
<arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
</event>
</interface>
</protocol>