[master] ebd0c81 - Move make_transient() to Fl_Posix_System_Driver from Fl_Screen_Driver

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] ebd0c81 - Move make_transient() to Fl_Posix_System_Driver from Fl_Screen_Driver "ManoloFLTK" 10:32 Jan 14 top right image
 
commit ebd0c81f7e5745d58e11846a695fe5842245c627
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri Jan 14 19:25:08 2022 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri Jan 14 19:25:17 2022 +0100

    Move make_transient() to Fl_Posix_System_Driver from Fl_Screen_Driver

 src/Fl_Native_File_Chooser_GTK.cxx         |  3 ++-
 src/Fl_Screen_Driver.H                     |  1 +
 src/drivers/Posix/Fl_Posix_System_Driver.H |  1 -
 src/drivers/X11/Fl_X11_Screen_Driver.H     |  4 +++
 src/drivers/X11/Fl_X11_Screen_Driver.cxx   | 40 ++++++++++++++++++++++++++++++
 src/drivers/X11/Fl_X11_System_Driver.H     |  1 -
 src/drivers/X11/Fl_X11_System_Driver.cxx   | 40 ------------------------------
 7 files changed, 47 insertions(+), 43 deletions(-)

diff --git src/Fl_Native_File_Chooser_GTK.cxx src/Fl_Native_File_Chooser_GTK.cxx
index a161da7..976d6f9 100644
--- src/Fl_Native_File_Chooser_GTK.cxx
+++ src/Fl_Native_File_Chooser_GTK.cxx
@@ -29,6 +29,7 @@
 #include <FL/fl_string.h>
 #include <dlfcn.h>   // for dlopen et al
 #include "drivers/X11/Fl_X11_System_Driver.H"
+#include "Fl_Screen_Driver.H"
 
 /* --------------------- Type definitions from GLIB and GTK --------------------- */
 /* all of this is from the public gnome API, so unlikely to change */
@@ -761,7 +762,7 @@ int Fl_GTK_Native_File_Chooser_Driver::fl_gtk_chooser_wrapper()
   Fl_Window* firstw = Fl::first_window();
   fl_gtk_widget_show_now(gtkw_ptr); // map the GTK window on screen
   if (firstw) {
-    ((Fl_Posix_System_Driver*)Fl::system_driver())->make_transient(Fl_Posix_System_Driver::ptr_gtk, gtkw_ptr, firstw);
+    Fl::screen_driver()->make_transient(Fl_Posix_System_Driver::ptr_gtk, gtkw_ptr, firstw);
   }
   gboolean state = fl_gtk_file_chooser_get_show_hidden((GtkFileChooser *)gtkw_ptr);
   fl_gtk_toggle_button_set_active((GtkToggleButton *)show_hidden_button, state);
diff --git src/Fl_Screen_Driver.H src/Fl_Screen_Driver.H
index d6baf77..e33950b 100644
--- src/Fl_Screen_Driver.H
+++ src/Fl_Screen_Driver.H
@@ -206,6 +206,7 @@ public:
   virtual APP_SCALING_CAPABILITY rescalable() { return NO_APP_SCALING; }
   // supports Fl_Window::default_icons()
   virtual void default_icons(const Fl_RGB_Image *icons[], int count);
+  virtual void make_transient(void *, void *, Fl_Window *) {}
 };
 
 #endif // !FL_SCREEN_DRIVER_H
diff --git src/drivers/Posix/Fl_Posix_System_Driver.H src/drivers/Posix/Fl_Posix_System_Driver.H
index 8206871..9d2c0fa 100644
--- src/drivers/Posix/Fl_Posix_System_Driver.H
+++ src/drivers/Posix/Fl_Posix_System_Driver.H
@@ -88,7 +88,6 @@ public:
   virtual void lock_ring();
   virtual void unlock_ring();
 #endif
-  virtual void make_transient(void */*ptr_gtk*/, void */*gtk_window*/, Fl_Window *) {}
   virtual void emulate_modal_dialog() {}
 };
 
