From eb6c70137b6d7c7b347148c89b33446dba5991c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 6 Mar 2015 11:44:42 +0800 Subject: [PATCH] wayland: Add and implement set/unset_modal for the gtk_surface interface Add set_modal ond unset_modal to the gtk_surface interface. When a surface is modal, the compositor can treat it differently from non-modal dialogs, for example attach it to the parent window if any. There is currently no changes to input device focus; it is up to the client to ignore events to the parent surface that is wanted. This bumps the gtk_shell version to 2. https://bugzilla.gnome.org/show_bug.cgi?id=745720 --- src/wayland/meta-wayland-surface.c | 46 +++++++++++++++++++++++------ src/wayland/meta-wayland-surface.h | 1 + src/wayland/meta-wayland-versions.h | 2 +- src/wayland/protocol/gtk-shell.xml | 7 +++-- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index a189e2fb6..111bb3b4d 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1554,14 +1554,14 @@ gtk_surface_destructor (struct wl_resource *resource) } static void -set_dbus_properties (struct wl_client *client, - struct wl_resource *resource, - const char *application_id, - const char *app_menu_path, - const char *menubar_path, - const char *window_object_path, - const char *application_object_path, - const char *unique_bus_name) +gtk_surface_set_dbus_properties (struct wl_client *client, + struct wl_resource *resource, + const char *application_id, + const char *app_menu_path, + const char *menubar_path, + const char *window_object_path, + const char *application_object_path, + const char *unique_bus_name) { MetaWaylandSurface *surface = wl_resource_get_user_data (resource); @@ -1581,8 +1581,36 @@ set_dbus_properties (struct wl_client *client, window_object_path); } +static void +gtk_surface_set_modal (struct wl_client *client, + struct wl_resource *resource) +{ + MetaWaylandSurface *surface = wl_resource_get_user_data (resource); + + if (surface->is_modal) + return; + + surface->is_modal = TRUE; + meta_window_set_type (surface->window, META_WINDOW_MODAL_DIALOG); +} + +static void +gtk_surface_unset_modal (struct wl_client *client, + struct wl_resource *resource) +{ + MetaWaylandSurface *surface = wl_resource_get_user_data (resource); + + if (!surface->is_modal) + return; + + surface->is_modal = FALSE; + meta_window_set_type (surface->window, META_WINDOW_NORMAL); +} + static const struct gtk_surface_interface meta_wayland_gtk_surface_interface = { - set_dbus_properties + gtk_surface_set_dbus_properties, + gtk_surface_set_modal, + gtk_surface_unset_modal, }; static void diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 5783a465a..0bc8dfdc2 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -101,6 +101,7 @@ struct _MetaWaylandSurface struct wl_resource *xdg_shell_resource; MetaWaylandSerial acked_configure_serial; gboolean has_set_geometry; + gboolean is_modal; /* xdg_popup */ struct { diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h index 3944956aa..08ceaca10 100644 --- a/src/wayland/meta-wayland-versions.h +++ b/src/wayland/meta-wayland-versions.h @@ -42,7 +42,7 @@ #define META_WL_SEAT_VERSION 4 #define META_WL_OUTPUT_VERSION 2 #define META_XSERVER_VERSION 1 -#define META_GTK_SHELL_VERSION 1 +#define META_GTK_SHELL_VERSION 2 #define META_WL_SUBCOMPOSITOR_VERSION 1 #endif diff --git a/src/wayland/protocol/gtk-shell.xml b/src/wayland/protocol/gtk-shell.xml index bed61d6b2..fd9974e20 100644 --- a/src/wayland/protocol/gtk-shell.xml +++ b/src/wayland/protocol/gtk-shell.xml @@ -1,6 +1,6 @@ - + gtk_shell is a protocol extension providing additional features for clients implementing it. It is not backward compatible, and a client must @@ -25,7 +25,7 @@ - + @@ -34,6 +34,9 @@ + + +