[nautilus/wip/antoniof/switch-to-gtk4: 23/40] general: GdkWindow -> GdkSurface




commit c1b090ea9ec5261dea74c6fc4cac99713633172f
Author: António Fernandes <antoniof gnome org>
Date:   Fri Dec 24 00:51:57 2021 +0000

    general: GdkWindow -> GdkSurface
    
    Also includes some backend-specific API changes which are more than
    simple substitution.

 src/nautilus-file-operations.c   | 17 ++++++++---------
 src/nautilus-properties-window.c |  2 +-
 src/nautilus-window.c            | 26 +++++++++++++-------------
 3 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index a408662c8..c68f15b6e 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -1242,13 +1242,13 @@ typedef struct
 } RunSimpleDialogData;
 
 static void
-set_transient_for (GdkWindow  *child_window,
+set_transient_for (GdkSurface *child_surface,
                    const char *parent_handle)
 {
     GdkDisplay *display;
     const char *prefix;
 
-    display = gdk_window_get_display (child_window);
+    display = gdk_surface_get_display (child_surface);
 
 #ifdef GDK_WINDOWING_X11
     if (GDK_IS_X11_DISPLAY (display))
@@ -1258,15 +1258,14 @@ set_transient_for (GdkWindow  *child_window,
         if (g_str_has_prefix (parent_handle, prefix))
         {
             const char *handle;
-            GdkWindow *window;
+            GdkSurface *surface;
 
             handle = parent_handle + strlen (prefix);
-            window = gdk_x11_window_foreign_new_for_display (display, strtol (handle, NULL, 16));
+            surface = gdk_x11_surface_lookup_for_display (display, strtol (handle, NULL, 16));
 
-            if (window != NULL)
+            if (surface != NULL)
             {
-                gdk_window_set_transient_for (child_window, window);
-                g_object_unref (window);
+                gdk_toplevel_set_transient_for (GDK_TOPLEVEL (child_surface), surface);
             }
         }
     }
@@ -1283,7 +1282,7 @@ set_transient_for (GdkWindow  *child_window,
 
             handle = parent_handle + strlen (prefix);
 
-            gdk_wayland_window_set_transient_for_exported (child_window, (char *) handle);
+            gdk_wayland_toplevel_set_transient_for_exported (GDK_TOPLEVEL (child_surface), (char *) handle);
         }
     }
 #endif
@@ -1297,7 +1296,7 @@ dialog_realize_cb (GtkWidget *widget,
     const char *parent_handle;
 
     parent_handle = nautilus_file_operations_dbus_data_get_parent_handle (dbus_data);
-    set_transient_for (gtk_widget_get_window (widget), parent_handle);
+    set_transient_for (gtk_native_get_surface (gtk_widget_get_native (widget)), parent_handle);
 }
 
 static gboolean
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 92d5dba4a..3ca9963e5 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2879,7 +2879,7 @@ start_long_operation (NautilusPropertiesWindow *self)
 static void
 end_long_operation (NautilusPropertiesWindow *self)
 {
-    if (gtk_widget_get_window (GTK_WIDGET (self)) != NULL &&
+    if (gtk_native_get_surface (GTK_NATIVE (self)) != NULL &&
         self->long_operation_underway == 1)
     {
         /* finished !! */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 8f49cf287..51924dd79 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1188,8 +1188,8 @@ get_window_xid (NautilusWindow *window)
 #ifdef GDK_WINDOWING_X11
     if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
     {
-        GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
-        return (guint) gdk_x11_window_get_xid (gdk_window);
+        GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
+        return (guint) gdk_x11_surface_get_xid (gdk_surface);
     }
 #endif
     return 0;
@@ -2373,9 +2373,9 @@ typedef struct
 } WaylandWindowHandleExportedData;
 
 static void
-wayland_window_handle_exported (GdkWindow  *window,
-                                const char *wayland_handle_str,
-                                gpointer    user_data)
+wayland_window_handle_exported (GdkToplevel *toplevel,
+                                const char  *wayland_handle_str,
+                                gpointer     user_data)
 {
     WaylandWindowHandleExportedData *data = user_data;
 
@@ -2409,7 +2409,7 @@ nautilus_window_export_handle (NautilusWindow               *window,
 #ifdef GDK_WINDOWING_WAYLAND
     if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
     {
-        GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+        GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
         WaylandWindowHandleExportedData *data;
 
         data = g_new0 (WaylandWindowHandleExportedData, 1);
@@ -2417,10 +2417,10 @@ nautilus_window_export_handle (NautilusWindow               *window,
         data->callback = callback;
         data->user_data = user_data;
 
-        if (!gdk_wayland_window_export_handle (gdk_window,
-                                               wayland_window_handle_exported,
-                                               data,
-                                               g_free))
+        if (!gdk_wayland_toplevel_export_handle (GDK_WAYLAND_TOPLEVEL (gdk_surface),
+                                                 wayland_window_handle_exported,
+                                                 data,
+                                                 g_free))
         {
             g_free (data);
             return FALSE;
@@ -2448,10 +2448,10 @@ nautilus_window_unexport_handle (NautilusWindow *window)
 #ifdef GDK_WINDOWING_WAYLAND
     if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
     {
-        GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
-        if (gdk_window != NULL)
+        GdkSurface *gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
+        if (GDK_IS_WAYLAND_TOPLEVEL (gdk_surface))
         {
-            gdk_wayland_window_unexport_handle (gdk_window);
+            gdk_wayland_toplevel_unexport_handle (GDK_WAYLAND_TOPLEVEL (gdk_surface));
         }
     }
 #endif


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