diff options
| author | Manolo Gouy <Manolo> | 2012-03-23 16:47:53 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2012-03-23 16:47:53 +0000 |
| commit | 08ce2e07d379d6b9925208b5da9323f948b634db (patch) | |
| tree | cff1ab07cf0952cec8c1cf874ba9bcc7b241a041 /src/Fl_win32.cxx | |
| parent | 8cd98f5236618f8ab9d576e709308b43246bc7ac (diff) | |
Fix STR#2641: true fullscreen windows that cover all their screen including menu bar, task bar, dock.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9299 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_win32.cxx')
| -rw-r--r-- | src/Fl_win32.cxx | 89 |
1 files changed, 83 insertions, 6 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 531a7ab76..5530e76f0 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1315,6 +1315,11 @@ int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by) X+=xoff; Y+=yoff; + if (w->flags() & Fl_Widget::FULLSCREEN) { + X = Y = 0; + bx = by = bt = 0; + } + return ret; } @@ -1365,6 +1370,58 @@ void Fl_Window::resize(int X,int Y,int W,int H) { } } +static void make_fullscreen(Fl_Window *w, Window xid, int X, int Y, int W, int H) { + int sx, sy, sw, sh; + Fl::screen_xywh(sx, sy, sw, sh, X, Y, W, H); + DWORD flags = GetWindowLong(xid, GWL_STYLE); + flags = flags & ~(WS_THICKFRAME|WS_CAPTION); + SetWindowLong(xid, GWL_STYLE, flags); + // SWP_NOSENDCHANGING is so that we can override size limits + SetWindowPos(xid, HWND_TOP, sx, sy, sw, sh, SWP_NOSENDCHANGING | SWP_FRAMECHANGED); +} + +void Fl_Window::fullscreen_x() { + _set_fullscreen(); + make_fullscreen(this, fl_xid(this), x(), y(), w(), h()); + Fl::handle(FL_FULLSCREEN, this); +} + +void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) { + _clear_fullscreen(); + DWORD style = GetWindowLong(fl_xid(this), GWL_STYLE); + // Remove the xid temporarily so that Fl_X::fake_X_wm() behaves like it + // does in Fl_X::make(). + HWND xid = fl_xid(this); + Fl_X::i(this)->xid = NULL; + int wx, wy, bt, bx, by; + switch (Fl_X::fake_X_wm(this, wx, wy, bt, bx, by)) { + case 0: + break; + case 1: + style |= WS_CAPTION; + break; + case 2: + if (border()) { + style |= WS_THICKFRAME | WS_CAPTION; + } + break; + } + Fl_X::i(this)->xid = xid; + // Adjust for decorations (but not if that puts the decorations + // outside the screen) + if ((X != x()) || (Y != y())) { + X -= bx; + Y -= by+bt; + } + W += bx*2; + H += by*2+bt; + SetWindowLong(fl_xid(this), GWL_STYLE, style); + SetWindowPos(fl_xid(this), 0, X, Y, W, H, + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); + Fl::handle(FL_FULLSCREEN, this); +} + + //////////////////////////////////////////////////////////////// /* @@ -1494,18 +1551,26 @@ Fl_X* Fl_X::make(Fl_Window* w) { int xwm = xp , ywm = yp , bt, bx, by; switch (fake_X_wm(w, xwm, ywm, bt, bx, by)) { // No border (used for menus) - case 0: style |= WS_POPUP; - styleEx |= WS_EX_TOOLWINDOW; + case 0: + style |= WS_POPUP; + styleEx |= WS_EX_TOOLWINDOW; break; // Thin border and title bar - case 1: style |= WS_DLGFRAME | WS_CAPTION; break; + case 1: + style |= WS_DLGFRAME | WS_CAPTION; + if (!w->modal()) + style |= WS_SYSMENU | WS_MINIMIZEBOX; + break; // Thick, resizable border and title bar, with maximize button - case 2: style |= WS_THICKFRAME | WS_MAXIMIZEBOX | WS_CAPTION ; break; + case 2: + style |= WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_CAPTION; + if (!w->modal()) + style |= WS_MINIMIZEBOX; + break; } if (by+bt) { - if (!w->modal()) style |= WS_SYSMENU | WS_MINIMIZEBOX; wp += 2*bx; hp += 2*by+bt; } @@ -1561,6 +1626,18 @@ Fl_X* Fl_X::make(Fl_Window* w) { ); if (lab) free(lab); + if (w->flags() & Fl_Widget::FULLSCREEN) { + /* We need to make sure that the fullscreen is created on the + default monitor, ie the desktop where the shortcut is located + etc. This requires that CreateWindow is called with CW_USEDEFAULT + for x and y. We can then use GetWindowRect to determine which + monitor the window was placed on. */ + RECT rect; + GetWindowRect(x->xid, &rect); + make_fullscreen(w, x->xid, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top); + } + x->next = Fl_X::first; Fl_X::first = x; @@ -1576,7 +1653,7 @@ Fl_X* Fl_X::make(Fl_Window* w) { // If we've captured the mouse, we dont want to activate any // other windows from the code, or we lose the capture. ShowWindow(x->xid, !showit ? SW_SHOWMINNOACTIVE : - (Fl::grab() || (style & WS_POPUP)) ? SW_SHOWNOACTIVATE : SW_SHOWNORMAL); + (Fl::grab() || (styleEx & WS_EX_TOOLWINDOW)) ? SW_SHOWNOACTIVATE : SW_SHOWNORMAL); // Register all windows for potential drag'n'drop operations fl_OleInitialize(); |
