Commit 3da7394b authored by Jonas Ådahl's avatar Jonas Ådahl

wayland: Add support for gtk_window_set_modal

Add two new requests to the gtk_surface interface: set_modal and
unset_modal. The server will currently not do anything special with
input focus, and its up to the client to ignore events on the parent
surface.

This commit bumps the gtk_shell interface version to 2. By connecting to
a Wayland server with another gtk_shell interface version any features
depending on the gtk_shell protocol will not be available.

https://bugzilla.gnome.org/show_bug.cgi?id=745721
parent 556fde09
......@@ -42,7 +42,7 @@
#define WL_SURFACE_HAS_BUFFER_SCALE 3
#define SUPPORTED_GTK_SHELL_VERSION 1
#define SUPPORTED_GTK_SHELL_VERSION 2
#define GDK_WINDOW_IS_WAYLAND(win) (GDK_IS_WINDOW_IMPL_WAYLAND (((GdkWindow *)win)->impl))
......
......@@ -155,8 +155,7 @@ static void gdk_wayland_window_configure (GdkWindow *window,
int height,
int scale);
static void maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
GdkWindowImplWayland *impl);
static void maybe_set_gtk_surface_dbus_properties (GdkWindow *window);
GType _gdk_window_impl_wayland_get_type (void);
......@@ -1007,7 +1006,7 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
xdg_surface_set_app_id (impl->xdg_surface, app_id);
maybe_set_gtk_surface_dbus_properties (display_wayland, impl);
maybe_set_gtk_surface_dbus_properties (window);
}
static void
......@@ -1628,10 +1627,38 @@ gdk_wayland_window_get_type_hint (GdkWindow *window)
return impl->hint;
}
static void
gdk_wayland_window_init_gtk_surface (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandDisplay *display =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
if (impl->gtk_surface != NULL)
return;
if (impl->xdg_surface == NULL)
return;
if (display->gtk_shell == NULL)
return;
impl->gtk_surface = gtk_shell_get_gtk_surface (display->gtk_shell,
impl->surface);
}
static void
gdk_wayland_window_set_modal_hint (GdkWindow *window,
gboolean modal)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
gdk_wayland_window_init_gtk_surface (window);
if (impl->gtk_surface == NULL)
return;
if (modal)
gtk_surface_set_modal (impl->gtk_surface);
else
gtk_surface_unset_modal (impl->gtk_surface);
}
static void
......@@ -2439,9 +2466,10 @@ gdk_wayland_window_set_use_custom_surface (GdkWindow *window)
}
static void
maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
GdkWindowImplWayland *impl)
maybe_set_gtk_surface_dbus_properties (GdkWindow *window)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (impl->application.was_set)
return;
......@@ -2453,17 +2481,9 @@ maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
impl->application.unique_bus_name == NULL)
return;
gdk_wayland_window_init_gtk_surface (window);
if (impl->gtk_surface == NULL)
{
if (impl->xdg_surface == NULL)
return;
if (display_wayland->gtk_shell == NULL)
return;
impl->gtk_surface = gtk_shell_get_gtk_surface (display_wayland->gtk_shell,
impl->surface);
}
return;
gtk_surface_set_dbus_properties (impl->gtk_surface,
impl->application.application_id,
......@@ -2484,8 +2504,6 @@ gdk_wayland_window_set_dbus_properties_libgtk_only (GdkWindow *window,
const char *application_object_path,
const char *unique_bus_name)
{
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkWindowImplWayland *impl;
g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
......@@ -2500,5 +2518,5 @@ gdk_wayland_window_set_dbus_properties_libgtk_only (GdkWindow *window,
g_strdup (application_object_path);
impl->application.unique_bus_name = g_strdup (unique_bus_name);
maybe_set_gtk_surface_dbus_properties (display_wayland, impl);
maybe_set_gtk_surface_dbus_properties (window);
}
<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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment