From eee5c5800c495efbb4208308666ee2fd2d055a1b Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 5 May 2018 10:22:55 +0000 Subject: Fix Fl_X11_Screen_Driver::read_win_rectangle() when GUI is scaled. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12898 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/X11/Fl_X11_Screen_Driver.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 4b454973a..d79d31307 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -786,14 +786,7 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int # endif // __sgi float s = Fl_Surface_Device::surface()->driver()->scale(); - int ws, hs; - if (int(s) == s) { ws = w * s; hs = h * s;} - else { - ws = (w+1)*s-1; - hs = (h+1)*s-1; - if (ws < 1) ws = 1; - if (hs < 1) hs = 1; - } + int ws = w * s, hs = h * s; if (!image) { // fetch absolute coordinates @@ -810,6 +803,14 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int // screen dimensions Fl::screen_xywh(sx, sy, sw, sh, win->driver()->screen_num()); } + if (win && !allow_outside && int(s) != s) { + ws = (w+1)*s-1; + hs = (h+1)*s-1; + if (int(X*s) + ws >= win->w()*s) ws = win->w()*s - int(X*s) -1; + if (int(Y*s) + hs >= win->h()*s) hs = win->h()*s - int(Y*s) -1; + } + if (ws < 1) ws = 1; + if (hs < 1) hs = 1; if (!win || (dx >= sx && dy >= sy && dxs + ws <= (sx+sw)*s && dys + hs <= (sy+sh)*s) ) { // the image is fully contained, we can use the traditional method // however, if the window is obscured etc. the function will still fail. Make sure we -- cgit v1.2.3