Blame SOURCES/fltk-1_v2.3.x-multihead.patch

ceac5b
diff -up fltk-1.3.0r9619/FL/Fl_Window.H.multihead fltk-1.3.0r9619/FL/Fl_Window.H
ceac5b
--- fltk-1.3.0r9619/FL/Fl_Window.H.multihead	2012-08-27 11:02:32.646542627 +0200
ceac5b
+++ fltk-1.3.0r9619/FL/Fl_Window.H	2012-08-27 11:02:32.659542408 +0200
ceac5b
@@ -54,7 +54,7 @@ class Fl_RGB_Image;
ceac5b
 class FL_EXPORT Fl_Window : public Fl_Group {
ceac5b
 
ceac5b
   static char *default_xclass_;
ceac5b
-  // Note: we must use separate statements for each of the following 4 variables,
ceac5b
+  // Note: we must use separate statements for each of the following 8 variables,
ceac5b
   // with the static attribute, otherwise MS VC++ 2008/2010 complains :-(
ceac5b
   // AlbrechtS 04/2012
ceac5b
 #if FLTK_ABI_VERSION < 10302
ceac5b
@@ -73,6 +73,22 @@ class FL_EXPORT Fl_Window : public Fl_Gr
ceac5b
   static // when these members are static, ABI compatibility with 1.3.0 is respected
ceac5b
 #endif
ceac5b
   int no_fullscreen_h;
ceac5b
+#if FLTK_ABI_VERSION < 10302
ceac5b
+  static // when these members are static, ABI compatibility with 1.3.0 is respected
ceac5b
+#endif
ceac5b
+  int fullscreen_screen_top;
ceac5b
+#if FLTK_ABI_VERSION < 10302
ceac5b
+  static // when these members are static, ABI compatibility with 1.3.0 is respected
ceac5b
+#endif
ceac5b
+  int fullscreen_screen_bottom;
ceac5b
+#if FLTK_ABI_VERSION < 10302
ceac5b
+  static // when these members are static, ABI compatibility with 1.3.0 is respected
ceac5b
+#endif
ceac5b
+  int fullscreen_screen_left;
ceac5b
+#if FLTK_ABI_VERSION < 10302
ceac5b
+  static // when these members are static, ABI compatibility with 1.3.0 is respected
ceac5b
+#endif
ceac5b
+  int fullscreen_screen_right;
ceac5b
 
ceac5b
   friend class Fl_X;
ceac5b
   Fl_X *i; // points at the system-specific stuff
ceac5b
@@ -422,13 +438,15 @@ public:
ceac5b
   */
ceac5b
   void show(int argc, char **argv);
ceac5b
   /**
ceac5b
-    Makes the window completely fill the screen, without any window
ceac5b
-    manager border visible.  You must use fullscreen_off() to undo
ceac5b
-    this. 
ceac5b
+    Makes the window completely fill one or more screens, without any
ceac5b
+    window manager border visible.  You must use fullscreen_off() to
ceac5b
+    undo this. 
ceac5b
 
ceac5b
     \note On some platforms, this can result in the keyboard being
ceac5b
     grabbed. The window may also be recreated, meaning hide() and
ceac5b
     show() will be called.
ceac5b
+
ceac5b
+    \see void Fl_Window::fullscreen_screens()
ceac5b
   */
ceac5b
   void fullscreen();
ceac5b
   /**
ceac5b
@@ -445,6 +463,17 @@ public:
ceac5b
   */
ceac5b
   unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
ceac5b
   /**
ceac5b
+    Sets which screens should be used when this window is in fullscreen
ceac5b
+    mode. The window will be resized to the top of the screen with index
ceac5b
+    \p top, the bottom of the screen with index \p bottom, etc. 
ceac5b
+
ceac5b
+    If this method is never called, or if any argument is < 0, then the
ceac5b
+    window will be resized to fill the screen it is currently on.
ceac5b
+
ceac5b
+    \see void Fl_Window::fullscreen()
ceac5b
+    */
ceac5b
+  void fullscreen_screens(int top, int bottom, int left, int right);
ceac5b
+  /**
ceac5b
     Iconifies the window.  If you call this when shown() is false
ceac5b
     it will show() it as an icon.  If the window is already
ceac5b
     iconified this does nothing.
ceac5b
diff -up fltk-1.3.0r9619/FL/win32.H.multihead fltk-1.3.0r9619/FL/win32.H
ceac5b
--- fltk-1.3.0r9619/FL/win32.H.multihead	2012-08-27 11:02:32.646542627 +0200
ceac5b
+++ fltk-1.3.0r9619/FL/win32.H	2012-08-27 11:02:32.659542408 +0200
ceac5b
@@ -80,6 +80,7 @@ public:
ceac5b
   static Fl_X* i(const Fl_Window* w) {return w->i;}
ceac5b
   static int fake_X_wm(const Fl_Window* w,int &X, int &Y,
ceac5b
 		                 int &bt,int &bx,int &by;;
ceac5b
+  void make_fullscreen(int X, int Y, int W, int H);
ceac5b
   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
ceac5b
   void flush() {w->flush();}
ceac5b
   void set_minmax(LPMINMAXINFO minmax);
ceac5b
diff -up fltk-1.3.0r9619/src/Fl_cocoa.mm.multihead fltk-1.3.0r9619/src/Fl_cocoa.mm
ceac5b
--- fltk-1.3.0r9619/src/Fl_cocoa.mm.multihead	2012-08-27 11:02:32.641542711 +0200
ceac5b
+++ fltk-1.3.0r9619/src/Fl_cocoa.mm	2012-08-27 14:00:11.192497864 +0200
ceac5b
@@ -2435,9 +2435,32 @@ void Fl_X::make(Fl_Window* w)
ceac5b
 	  
ceac5b
     NSRect crect;
ceac5b
     if (w->fullscreen_active()) {
ceac5b
-      int sx, sy, sw, sh;
ceac5b
-      Fl::screen_xywh(sx, sy, sw, sh, w->x(), w->y(), w->w(), w->h());
ceac5b
-      w->resize(sx, sy, sw, sh);
ceac5b
+      int top, bottom, left, right;
ceac5b
+      int sx, sy, sw, sh, X, Y, W, H;
ceac5b
+
ceac5b
+      top = w->fullscreen_screen_top;
ceac5b
+      bottom = w->fullscreen_screen_bottom;
ceac5b
+      left = w->fullscreen_screen_left;
ceac5b
+      right = w->fullscreen_screen_right;
ceac5b
+
ceac5b
+      if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
ceac5b
+        top = Fl::screen_num(w->x(), w->y(), w->w(), w->h());
ceac5b
+        bottom = top;
ceac5b
+        left = top;
ceac5b
+        right = top;
ceac5b
+      }
ceac5b
+
ceac5b
+      Fl::screen_xywh(sx, sy, sw, sh, top);
ceac5b
+      Y = sy;
ceac5b
+      Fl::screen_xywh(sx, sy, sw, sh, bottom);
ceac5b
+      H = sy + sh - Y;
ceac5b
+      Fl::screen_xywh(sx, sy, sw, sh, left);
ceac5b
+      X = sx;
ceac5b
+      Fl::screen_xywh(sx, sy, sw, sh, right);
ceac5b
+      W = sx + sw - X;
ceac5b
+
ceac5b
+      w->resize(X, Y, W, H);
ceac5b
+
ceac5b
       winstyle = NSBorderlessWindowMask;
ceac5b
       winlevel = NSStatusWindowLevel;
ceac5b
     }
ceac5b
diff -up fltk-1.3.0r9619/src/Fl_win32.cxx.multihead fltk-1.3.0r9619/src/Fl_win32.cxx
ceac5b
--- fltk-1.3.0r9619/src/Fl_win32.cxx.multihead	2012-08-27 11:02:32.648542593 +0200
ceac5b
+++ fltk-1.3.0r9619/src/Fl_win32.cxx	2012-08-27 11:02:32.662542359 +0200
ceac5b
@@ -1547,19 +1547,42 @@ void Fl_Window::resize(int X,int Y,int W
ceac5b
   }
ceac5b
 }
ceac5b
 
ceac5b
-static void make_fullscreen(Fl_Window *w, Window xid, int X, int Y, int W, int H) {
ceac5b
+void Fl_X::make_fullscreen(int X, int Y, int W, int H) {
ceac5b
+  int top, bottom, left, right;
ceac5b
   int sx, sy, sw, sh;
ceac5b
-  Fl::screen_xywh(sx, sy, sw, sh, X, Y, W, H);
ceac5b
+
ceac5b
+  top = w->fullscreen_screen_top;
ceac5b
+  bottom = w->fullscreen_screen_bottom;
ceac5b
+  left = w->fullscreen_screen_left;
ceac5b
+  right = w->fullscreen_screen_right;
ceac5b
+
ceac5b
+  if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
ceac5b
+    top = Fl::screen_num(X, Y, W, H);
ceac5b
+    bottom = top;
ceac5b
+    left = top;
ceac5b
+    right = top;
ceac5b
+  }
ceac5b
+
ceac5b
+  Fl::screen_xywh(sx, sy, sw, sh, top);
ceac5b
+  Y = sy;
ceac5b
+  Fl::screen_xywh(sx, sy, sw, sh, bottom);
ceac5b
+  H = sy + sh - Y;
ceac5b
+  Fl::screen_xywh(sx, sy, sw, sh, left);
ceac5b
+  X = sx;
ceac5b
+  Fl::screen_xywh(sx, sy, sw, sh, right);
ceac5b
+  W = sx + sw - X;
ceac5b
+
ceac5b
   DWORD flags = GetWindowLong(xid, GWL_STYLE);
ceac5b
   flags = flags & ~(WS_THICKFRAME|WS_CAPTION);
ceac5b
   SetWindowLong(xid, GWL_STYLE, flags);
ceac5b
+
ceac5b
   // SWP_NOSENDCHANGING is so that we can override size limits
ceac5b
-  SetWindowPos(xid, HWND_TOP, sx, sy, sw, sh, SWP_NOSENDCHANGING | SWP_FRAMECHANGED);
ceac5b
+  SetWindowPos(xid, HWND_TOP, X, Y, W, H, SWP_NOSENDCHANGING | SWP_FRAMECHANGED);
ceac5b
 }
ceac5b
 
ceac5b
 void Fl_Window::fullscreen_x() {
ceac5b
   _set_fullscreen();
ceac5b
-  make_fullscreen(this, fl_xid(this), x(), y(), w(), h());
ceac5b
+  i->make_fullscreen(x(), y(), w(), h());
ceac5b
   Fl::handle(FL_FULLSCREEN, this);
ceac5b
 }
ceac5b
 
ceac5b
@@ -1814,8 +1837,8 @@ Fl_X* Fl_X::make(Fl_Window* w) {
ceac5b
      monitor the window was placed on. */
ceac5b
     RECT rect;
ceac5b
     GetWindowRect(x->xid, &rect);
ceac5b
-    make_fullscreen(w, x->xid, rect.left, rect.top, 
ceac5b
-                    rect.right - rect.left, rect.bottom - rect.top);
ceac5b
+    x->make_fullscreen(rect.left, rect.top, 
ceac5b
+                       rect.right - rect.left, rect.bottom - rect.top);
ceac5b
   }
