|
commit d7985607d6dd8308f104d84c778080731fa23c9a
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Nov 25 09:21:27 2020 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Nov 25 09:21:44 2020 +0100
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.
src/Fl_x.cxx | 12 ++++++------
src/drivers/X11/Fl_X11_Screen_Driver.cxx | 7 +++++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git src/Fl_x.cxx src/Fl_x.cxx
index 332a2aa..3229a81 100644
--- src/Fl_x.cxx
+++ 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 src/drivers/X11/Fl_X11_Screen_Driver.cxx src/drivers/X11/Fl_X11_Screen_Driver.cxx
index 9141047..90a8381 100644
--- src/drivers/X11/Fl_X11_Screen_Driver.cxx
+++ 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
[ Direct Link to Message ] | |