diff --git src/drivers/X11/Fl_X11_Screen_Driver.H src/drivers/X11/Fl_X11_Screen_Driver.H
index 6fb8330..8a82486 100644
--- src/drivers/X11/Fl_X11_Screen_Driver.H
+++ src/drivers/X11/Fl_X11_Screen_Driver.H
@@ -23,6 +23,7 @@
 #ifndef FL_X11_SCREEN_DRIVER_H
 #define FL_X11_SCREEN_DRIVER_H
 
+#include <config.h>
 #include "../../Fl_Screen_Driver.H"
 
 
@@ -102,6 +103,9 @@ public:
   // --- compute dimensions of an Fl_Offscreen
   virtual void offscreen_size(Fl_Offscreen o, int &width, int &height);
   virtual void default_icons(const Fl_RGB_Image *icons[], int count);
+#if HAVE_DLSYM && HAVE_DLFCN_H
+  virtual void make_transient(void *ptr_gtk, void *gtk_window, Fl_Window *win);
+#endif
 };
 
 
diff --git src/drivers/X11/Fl_X11_Screen_Driver.cxx src/drivers/X11/Fl_X11_Screen_Driver.cxx
index ed8c54d..717132d 100644
--- src/drivers/X11/Fl_X11_Screen_Driver.cxx
+++ src/drivers/X11/Fl_X11_Screen_Driver.cxx
@@ -1399,3 +1399,43 @@ void Fl_X11_Screen_Driver::desktop_scale_factor()
 }
 
 #endif // USE_XFT
+
+#if HAVE_DLSYM && HAVE_DLFCN_H
+void Fl_X11_Screen_Driver::make_transient(void *ptr_gtk, void *gtkw_window, Fl_Window *win) {
+  typedef int gboolean;
+  typedef struct _GdkDrawable GdkWindow;
+  typedef struct _GtkWidget GtkWidget;
+
+  typedef unsigned long (*XX_gdk_x11_window_get_type)();
+  static XX_gdk_x11_window_get_type fl_gdk_x11_window_get_type = NULL;
+
+  typedef gboolean (*XX_g_type_check_instance_is_a)(void *type_instance, unsigned long iface_type);
+  static XX_g_type_check_instance_is_a fl_g_type_check_instance_is_a = NULL;
+
+  typedef Window (*gdk_to_X11_t)(GdkWindow*);
+  static gdk_to_X11_t fl_gdk_to_X11 = NULL;
+
+  typedef GdkWindow* (*XX_gtk_widget_get_window)(GtkWidget *);
+  static XX_gtk_widget_get_window fl_gtk_widget_get_window = NULL;
+
+  if (!fl_gdk_to_X11) {
+    fl_gdk_to_X11 = (gdk_to_X11_t)dlsym(ptr_gtk, "gdk_x11_drawable_get_xid");
+    if (!fl_gdk_to_X11) fl_gdk_to_X11 = (gdk_to_X11_t)dlsym(ptr_gtk, "gdk_x11_window_get_xid");
+    if (!fl_gdk_to_X11) return;
+    fl_gdk_x11_window_get_type = (XX_gdk_x11_window_get_type)dlsym(ptr_gtk, "gdk_x11_window_get_type");
+    fl_g_type_check_instance_is_a = (XX_g_type_check_instance_is_a)dlsym(ptr_gtk, "g_type_check_instance_is_a");
+    fl_gtk_widget_get_window = (XX_gtk_widget_get_window)dlsym(ptr_gtk, "gtk_widget_get_window");
+    if (!fl_gtk_widget_get_window) return;
+  }
+  GdkWindow* gdkw = fl_gtk_widget_get_window((GtkWidget*)gtkw_window);
+
+  // Make sure the Dialog is an X11 window because it's not on Wayland.
+  // Until we find how to make a wayland window transient for an X11 window,
+  // we make the GTK window transient only when it's X11-based.
+  if ( (!fl_gdk_x11_window_get_type) || (!fl_g_type_check_instance_is_a) ||
+      fl_g_type_check_instance_is_a(gdkw, fl_gdk_x11_window_get_type()) ) {
+    Window xw = fl_gdk_to_X11(gdkw); // get the X11 ref of the GTK window
+    if (xw) XSetTransientForHint(fl_display, xw, fl_xid(win)); // set the GTK window transient for the last FLTK win
+  }
+}
+#endif //HAVE_DLSYM && HAVE_DLFCN_H
diff --git src/drivers/X11/Fl_X11_System_Driver.H src/drivers/X11/Fl_X11_System_Driver.H
index f95fb6b..69649bc 100644
--- src/drivers/X11/Fl_X11_System_Driver.H
+++ src/drivers/X11/Fl_X11_System_Driver.H
@@ -64,7 +64,6 @@ public:
   virtual void add_fd(int fd, Fl_FD_Handler cb, void* = 0);
   virtual void remove_fd(int, int when);
   virtual void remove_fd(int);
