You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.1KB

  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. // Turning the border on/off by changing the motif_wm_hints property
  28. // works on Irix 4DWM. Does not appear to work for any other window
  29. // manager. Fullscreen still works on some window managers (fvwm is one)
  30. // because they allow the border to be placed off-screen.
  31. // Unfortunately most X window managers ignore changes to the border
  32. // and refuse to position the border off-screen, so attempting to make
  33. // the window full screen will lose the size of the border off the
  34. // bottom and right.
  35. #include <FL/Fl.H>
  36. #include <FL/x.H>
  37. #include <config.h>
  38. void Fl_Window::border(int b) {
  39. if (b) {
  40. if (border()) return;
  41. clear_flag(NOBORDER);
  42. } else {
  43. if (!border()) return;
  44. set_flag(NOBORDER);
  45. }
  46. #if defined(USE_X11)
  47. if (shown()) Fl_X::i(this)->sendxjunk();
  48. #elif defined(WIN32)
  49. // not yet implemented, but it's possible
  50. // for full fullscreen we have to make the window topmost as well
  51. #elif defined(__APPLE_QUARTZ__)
  52. // warning: not implemented in Quartz/Carbon
  53. #else
  54. # error unsupported platform
  55. #endif
  56. }
  57. void Fl_Window::fullscreen() {
  58. #ifndef WIN32
  59. //this would clobber the fake wm, since it relies on the border flags to
  60. //determine its thickness
  61. border(0);
  62. #endif
  63. #if defined(__APPLE__) || defined(WIN32) || defined(USE_X11)
  64. int sx, sy, sw, sh;
  65. Fl::screen_xywh(sx, sy, sw, sh, x(), y(), w(), h());
  66. // if we are on the main screen, we will leave the system menu bar unobstructed
  67. if (Fl::x()>=sx && Fl::y()>=sy && Fl::x()+Fl::w()<=sx+sw && Fl::y()+Fl::h()<=sy+sh) {
  68. sx = Fl::x(); sy = Fl::y();
  69. sw = Fl::w(); sh = Fl::h();
  70. }
  71. if (x()==sx) x(sx+1); // make sure that we actually execute the resize
  72. #if defined(USE_X11)
  73. resize(0, 0, w(), h()); // work around some quirks in X11
  74. #endif
  75. resize(sx, sy, sw, sh);
  76. #else
  77. if (!x()) x(1); // make sure that we actually execute the resize
  78. resize(0,0,Fl::w(),Fl::h());
  79. #endif
  80. }
  81. void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
  82. // this order produces less blinking on IRIX:
  83. resize(X,Y,W,H);
  84. #ifndef WIN32
  85. border(1);
  86. #endif
  87. }
  88. //
  89. // End of "$Id: Fl_Window_fullscreen.cxx 8515 2011-03-12 21:36:21Z manolo $".
  90. //