ceac5b
 
ceac5b
   x->next = Fl_X::first;
ceac5b
diff -up fltk-1.3.0r9619/src/Fl_Window_fullscreen.cxx.multihead fltk-1.3.0r9619/src/Fl_Window_fullscreen.cxx
ceac5b
--- fltk-1.3.0r9619/src/Fl_Window_fullscreen.cxx.multihead	2012-03-23 17:47:53.000000000 +0100
ceac5b
+++ fltk-1.3.0r9619/src/Fl_Window_fullscreen.cxx	2012-08-27 11:02:32.662542359 +0200
ceac5b
@@ -36,6 +36,10 @@ int Fl_Window::no_fullscreen_x = 0;
ceac5b
 int Fl_Window::no_fullscreen_y = 0;
ceac5b
 int Fl_Window::no_fullscreen_w = 0;
ceac5b
 int Fl_Window::no_fullscreen_h = 0;
ceac5b
+int Fl_Window::fullscreen_screen_top = -1;
ceac5b
+int Fl_Window::fullscreen_screen_bottom = -1;
ceac5b
+int Fl_Window::fullscreen_screen_left = -1;
ceac5b
+int Fl_Window::fullscreen_screen_right = -1;
ceac5b
 #endif
ceac5b
 
ceac5b
 void Fl_Window::border(int b) {
ceac5b
@@ -95,6 +99,23 @@ void Fl_Window::fullscreen_off() {
ceac5b
   fullscreen_off(no_fullscreen_x, no_fullscreen_y, no_fullscreen_w, no_fullscreen_h);
ceac5b
 }
ceac5b
 
ceac5b
+void Fl_Window::fullscreen_screens(int top, int bottom, int left, int right) {
ceac5b
+  if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
ceac5b
+    fullscreen_screen_top = -1;
ceac5b
+    fullscreen_screen_bottom = -1;
ceac5b
+    fullscreen_screen_left = -1;
ceac5b
+    fullscreen_screen_right = -1;
ceac5b
+  } else {
ceac5b
+    fullscreen_screen_top = top;
ceac5b
+    fullscreen_screen_bottom = bottom;
ceac5b
+    fullscreen_screen_left = left;
ceac5b
+    fullscreen_screen_right = right;
ceac5b
+  }
ceac5b
+
ceac5b
+  if (shown() && (flags() & Fl_Widget::FULLSCREEN))
ceac5b
+    fullscreen_x();
ceac5b
+}
ceac5b
+
ceac5b
 
