diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-25 09:21:27 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-25 09:21:44 +0100 |
| commit | d7985607d6dd8308f104d84c778080731fa23c9a (patch) | |
| tree | ca5fec95303f861e782d0ae7f5a0b12d72fdf2e0 | |
| parent | c70a091fa3bfbaa4e28d456a3dac7214217aa206 (diff) | |
Fix for issue #123 - X11 platform
As discussed, only the window position becomes rounded to nearest integer value
when a fractional GUI scale factor is applied.
| -rw-r--r-- | src/Fl_x.cxx | 12 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.cxx | 7 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 332a2aa3e..3229a8154 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -2186,9 +2186,9 @@ int fl_handle(const XEvent& thisevent) #if USE_XFT if (!Fl_X11_Window_Driver::data_for_resize_window_between_screens_.busy && ( ceil(W/s) != window->w() || ceil(H/s) != window->h() ) ) { - window->resize(X/s, Y/s, ceil(W/s), ceil(H/s)); + window->resize(rint(X/s), rint(Y/s), ceil(W/s), ceil(H/s)); } else { - window->position(X/s, Y/s); + window->position(rint(X/s), rint(Y/s)); } #else window->resize(X, Y, W, H); @@ -2220,7 +2220,7 @@ int fl_handle(const XEvent& thisevent) #else float s = 1; #endif - window->position(xpos/s, ypos/s); + window->position(rint(xpos/s), rint(ypos/s)); } break; } @@ -2273,12 +2273,12 @@ void Fl_X11_Window_Driver::resize(int X,int Y,int W,int H) { if (is_a_resize) { if (!pWindow->resizable()) pWindow->size_range(w(), h(), w(), h()); if (is_a_move) { - XMoveResizeWindow(fl_display, fl_xid(pWindow), X*s, Y*s, W>0 ? W*s : 1, H>0 ? H*s : 1); + XMoveResizeWindow(fl_display, fl_xid(pWindow), rint(X*s), rint(Y*s), W>0 ? W*s : 1, H>0 ? H*s : 1); } else { XResizeWindow(fl_display, fl_xid(pWindow), W>0 ? W*s : 1, H>0 ? H*s : 1); } } else - XMoveWindow(fl_display, fl_xid(pWindow), X*s, Y*s); + XMoveWindow(fl_display, fl_xid(pWindow), rint(X*s), rint(Y*s)); } } @@ -2586,7 +2586,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap) Fl_X* xp = set_xid(win, XCreateWindow(fl_display, root, - X*s, Y*s, W*s, H*s, + rint(X*s), rint(Y*s), W*s, H*s, 0, // borderwidth visual->depth, InputOutput, diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 914104769..90a838126 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -793,8 +793,11 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int XTranslateCoordinates(fl_display, xid, RootWindow(fl_display, fl_screen), Xs, Ys, &dx, &dy, &child_win); // screen dimensions - Fl::screen_xywh(sx, sy, sw, sh, Fl_Window_Driver::driver(win)->screen_num()); - sx *= s; sy *= s; sw *= s; sh *= s; + int ns = Fl_Window_Driver::driver(win)->screen_num(); + sx = screens[ns].x_org; + sy = screens[ns].y_org; + sw = screens[ns].width; + sh = screens[ns].height; } if (win && !allow_outside && int(s) != s) { ws = (w+1) * s; // matches what Fl_Graphics_Driver::cache_size() does |
