diff options
| -rw-r--r-- | FL/x11.H | 6 | ||||
| -rw-r--r-- | documentation/src/osissues.dox | 4 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 7 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.cxx | 3 |
4 files changed, 17 insertions, 3 deletions
@@ -26,6 +26,11 @@ /** Returns the X11 Display in use */ extern Display *fl_x11_display(); +/** Have FLTK use a pre-established X11 connexion. + This function should be called before FLTK attempts to open its own X11 connexion. + \param d the X11 Display* value representing a valid, pre-established X11 connexion + */ +extern void fl_x11_use_display(Display *d); /** Returns the Window reference for the given Fl_Window, or zero if not \c shown(). */ extern Window fl_x11_xid(const Fl_Window *win); /** Returns the Fl_Window corresponding to the given Window reference. */ @@ -58,6 +63,7 @@ extern GLXContext fl_x11_glcontext(GLContext rc); // constant info about the X server connection: extern FL_EXPORT Display *fl_display; extern FL_EXPORT Display *fl_x11_display(); +extern FL_EXPORT void fl_x11_use_display(Display *); extern FL_EXPORT Window fl_x11_xid(const Fl_Window *win); extern FL_EXPORT Fl_Window *fl_x11_find(Window); extern FL_EXPORT int fl_screen; diff --git a/documentation/src/osissues.dox b/documentation/src/osissues.dox index fa17aec7e..1c8718c62 100644 --- a/documentation/src/osissues.dox +++ b/documentation/src/osissues.dox @@ -268,6 +268,10 @@ code will be called before the first \c show() of a window. \par This may call Fl::abort() if there is an error opening the display. +void fl_x11_use_display(Display *d) +\par +Directs FLTK to use a pre-established X11 connexion. + void fl_close_display() \par diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 79d0a8fea..07f80cde7 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -531,7 +531,8 @@ void Fl_X11_Screen_Driver::disable_im() { } void Fl_X11_Screen_Driver::open_display_platform() { - if (fl_display) return; + static GC gc = NULL; + if (gc) return; setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); @@ -539,7 +540,7 @@ void Fl_X11_Screen_Driver::open_display_platform() { XSetIOErrorHandler(io_error_handler); XSetErrorHandler(xerror_handler); - Display *d = XOpenDisplay(0); + Display *d = (fl_display ? fl_display : XOpenDisplay(0)); if (!d) { Fl::fatal("Can't open display: %s", XDisplayName(0)); // does not return return; // silence static code analyzer @@ -547,7 +548,7 @@ void Fl_X11_Screen_Driver::open_display_platform() { open_display_i(d); // the unique GC used by all X windows - GC gc = XCreateGC(fl_display, RootWindow(fl_display, fl_screen), 0, 0); + gc = XCreateGC(fl_display, RootWindow(fl_display, fl_screen), 0, 0); Fl_Graphics_Driver::default_driver().gc(gc); fl_create_print_window(); } diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 9e3465f13..7fc7e2b01 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -80,6 +80,9 @@ void Fl_X11_Screen_Driver::display(const char *d) if (d) setenv("DISPLAY", d, 1); } +void fl_x11_use_display(Display *d) { + fl_display = d; +} int Fl_X11_Screen_Driver::XParseGeometry(const char* string, int* x, int* y, unsigned int* width, unsigned int* height) { |
