diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2015-03-06 11:44:42 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2015-04-23 16:02:37 +0800 |
commit | eb6c70137b6d7c7b347148c89b33446dba5991c6 (patch) | |
tree | 6cc5d137e942b8e2510829b609d5a4a52f07a403 | |
parent | df3b412a254f606a79807e56961b6781fa171c9b (diff) |
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
-rw-r--r-- | src/wayland/meta-wayland-surface.c | 46 | ||||
-rw-r--r-- | src/wayland/meta-wayland-surface.h | 1 | ||||
-rw-r--r-- | src/wayland/meta-wayland-versions.h | 2 | ||||
-rw-r--r-- | 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 a189e2fb..111bb3b4 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 5783a465..0bc8dfdc 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 3944956a..08ceaca1 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 bed61d6b..fd9974e2 100644 --- a/src/wayland/protocol/gtk-shell.xml +++ b/src/wayland/protocol/gtk-shell.xml @@ -1,6 +1,6 @@ <protocol name="gtk"> - <interface name="gtk_shell" version="1"> + <interface name="gtk_shell" version="2"> <description summary="gtk specific extensions"> 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 @@ </request> </interface> - <interface name="gtk_surface" version="1"> + <interface name="gtk_surface" 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"/> @@ -34,6 +34,9 @@ <arg name="application_object_path" type="string" allow-null="true"/> <arg name="unique_bus_name" type="string" allow-null="true"/> </request> + + <request name="set_modal"/> + <request name="unset_modal"/> </interface> </protocol> |