mirror of
https://github.com/fltk/fltk.git
synced 2026-06-04 15:32:12 +08:00
Support for full screen over multiple monitors.
The API follows that of EWMH, which gives you a good control over which monitors to use. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+49
-9
@@ -127,7 +127,7 @@ class fullscreen_window : public Fl_Single_Window {
|
||||
fullscreen_window(int W, int H, const char *t=0);
|
||||
int handle (int e);
|
||||
Fl_Toggle_Light_Button *b3;
|
||||
|
||||
Fl_Toggle_Light_Button *b4;
|
||||
};
|
||||
|
||||
fullscreen_window::fullscreen_window(int W, int H, const char *t) : Fl_Single_Window(W, H, t) {
|
||||
@@ -170,27 +170,63 @@ void border_cb(Fl_Widget *o, void *p) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int px,py,pw,ph;
|
||||
Fl_Button *border_button;
|
||||
void fullscreen_cb(Fl_Widget *o, void *p) {
|
||||
Fl_Window *w = (Fl_Window *)p;
|
||||
int d = ((Fl_Button *)o)->value();
|
||||
if (d) {
|
||||
px = w->x();
|
||||
py = w->y();
|
||||
pw = w->w();
|
||||
ph = w->h();
|
||||
w->fullscreen();
|
||||
w->override();
|
||||
#ifndef WIN32 // update our border state in case border was turned off
|
||||
border_button->value(w->border());
|
||||
#endif
|
||||
} else {
|
||||
//w->fullscreen_off(px,py,pw,ph);
|
||||
w->fullscreen_off();
|
||||
}
|
||||
}
|
||||
|
||||
void allscreens_cb(Fl_Widget *o, void *p) {
|
||||
Fl_Window *w = (Fl_Window *)p;
|
||||
int d = ((Fl_Button *)o)->value();
|
||||
if (d) {
|
||||
int top, bottom, left, right;
|
||||
int top_y, bottom_y, left_x, right_x;
|
||||
|
||||
int sx, sy, sw, sh;
|
||||
|
||||
top = bottom = left = right = 0;
|
||||
|
||||
Fl::screen_xywh(sx, sy, sw, sh, 0);
|
||||
top_y = sy;
|
||||
bottom_y = sy + sh;
|
||||
left_x = sx;
|
||||
right_x = sx + sw;
|
||||
|
||||
for (int i = 1;i < Fl::screen_count();i++) {
|
||||
Fl::screen_xywh(sx, sy, sw, sh, i);
|
||||
if (sy < top_y) {
|
||||
top = i;
|
||||
top_y = sy;
|
||||
}
|
||||
if ((sy + sh) > bottom_y) {
|
||||
bottom = i;
|
||||
bottom_y = sy + sh;
|
||||
}
|
||||
if (sx < left_x) {
|
||||
left = i;
|
||||
left_x = sx;
|
||||
}
|
||||
if ((sx + sw) > right_x) {
|
||||
right = i;
|
||||
right_x = sx + sw;
|
||||
}
|
||||
}
|
||||
|
||||
w->fullscreen_screens(top, bottom, left, right);
|
||||
} else {
|
||||
w->fullscreen_screens(-1, -1, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void update_screeninfo(Fl_Widget *b, void *p) {
|
||||
Fl_Browser *browser = (Fl_Browser *)p;
|
||||
int x, y, w, h;
|
||||
@@ -219,7 +255,7 @@ void exit_cb(Fl_Widget *, void *) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define NUMB 7
|
||||
#define NUMB 8
|
||||
|
||||
int twowindow = 0;
|
||||
int initfull = 0;
|
||||
@@ -284,6 +320,10 @@ int main(int argc, char **argv) {
|
||||
window.b3->callback(fullscreen_cb,w);
|
||||
y+=30;
|
||||
|
||||
window.b4 = new Fl_Toggle_Light_Button(50,y,window.w()-60,30,"All Screens");
|
||||
window.b4->callback(allscreens_cb,w);
|
||||
y+=30;
|
||||
|
||||
Fl_Button eb(50,y,window.w()-60,30,"Exit");
|
||||
eb.callback(exit_cb);
|
||||
y+=30;
|
||||
|
||||
Reference in New Issue
Block a user