From 9bdc310346077e3fd60371b3d3d0c7db54db10e3 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 30 Sep 2011 14:46:08 +0000 Subject: Fix STR#2600 : screens configuration changes are now detected under all platforms. Requires the RandR X extension. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9102 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl.cxx | 2 +- src/Fl_x.cxx | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Fl.cxx b/src/Fl.cxx index 6264c4a30..374847047 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -778,7 +778,7 @@ static handler_link *handlers = 0; - \ref FL_SHORTCUT events that are not recognized by any widget. This lets you provide global shortcut keys. - - \ref FL_SCREEN_CONFIGURATION_CHANGED events (not implemented on the X11 platform). + - \ref FL_SCREEN_CONFIGURATION_CHANGED events. - System events that FLTK does not recognize. See fl_xevent. - \e Some other events when the widget FLTK selected returns zero from its handle() method. Exactly which ones may change diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index bc528aa34..360981ed8 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -43,6 +43,10 @@ # include # include # include +#ifdef HAVE_XRANDR +#include +static int randrEventBase = -1; +#endif static Fl_Xlib_Graphics_Driver fl_xlib_driver; static Fl_Display_Device fl_xlib_display(&fl_xlib_driver); @@ -587,6 +591,7 @@ void fl_open_display() { fl_open_display(d); } + void fl_open_display(Display* d) { fl_display = d; @@ -637,6 +642,12 @@ void fl_open_display(Display* d) { #if !USE_COLORMAP Fl::visual(FL_RGB); #endif +#ifdef HAVE_XRANDR + int error_base; + if (XRRQueryExtension(d, &randrEventBase, &error_base)) + XRRSelectInput(d, RootWindow(d, fl_screen), RRScreenChangeNotifyMask); + else randrEventBase = -1; +#endif } void fl_close_display() { @@ -920,7 +931,16 @@ int fl_handle(const XEvent& thisevent) if ( XFilterEvent((XEvent *)&xevent, 0) ) return(1); - + +#ifdef HAVE_XRANDR + if( randrEventBase >= 0 && xevent.type == randrEventBase + RRScreenChangeNotify) { + XRRUpdateConfiguration (&xevent); + Fl::call_screen_init(); + fl_init_workarea(); + Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL); + } +#endif + switch (xevent.type) { case KeymapNotify: -- cgit v1.2.3