1 //
2 // "$Id: Fl_Window_fullscreen.cxx 5190 2006-06-09 16:16:34Z mike $"
3 //
4 // Fullscreen window support for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2005 by Bill Spitzak and others.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21 // USA.
22 //
23 // Please report all bugs and problems on the following page:
24 //
25 //     http://www.fltk.org/str.php
26 //
27 
28 // Turning the border on/off by changing the motif_wm_hints property
29 // works on Irix 4DWM.  Does not appear to work for any other window
30 // manager.  Fullscreen still works on some window managers (fvwm is one)
31 // because they allow the border to be placed off-screen.
32 
33 // Unfortunatly most X window managers ignore changes to the border
34 // and refuse to position the border off-screen, so attempting to make
35 // the window full screen will lose the size of the border off the
36 // bottom and right.
37 
38 #include <FL/Fl.H>
39 #include <FL/x.H>
40 
41 #ifdef __APPLE__
42 #include <config.h>
43 #endif
44 
border(int b)45 void Fl_Window::border(int b) {
46   if (b) {
47     if (border()) return;
48     clear_flag(FL_NOBORDER);
49   } else {
50     if (!border()) return;
51     set_flag(FL_NOBORDER);
52   }
53 #ifdef WIN32
54   // not yet implemented, but it's possible
55   // for full fullscreen we have to make the window topmost as well
56 #elif defined(__APPLE_QD__)
57   // warning: not implemented in Quickdraw/Carbon
58 #elif defined(__APPLE_QUARTZ__)
59   // warning: not implemented in Quartz/Carbon
60 #else
61   if (shown()) Fl_X::i(this)->sendxjunk();
62 #endif
63 }
64 
fullscreen()65 void Fl_Window::fullscreen() {
66 #ifndef WIN32
67   //this would clobber the fake wm, since it relies on the border flags to
68   //determine its thickness
69   border(0);
70 #endif
71 #if defined(__APPLE__) || defined(WIN32)
72   int sx, sy, sw, sh;
73   Fl::screen_xywh(sx, sy, sw, sh, x()+w()/2, y()+h()/2);
74   // if we are on the main screen, we will leave the system menu bar unobstructed
75   if (Fl::x()>=sx && Fl::y()>=sy && Fl::x()+Fl::w()<=sx+sw && Fl::y()+Fl::h()<=sy+sh) {
76     sx = Fl::x(); sy = Fl::y();
77     sw = Fl::w(); sh = Fl::h();
78   }
79   if (x()==sx) x(sx+1); // make sure that we actually execute the resize
80   resize(sx, sy, sw, sh);
81 #else
82   if (!x()) x(1); // force it to call XResizeWindow()
83   resize(0,0,Fl::w(),Fl::h());
84 #endif
85 }
86 
fullscreen_off(int X,int Y,int W,int H)87 void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
88   // this order produces less blinking on IRIX:
89   resize(X,Y,W,H);
90 #ifndef WIN32
91   border(1);
92 #endif
93 }
94 
95 //
96 // End of "$Id: Fl_Window_fullscreen.cxx 5190 2006-06-09 16:16:34Z mike $".
97 //
98