summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-05-05 10:22:55 +0000
committerManolo Gouy <Manolo>2018-05-05 10:22:55 +0000
commiteee5c5800c495efbb4208308666ee2fd2d055a1b (patch)
tree79946608f25f19d493f2255334eb4b1729abbf18
parentc68328c2bff997c5f4846592e3f06aea4998f720 (diff)
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
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.cxx17
1 files changed, 9 insertions, 8 deletions
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