[gimp] app: Partially correct gimp_window_get_native_id()



commit 5a1dd584e94221d5fbfd191cb047357d480d0236
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Dec 30 12:22:42 2020 +0100

    app: Partially correct gimp_window_get_native_id()
    
    Most important of all, we shouldn't assume that if a given GDK backend
    is enabled at compile time, that this is also the one that is being
    used. For example, on Linux, both `GDK_WINDOWING_X11` and
    `GDK_WINDOWING_WAYLAND` can be set, but you still need to do a runtime
    check if you're running under one WM or the the other.
    
    A small cleanup is that we immediately check if a widget is realized by
    checking if it's `GdkWindow` is NULL or not and return immediately
    (since we need to check its type later on anyway).
    
    Finally, we can remove `GDK_NATIVE_WINDOW_POINTER` as that is a GTK+ 2.0
    construct, so it's dead code anyway.

 app/widgets/gimpwidgets-utils.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 93356fa23c..524ea67c3a 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -33,6 +33,10 @@
 #include <gdk/gdkx.h>
 #endif
 
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+
 #ifdef PLATFORM_OSX
 #include <ApplicationServices/ApplicationServices.h>
 #endif
@@ -877,25 +881,29 @@ gimp_window_set_hint (GtkWindow      *window,
 guint32
 gimp_window_get_native_id (GtkWindow *window)
 {
+  GdkWindow *surface;
+
   g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
 
-#ifdef GDK_NATIVE_WINDOW_POINTER
-#ifdef __GNUC__
-#warning gimp_window_get_native() unimplementable for the target windowing system
-#endif
-  return 0;
-#endif
+  surface = gtk_widget_get_window (GTK_WIDGET (window));
+  if (!surface) /* aka window is not yet realized */
+    return 0;
 
 #ifdef GDK_WINDOWING_WIN32
-  if (window && gtk_widget_get_realized (GTK_WIDGET (window)))
+  if (GDK_IS_WIN32_WINDOW (surface))
     return GDK_WINDOW_HWND (gtk_widget_get_window (GTK_WIDGET (window)));
 #endif
 
 #ifdef GDK_WINDOWING_X11
-  if (window && gtk_widget_get_realized (GTK_WIDGET (window)))
+  if (GDK_IS_X11_WINDOW (surface))
     return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
 #endif
 
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_WINDOW (surface))
+    g_debug ("Getting window ID for progress not supported on Wayland yet");
+#endif
+
   return 0;
 }
 


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