-  virtual void make_transient(void *ptr_gtk, void *gtk_window, Fl_Window *win);
   virtual void emulate_modal_dialog();
 };
 
diff --git src/drivers/X11/Fl_X11_System_Driver.cxx src/drivers/X11/Fl_X11_System_Driver.cxx
index 405be9e..30dfe8b 100644
--- src/drivers/X11/Fl_X11_System_Driver.cxx
+++ src/drivers/X11/Fl_X11_System_Driver.cxx
@@ -619,46 +619,6 @@ void Fl_X11_System_Driver::own_colormap() {
 }
 
 
-void Fl_X11_System_Driver::make_transient(void *ptr_gtk, void *gtkw_window, Fl_Window *win) {
-#if HAVE_DLSYM && HAVE_DLFCN_H
-  typedef int gboolean;
-  typedef struct _GdkDrawable GdkWindow;
-  typedef struct _GtkWidget GtkWidget;
-
-  typedef unsigned long (*XX_gdk_x11_window_get_type)();
-  static XX_gdk_x11_window_get_type fl_gdk_x11_window_get_type = NULL;
-
-  typedef gboolean (*XX_g_type_check_instance_is_a)(void *type_instance, unsigned long iface_type);
-  static XX_g_type_check_instance_is_a fl_g_type_check_instance_is_a = NULL;
-
-  typedef Window (*gdk_to_X11_t)(GdkWindow*);
-  static gdk_to_X11_t fl_gdk_to_X11 = NULL;
-
-  typedef GdkWindow* (*XX_gtk_widget_get_window)(GtkWidget *);
-  static XX_gtk_widget_get_window fl_gtk_widget_get_window = NULL;
-
-  if (!fl_gdk_to_X11) {
-    fl_gdk_to_X11 = (gdk_to_X11_t)dlsym(ptr_gtk, "gdk_x11_drawable_get_xid");
-    if (!fl_gdk_to_X11) fl_gdk_to_X11 = (gdk_to_X11_t)dlsym(ptr_gtk, "gdk_x11_window_get_xid");
-    if (!fl_gdk_to_X11) return;
-    fl_gdk_x11_window_get_type = (XX_gdk_x11_window_get_type)dlsym(ptr_gtk, "gdk_x11_window_get_type");
-    fl_g_type_check_instance_is_a = (XX_g_type_check_instance_is_a)dlsym(ptr_gtk, "g_type_check_instance_is_a");
-    fl_gtk_widget_get_window = (XX_gtk_widget_get_window)dlsym(ptr_gtk, "gtk_widget_get_window");
-    if (!fl_gtk_widget_get_window) return;
-  }
-  GdkWindow* gdkw = fl_gtk_widget_get_window((GtkWidget*)gtkw_window);
-
-  // Make sure the Dialog is an X11 window because it's not on Wayland.
-  // Until we find how to make a wayland window transient for an X11 window,
-  // we make the GTK window transient only when it's X11-based.
-  if ( (!fl_gdk_x11_window_get_type) || (!fl_g_type_check_instance_is_a) ||
-      fl_g_type_check_instance_is_a(gdkw, fl_gdk_x11_window_get_type()) ) {
-    Window xw = fl_gdk_to_X11(gdkw); // get the X11 ref of the GTK window
-    if (xw) XSetTransientForHint(fl_display, xw, fl_xid(win)); // set the GTK window transient for the last FLTK win
-  }
-#endif //HAVE_DLSYM && HAVE_DLFCN_H
-}
-
 void Fl_X11_System_Driver::emulate_modal_dialog() {
   while (XEventsQueued(fl_display, QueuedAfterReading)) { // emulate modal dialog
     XEvent xevent;
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2022 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.