mirror of
https://github.com/fltk/fltk.git
synced 2026-05-30 13:05:35 +08:00
Windows: fix window titlebar capture when desktop uses negative coordinates.
This commit is contained in:
+4
-4
@@ -2998,14 +2998,14 @@ void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image *&top, F
|
||||
int offset = r.left < 0 ? -r.left : 0;
|
||||
Fl_WinAPI_Screen_Driver *dr = (Fl_WinAPI_Screen_Driver *)Fl::screen_driver();
|
||||
if (htop && r.right - r.left > offset) {
|
||||
top = dr->read_win_rectangle_unscaled(r.left+offset, r.top, r.right - r.left-offset, htop, 0);
|
||||
top = dr->read_win_rectangle_unscaled(r.left+offset, r.top, r.right - r.left-offset, htop, 0, true);
|
||||
if (scaling != 1 && top)
|
||||
top->scale(ww, int(htop / scaling), 0, 1);
|
||||
}
|
||||
if (wsides) {
|
||||
left = dr->read_win_rectangle_unscaled(r.left + offset, r.top + htop, wsides, int(h() * scaling), 0);
|
||||
right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, int(h() * scaling), 0);
|
||||
bottom = dr->read_win_rectangle_unscaled(r.left+offset, r.bottom - hbottom, ww, hbottom, 0);
|
||||
left = dr->read_win_rectangle_unscaled(r.left + offset, r.top + htop, wsides, int(h() * scaling), 0, true);
|
||||
right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, int(h() * scaling), 0, true);
|
||||
bottom = dr->read_win_rectangle_unscaled(r.left+offset, r.bottom - hbottom, ww, hbottom, 0, true);
|
||||
if (scaling != 1) {
|
||||
if (left) left->scale(wsides, h(), 0, 1);
|
||||
if (right) right->scale(wsides, h(), 0, 1);
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
int dnd(int unused) FL_OVERRIDE;
|
||||
int compose(int &del) FL_OVERRIDE;
|
||||
Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win, bool may_capture_subwins, bool *did_capture_subwins) FL_OVERRIDE;
|
||||
Fl_RGB_Image *read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win);
|
||||
Fl_RGB_Image *read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win, bool screen_capture);
|
||||
int get_mouse(int &x, int &y) FL_OVERRIDE;
|
||||
void enable_im() FL_OVERRIDE;
|
||||
void disable_im() FL_OVERRIDE;
|
||||
|
||||
@@ -372,11 +372,15 @@ Fl_WinAPI_Screen_Driver::read_win_rectangle(
|
||||
if (ws < 1) ws = 1;
|
||||
if (hs < 1) hs = 1;
|
||||
}
|
||||
return read_win_rectangle_unscaled(Fl_Scalable_Graphics_Driver::floor(X, s), Fl_Scalable_Graphics_Driver::floor(Y, s), ws, hs, win);
|
||||
return read_win_rectangle_unscaled(Fl_Scalable_Graphics_Driver::floor(X, s), Fl_Scalable_Graphics_Driver::floor(Y, s), ws, hs, win, false);
|
||||
}
|
||||
|
||||
Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win)
|
||||
Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h,
|
||||
Fl_Window *win, bool screen_capture)
|
||||
{
|
||||
// When screen_capture is true, win is NULL and we read from the screen independently from any window.
|
||||
// Otherwise win can be a window inside which to read or NULL to read from current offscreen.
|
||||
|
||||
// Depth of image is always 3 here
|
||||
|
||||
// Grab all of the pixels in the image...
|
||||
@@ -390,15 +394,17 @@ Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y,
|
||||
int shift_x = 0; // X target shift if X modified
|
||||
int shift_y = 0; // Y target shift if X modified
|
||||
|
||||
if (X < 0) {
|
||||
shift_x = -X;
|
||||
w += X;
|
||||
X = 0;
|
||||
}
|
||||
if (Y < 0) {
|
||||
shift_y = -Y;
|
||||
h += Y;
|
||||
Y = 0;
|
||||
if (!screen_capture) {
|
||||
if (X < 0) {
|
||||
shift_x = -X;
|
||||
w += X;
|
||||
X = 0;
|
||||
}
|
||||
if (Y < 0) {
|
||||
shift_y = -Y;
|
||||
h += Y;
|
||||
Y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (h < 1 || w < 1) return 0; // nothing to copy
|
||||
|
||||
Reference in New Issue
Block a user