blob: 9e62a9d7f921e87459dc20ece6c6be3e4fdbc8da [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
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
43void 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
DRC685f17e2011-07-28 09:23:00 +000063void fullscreen_x(Fl_Window *w);
64void fullscreen_off_x();
65void fullscreen_off_x(Fl_Window *w, int X, int Y, int W, int H);
66
67/* Note: The previous implementation toggled border(). With this new
68 implementation this is not necessary. Additionally, if we do that,
69 the application may lose focus when switching out of fullscreen
70 mode with some window managers. Besides, the API does not say that
71 the FLTK border state should be toggled; it only says that the
72 borders should not be *visible*.
73*/
DRC2ff39b82011-07-28 08:38:59 +000074void Fl_Window::fullscreen() {
DRC685f17e2011-07-28 09:23:00 +000075 if (shown() && !(flags() & Fl_Widget::FULLSCREEN)) {
76 no_fullscreen_x = x();
77 no_fullscreen_y = y();
78 no_fullscreen_w = w();
79 no_fullscreen_h = h();
80 fullscreen_x(this);
81 } else {
82 set_flag(FULLSCREEN);
DRC2ff39b82011-07-28 08:38:59 +000083 }
DRC2ff39b82011-07-28 08:38:59 +000084}
85
86void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
DRC685f17e2011-07-28 09:23:00 +000087 if (shown() && (flags() & Fl_Widget::FULLSCREEN)) {
88 fullscreen_off_x(this, X, Y, W, H);
89 } else {
90 clear_flag(FULLSCREEN);
91 }
92 no_fullscreen_x = no_fullscreen_y = no_fullscreen_w = no_fullscreen_h = 0;
DRC2ff39b82011-07-28 08:38:59 +000093}
94
DRC685f17e2011-07-28 09:23:00 +000095void Fl_Window::fullscreen_off() {
96 if (!no_fullscreen_x && !no_fullscreen_y) {
97 // Window was initially created fullscreen - default to current monitor
98 no_fullscreen_x = x();
99 no_fullscreen_y = y();
100 }
101 fullscreen_off(no_fullscreen_x, no_fullscreen_y, no_fullscreen_w, no_fullscreen_h);
102}
103
104
DRC2ff39b82011-07-28 08:38:59 +0000105//
106// End of "$Id: Fl_Window_fullscreen.cxx 8515 2011-03-12 21:36:21Z manolo $".
107//