[gnome-builder] libide-gui: use root instead of native to get workbench



commit 093feb4043c0e44c47d0663b130da96d03b2b438
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 12 22:09:31 2022 -0700

    libide-gui: use root instead of native to get workbench
    
    We don't care much about the native, what we really want is the window at
    the root of the hierarchy which should be in our workbench window group.

 src/libide/gui/ide-gui-global.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/gui/ide-gui-global.c b/src/libide/gui/ide-gui-global.c
index 49c56ebc4..22b907adb 100644
--- a/src/libide/gui/ide-gui-global.c
+++ b/src/libide/gui/ide-gui-global.c
@@ -201,19 +201,24 @@ ide_widget_get_context (GtkWidget *widget)
 IdeWorkbench *
 ide_widget_get_workbench (GtkWidget *widget)
 {
-  GtkWidget *toplevel;
+  GtkWindow *transient_for;
+  GtkRoot *root;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  toplevel = GTK_WIDGET (gtk_widget_get_native (widget));
+  if (GTK_IS_ROOT (widget))
+    root = GTK_ROOT (widget);
+  else
+    root = gtk_widget_get_root (widget);
 
-  if (GTK_IS_WINDOW (toplevel))
-    {
-      GtkWindowGroup *group = gtk_window_get_group (GTK_WINDOW (toplevel));
+  if (root != NULL &&
+      !IDE_IS_WORKSPACE (root) &&
+      GTK_IS_WINDOW (root) &&
+      (transient_for = gtk_window_get_transient_for (GTK_WINDOW (root))))
+    return ide_widget_get_workbench (GTK_WIDGET (transient_for));
 
-      if (IDE_IS_WORKBENCH (group))
-        return IDE_WORKBENCH (group);
-    }
+  if (GTK_IS_WINDOW (root))
+    return IDE_WORKBENCH (gtk_window_get_group (GTK_WINDOW (root)));
 
   return NULL;
 }


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