Move make_transient() to Fl_Posix_System_Driver from Fl_Screen_Driver
This commit is contained in:
parent
ab58971bcf
commit
ebd0c81f7e
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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() {}
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user