ceac5b
 //
ceac5b
 // End of "$Id: Fl_Window_fullscreen.cxx 9299 2012-03-23 16:47:53Z manolo $".
ceac5b
diff -up fltk-1.3.0r9619/src/Fl_x.cxx.multihead fltk-1.3.0r9619/src/Fl_x.cxx
ceac5b
--- fltk-1.3.0r9619/src/Fl_x.cxx.multihead	2012-08-27 11:02:32.650542559 +0200
ceac5b
+++ fltk-1.3.0r9619/src/Fl_x.cxx	2012-08-27 11:02:32.663542343 +0200
ceac5b
@@ -352,6 +352,7 @@ Atom fl_NET_WM_ICON_NAME;		// utf8 aware
ceac5b
 Atom fl_NET_SUPPORTING_WM_CHECK;
ceac5b
 Atom fl_NET_WM_STATE;
ceac5b
 Atom fl_NET_WM_STATE_FULLSCREEN;
ceac5b
+Atom fl_NET_WM_FULLSCREEN_MONITORS;
ceac5b
 Atom fl_NET_WORKAREA;
ceac5b
 Atom fl_NET_WM_ICON;
ceac5b
 
ceac5b
@@ -717,6 +718,7 @@ void fl_open_display(Display* d) {
ceac5b
   fl_NET_SUPPORTING_WM_CHECK = XInternAtom(d, "_NET_SUPPORTING_WM_CHECK", 0);
ceac5b
   fl_NET_WM_STATE       = XInternAtom(d, "_NET_WM_STATE",       0);
ceac5b
   fl_NET_WM_STATE_FULLSCREEN = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", 0);
ceac5b
+  fl_NET_WM_FULLSCREEN_MONITORS = XInternAtom(d, "_NET_WM_FULLSCREEN_MONITORS", 0);
ceac5b
   fl_NET_WORKAREA       = XInternAtom(d, "_NET_WORKAREA",       0);
ceac5b
   fl_NET_WM_ICON        = XInternAtom(d, "_NET_WM_ICON",        0);
ceac5b
 
ceac5b
@@ -1870,22 +1872,30 @@ void Fl_Window::resize(int X,int Y,int W
ceac5b
 #define _NET_WM_STATE_ADD           1  /* add/set property */
ceac5b
 #define _NET_WM_STATE_TOGGLE        2  /* toggle property  */
ceac5b
 
ceac5b
-static void send_wm_state_event(Window wnd, int add, Atom prop) {
ceac5b
+static void send_wm_event(Window wnd, Atom message,
ceac5b
+                          unsigned long d0, unsigned long d1=0,
ceac5b
+                          unsigned long d2=0, unsigned long d3=0,
ceac5b
+                          unsigned long d4=0) {
ceac5b
   XEvent e;
ceac5b
   e.xany.type = ClientMessage;
ceac5b
   e.xany.window = wnd;
ceac5b
-  e.xclient.message_type = fl_NET_WM_STATE;
ceac5b
+  e.xclient.message_type = message;
ceac5b
   e.xclient.format = 32;
ceac5b
-  e.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
ceac5b
-  e.xclient.data.l[1] = prop;
ceac5b
-  e.xclient.data.l[2] = 0;
ceac5b
-  e.xclient.data.l[3] = 0;
ceac5b
-  e.xclient.data.l[4] = 0;
ceac5b
+  e.xclient.data.l[0] = d0;
ceac5b
+  e.xclient.data.l[1] = d1;
ceac5b
+  e.xclient.data.l[2] = d2;
ceac5b
+  e.xclient.data.l[3] = d3;
ceac5b
+  e.xclient.data.l[4] = d4;
ceac5b
   XSendEvent(fl_display, RootWindow(fl_display, fl_screen),
ceac5b
              0, SubstructureNotifyMask | SubstructureRedirectMask,
ceac5b
              &e);
ceac5b
 }
ceac5b
 
ceac5b
+static void send_wm_state_event(Window wnd, int add, Atom prop) {
ceac5b
+  send_wm_event(wnd, fl_NET_WM_STATE,
ceac5b
+                add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE, prop);
ceac5b
+}
ceac5b
+
ceac5b
 int Fl_X::ewmh_supported() {
ceac5b
   static int result = -1;
ceac5b
 
ceac5b
@@ -1909,6 +1919,22 @@ int Fl_X::ewmh_supported() {
ceac5b
 /* Change an existing window to fullscreen */
ceac5b
 void Fl_Window::fullscreen_x() {
ceac5b
   if (Fl_X::ewmh_supported()) {
ceac5b
+    int top, bottom, left, right;
ceac5b
+
ceac5b
+    top = fullscreen_screen_top;
ceac5b
+    bottom = fullscreen_screen_bottom;
ceac5b
+    left = fullscreen_screen_left;
ceac5b
+    right = fullscreen_screen_right;
ceac5b
+
ceac5b
+    if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
ceac5b
+      top = Fl::screen_num(x(), y(), w(), h());
ceac5b
+      bottom = top;
ceac5b
+      left = top;
ceac5b
+      right = top;
ceac5b
+    }
ceac5b
+
ceac5b
+    send_wm_event(fl_xid(this), fl_NET_WM_FULLSCREEN_MONITORS,
ceac5b
+                  top, bottom, left, right);
ceac5b
     send_wm_state_event(fl_xid(this), 1, fl_NET_WM_STATE_FULLSCREEN);
ceac5b
   } else {
ceac5b
     _set_fullscreen();
ceac5b
@@ -1995,7 +2021,7 @@ void Fl_X::make_xid(Fl_Window* win, XVis
ceac5b
     // force the window to be on-screen.  Usually the X window manager
ceac5b
     // does this, but a few don't, so we do it here for consistency:
ceac5b
     int scr_x, scr_y, scr_w, scr_h;
ceac5b
-    Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h, X, Y);
ceac5b
+    Fl::screen_xywh(scr_x, scr_y, scr_w, scr_h, X, Y, W, H);
ceac5b
 
ceac5b
     if (win->border()) {
ceac5b
       // ensure border is on screen:
ceac5b
@@ -2024,6 +2050,23 @@ void Fl_X::make_xid(Fl_Window* win, XVis
ceac5b
     return;
ceac5b
   }
ceac5b
 
ceac5b
+  // Compute which screen(s) we should be on if we want to go fullscreen
ceac5b
+  int fullscreen_top, fullscreen_bottom, fullscreen_left, fullscreen_right;
ceac5b
+
ceac5b
+  fullscreen_top = win->fullscreen_screen_top;
ceac5b
+  fullscreen_bottom = win->fullscreen_screen_bottom;
ceac5b
+  fullscreen_left = win->fullscreen_screen_left;
ceac5b
+  fullscreen_right = win->fullscreen_screen_right;
ceac5b
+
ceac5b
+  if ((fullscreen_top < 0) || (fullscreen_bottom < 0) ||
ceac5b
+      (fullscreen_left < 0) || (fullscreen_right < 0)) {
ceac5b
+    fullscreen_top = Fl::screen_num(X, Y, W, H);
ceac5b
+    fullscreen_bottom = fullscreen_top;
ceac5b
+    fullscreen_left = fullscreen_top;
ceac5b
+    fullscreen_right = fullscreen_top;
ceac5b
+  }
ceac5b
+
ceac5b
+
ceac5b
   ulong root = win->parent() ?
ceac5b
     fl_xid(win->window()) : RootWindow(fl_display, fl_screen);
ceac5b
 
ceac5b
@@ -2047,9 +2090,17 @@ void Fl_X::make_xid(Fl_Window* win, XVis
ceac5b
   // border, and cannot grab without an existing window. Besides, 
ceac5b
   // there is no clear_override(). 
ceac5b
   if (win->flags() & Fl_Widget::FULLSCREEN && !Fl_X::ewmh_supported()) {
ceac5b
+    int sx, sy, sw, sh;
ceac5b
     attr.override_redirect = 1;
ceac5b
     mask |= CWOverrideRedirect;
ceac5b
-    Fl::screen_xywh(X, Y, W, H, X, Y, W, H);
ceac5b
+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_left);
ceac5b
+    X = sx;
ceac5b
+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_right);
ceac5b
+    W = sx + sw - X;
ceac5b
+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_top);
ceac5b
+    Y = sy;
ceac5b
+    Fl::screen_xywh(sx, sy, sw, sh, fullscreen_bottom);
ceac5b
+    H = sy + sh - Y;
ceac5b
   }
ceac5b
 
ceac5b
   if (fl_background_pixel >= 0) {
ceac5b
@@ -2120,6 +2171,13 @@ void Fl_X::make_xid(Fl_Window* win, XVis
ceac5b
 
ceac5b
     // If asked for, create fullscreen
ceac5b
     if (win->flags() & Fl_Widget::FULLSCREEN && Fl_X::ewmh_supported()) {
ceac5b
+      unsigned long data[4];
ceac5b
+      data[0] = fullscreen_top;
ceac5b
+      data[1] = fullscreen_bottom;
ceac5b
+      data[2] = fullscreen_left;
ceac5b
+      data[3] = fullscreen_right;
ceac5b
+      XChangeProperty (fl_display, xp->xid, fl_NET_WM_FULLSCREEN_MONITORS, XA_ATOM, 32,
ceac5b
+                       PropModeReplace, (unsigned char*) data, 4);
ceac5b
       XChangeProperty (fl_display, xp->xid, fl_NET_WM_STATE, XA_ATOM, 32,
ceac5b
                        PropModeAppend, (unsigned char*) &fl_NET_WM_STATE_FULLSCREEN, 1);
ceac5b
     }
ceac5b
diff -up fltk-1.3.0r9619/test/fullscreen.cxx.multihead fltk-1.3.0r9619/test/fullscreen.cxx
ceac5b
--- fltk-1.3.0r9619/test/fullscreen.cxx.multihead	2012-06-14 17:09:46.000000000 +0200
ceac5b
+++ fltk-1.3.0r9619/test/fullscreen.cxx	2012-08-27 11:02:32.664542326 +0200
ceac5b
@@ -127,7 +127,7 @@ class fullscreen_window : public Fl_Sing
ceac5b
   fullscreen_window(int W, int H, const char *t=0);
ceac5b
   int handle (int e);
ceac5b
   Fl_Toggle_Light_Button *b3;
ceac5b
-
ceac5b
+  Fl_Toggle_Light_Button *b4;
ceac5b
 };
ceac5b
 
ceac5b
 fullscreen_window::fullscreen_window(int W, int H, const char *t) : Fl_Single_Window(W, H, t) { 
ceac5b
@@ -170,23 +170,54 @@ void border_cb(Fl_Widget *o, void *p) {
ceac5b
 #endif
ceac5b
 }
ceac5b
 
ceac5b
-int px,py,pw,ph;
ceac5b
 Fl_Button *border_button;
ceac5b
 void fullscreen_cb(Fl_Widget *o, void *p) {
ceac5b
   Fl_Window *w = (Fl_Window *)p;
ceac5b
   int d = ((Fl_Button *)o)->value();
ceac5b
   if (d) {
ceac5b
-    px = w->x();
ceac5b
-    py = w->y();
ceac5b
-    pw = w->w();
ceac5b
-    ph = w->h();
ceac5b
+    if (((fullscreen_window*)w)->b4->value()) {
ceac5b
+      int top, bottom, left, right;
ceac5b
+      int top_y, bottom_y, left_x, right_x;
ceac5b
+
ceac5b
+      int sx, sy, sw, sh;
ceac5b
+
ceac5b
+      top = bottom = left = right = 0;
ceac5b
+
ceac5b
+      Fl::screen_xywh(sx, sy, sw, sh, 0);
ceac5b
+      top_y = sy;
ceac5b
+      bottom_y = sy + sh;
ceac5b
+      left_x = sx;
ceac5b
+      right_x = sx + sw;
ceac5b
+
ceac5b
+      for (int i = 1;i < Fl::screen_count();i++) {
ceac5b
+        Fl::screen_xywh(sx, sy, sw, sh, i);
ceac5b
+        if (sy < top_y) {
ceac5b
+          top = i;
ceac5b
+          top_y = sy;
ceac5b
+        }
ceac5b
+        if ((sy + sh) > bottom_y) {
ceac5b
+          bottom = i;
ceac5b
+          bottom_y = sy + sh;
ceac5b
+        }
ceac5b
+        if (sx < left_x) {
ceac5b
+          left = i;
ceac5b
+          left_x = sx;
ceac5b
+        }
ceac5b
+        if ((sx + sw) > right_x) {
ceac5b
+          right = i;
ceac5b
+          right_x = sx + sw;
ceac5b
+        }
ceac5b
+      }
ceac5b
+
ceac5b
+      w->fullscreen_screens(top, bottom, left, right);
ceac5b
+    } else {
ceac5b
+      w->fullscreen_screens(-1, -1, -1, -1);
ceac5b
+    }
ceac5b
     w->fullscreen();
ceac5b
-    w->override();
ceac5b
 #ifndef WIN32 // update our border state in case border was turned off
ceac5b
     border_button->value(w->border());
ceac5b
 #endif
ceac5b
   } else {
ceac5b
-    //w->fullscreen_off(px,py,pw,ph);
ceac5b
     w->fullscreen_off();
ceac5b
   }
ceac5b
 }
ceac5b
@@ -219,7 +250,7 @@ void exit_cb(Fl_Widget *, void *) {
ceac5b
   exit(0);
ceac5b
 }
ceac5b
 
ceac5b
-#define NUMB 7
ceac5b
+#define NUMB 8
ceac5b
 
ceac5b
 int twowindow = 0;
ceac5b
 int initfull = 0;
ceac5b
@@ -284,6 +315,9 @@ int main(int argc, char **argv) {
ceac5b
   window.b3->callback(fullscreen_cb,w);
ceac5b
   y+=30;
ceac5b
 
ceac5b
+  window.b4 = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"All Screens");
ceac5b
+  y+=30;
ceac5b
+
ceac5b
   Fl_Button eb(50,y,window.w()-60,30,"Exit");
ceac5b
   eb.callback(exit_cb);
ceac5b
   y+=30;