DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame^] | 1 | // |
| 2 | // "$Id: Fl_Window_fullscreen.cxx 8515 2011-03-12 21:36:21Z manolo $" |
| 3 | // |
| 4 | // Fullscreen window support for the Fast Light Tool Kit (FLTK). |
| 5 | // |
| 6 | // Copyright 1998-2010 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 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 | // Unfortunately 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 | #include <config.h> |
| 42 | |
| 43 | void Fl_Window::border(int b) { |
| 44 | if (b) { |
| 45 | if (border()) return; |
| 46 | clear_flag(NOBORDER); |
| 47 | } else { |
| 48 | if (!border()) return; |
| 49 | set_flag(NOBORDER); |
| 50 | } |
| 51 | #if defined(USE_X11) |
| 52 | if (shown()) Fl_X::i(this)->sendxjunk(); |
| 53 | #elif defined(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_QUARTZ__) |
| 57 | // warning: not implemented in Quartz/Carbon |
| 58 | #else |
| 59 | # error unsupported platform |
| 60 | #endif |
| 61 | } |
| 62 | |
| 63 | void Fl_Window::fullscreen() { |
| 64 | #ifndef WIN32 |
| 65 | //this would clobber the fake wm, since it relies on the border flags to |
| 66 | //determine its thickness |
| 67 | border(0); |
| 68 | #endif |
| 69 | #if defined(__APPLE__) || defined(WIN32) || defined(USE_X11) |
| 70 | int sx, sy, sw, sh; |
| 71 | Fl::screen_xywh(sx, sy, sw, sh, x(), y(), w(), h()); |
| 72 | // if we are on the main screen, we will leave the system menu bar unobstructed |
| 73 | if (Fl::x()>=sx && Fl::y()>=sy && Fl::x()+Fl::w()<=sx+sw && Fl::y()+Fl::h()<=sy+sh) { |
| 74 | sx = Fl::x(); sy = Fl::y(); |
| 75 | sw = Fl::w(); sh = Fl::h(); |
| 76 | } |
| 77 | if (x()==sx) x(sx+1); // make sure that we actually execute the resize |
| 78 | #if defined(USE_X11) |
| 79 | resize(0, 0, w(), h()); // work around some quirks in X11 |
| 80 | #endif |
| 81 | resize(sx, sy, sw, sh); |
| 82 | #else |
| 83 | if (!x()) x(1); // make sure that we actually execute the resize |
| 84 | resize(0,0,Fl::w(),Fl::h()); |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | void Fl_Window::fullscreen_off(int X,int Y,int W,int H) { |
| 89 | // this order produces less blinking on IRIX: |
| 90 | resize(X,Y,W,H); |
| 91 | #ifndef WIN32 |
| 92 | border(1); |
| 93 | #endif |
| 94 | } |
| 95 | |
| 96 | // |
| 97 | // End of "$Id: Fl_Window_fullscreen.cxx 8515 2011-03-12 21:36:21Z manolo $". |
| 98 | // |