diff options
| author | Manolo Gouy <Manolo> | 2017-06-19 17:30:03 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-06-19 17:30:03 +0000 |
| commit | fa3d8c6259c0326df980f0347a23b68d0620ea92 (patch) | |
| tree | 79b22579bc305118471b1af54b6d588a9340df5a | |
| parent | cd1fd95f056c726cfd6417f29d5bce00c43b8253 (diff) | |
HiDPI support under WIN32: fix bugs with tile demo and with fullscreen demo.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12268 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_win32.cxx | 20 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx | 14 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index d54504c03..1c62c56ad 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -1676,22 +1676,22 @@ void Fl_WinAPI_Window_Driver::resize(int X,int Y,int W,int H) { if (resize_from_program && shown()) { if (!pWindow->resizable()) pWindow->size_range(w(), h(), w(), h()); int dummy_x, dummy_y, bt, bx, by; - //Ignore window managing when resizing, so that windows (and more + // compute window position and size in scaled units float s = Fl::screen_driver()->scale(screen_num()); - X *= s; Y *= s; W *= s; H *= s; + int scaledX = ceil(X*s), scaledY= ceil(Y*s), scaledW = ceil(W*s), scaledH = ceil(H*s); + //Ignore window managing when resizing, so that windows (and more //specifically menus) can be moved offscreen. if (fake_X_wm(dummy_x, dummy_y, bt, bx, by)) { - X -= bx; - Y -= by+bt; - W += 2*bx; - H += 2*by+bt; + scaledX -= bx; + scaledY -= by+bt; + scaledW += 2*bx; + scaledH += 2*by+bt; } // avoid zero size windows. A zero sized window on Win32 // will cause continouly new redraw events. - if (W<=0) W = 1; - if (H<=0) H = 1; - SetWindowPos(fl_xid(pWindow), 0, X, Y, W, H, flags); -//fprintf(LOG,"parent=%p bt=%d X=%d W=%d H=%d s=%f\n",pWindow->parent(),bt,int(X),int(W),int(H),s);fflush(LOG); + if (scaledW<=0) scaledW = 1; + if (scaledH<=0) scaledH = 1; + SetWindowPos(fl_xid(pWindow), 0, scaledX, scaledY, scaledW, scaledH, flags); } } diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx index 14a66be1f..9eb7705bc 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx @@ -29,6 +29,7 @@ #include "Fl_WinAPI_Window_Driver.H" #include "Fl_WinAPI_Screen_Driver.H" #include <windows.h> +#include <math.h> // for ceil() #if USE_COLORMAP extern HPALETTE fl_select_palette(void); // in fl_color_win32.cxx @@ -561,16 +562,19 @@ void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) { break; } Fl_X::i(pWindow)->xid = xid; + // compute window position and size in scaled units + float s = Fl::screen_driver()->scale(screen_num()); + int scaledX = ceil(X*s), scaledY= ceil(Y*s), scaledW = ceil(W*s), scaledH = ceil(H*s); // Adjust for decorations (but not if that puts the decorations // outside the screen) if ((X != x()) || (Y != y())) { - X -= bx; - Y -= by+bt; + scaledX -= bx; + scaledY -= by+bt; } - W += bx*2; - H += by*2+bt; + scaledW += bx*2; + scaledH += by*2+bt; SetWindowLong(fl_xid(pWindow), GWL_STYLE, style); - SetWindowPos(fl_xid(pWindow), 0, X, Y, W, H, + SetWindowPos(fl_xid(pWindow), 0, scaledX, scaledY, scaledW, scaledH, SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); Fl::handle(FL_FULLSCREEN, pWindow); } |
