[gtk+] wayland: Add support for gtk_window_set_modal



commit 3da7394b58b033c181acfb4323d7c100a084884c
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Mar 6 11:40:12 2015 +0800

    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

 gdk/wayland/gdkprivate-wayland.h   |    2 +-
 gdk/wayland/gdkwindow-wayland.c    |   54 ++++++++++++++++++++++++------------
 gdk/wayland/protocol/gtk-shell.xml |    7 +++-
 3 files changed, 42 insertions(+), 21 deletions(-)
---
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index a8211fd..cd2e171 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -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))
 
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 14ffbe4..a4e1df4 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -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
@@ -1629,9 +1628,37 @@ gdk_wayland_window_get_type_hint (GdkWindow *window)
 }
 
 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);
 }
diff --git a/gdk/wayland/protocol/gtk-shell.xml b/gdk/wayland/protocol/gtk-shell.xml
index bed61d6..fd9974e 100644
--- a/gdk/wayland/protocol/gtk-shell.xml
+++ b/gdk/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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]