[gtk/wip/carlosg/present-window-on-wayland: 2/3] gdk/wayland: Implement gdk_window_present()



commit ed9db5a17327e0e12036d9daa25f37252554419d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jan 23 17:03:25 2019 +0100

    gdk/wayland: Implement gdk_window_present()
    
    This uses the gtk_surface1.request_focus request added in gtk-shell v3,
    the given startup ID may be used by the compositor in order to determine
    when was the request started, and whether user input happened in between.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/624

 gdk/wayland/gdkdisplay-wayland.c |  2 +-
 gdk/wayland/gdkwindow-wayland.c  | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 1e00f292d8..be74c93e0a 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -83,7 +83,7 @@
 
 #define MIN_SYSTEM_BELL_DELAY_MS 20
 
-#define GTK_SHELL1_VERSION       2
+#define GTK_SHELL1_VERSION       3
 
 static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
 
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 91e01e1d90..70f1044d9b 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -3532,14 +3532,20 @@ gdk_wayland_window_focus (GdkWindow *window,
   if (!impl->display_server.gtk_surface)
     return;
 
-  /* We didn't have an event to fetch a time from, meaning we have nothing valid
-   * to send. This should rather be translated to a 'needs-attention' request or
-   * something.
-   */
   if (timestamp == GDK_CURRENT_TIME)
-    return;
+    {
+      GdkWaylandDisplay *display_wayland =
+        GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
 
-  gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
+      if (display_wayland->gtk_shell_version >= 3)
+        {
+          gtk_surface1_request_focus (impl->display_server.gtk_surface,
+                                      display_wayland->startup_notification_id);
+          g_clear_pointer (&display_wayland->startup_notification_id, g_free);
+        }
+    }
+  else
+    gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
 }
 
 static void


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