mirror of
https://github.com/fltk/fltk.git
synced 2026-05-27 10:57:58 +08:00
X11: simpler code to capture window decoration under xfce
This commit is contained in:
@@ -640,6 +640,10 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// When capturing window decoration, w is negative and X,Y,w and h are in pixels;
|
||||||
|
// otherwise X,Y,w and h are in FLTK units.
|
||||||
|
//
|
||||||
Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win, bool may_capture_subwins, bool *did_capture_subwins)
|
Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win, bool may_capture_subwins, bool *did_capture_subwins)
|
||||||
{
|
{
|
||||||
XImage *image; // Captured image
|
XImage *image; // Captured image
|
||||||
@@ -665,7 +669,6 @@ Fl_RGB_Image *Fl_X11_Screen_Driver::read_win_rectangle(int X, int Y, int w, int
|
|||||||
//
|
//
|
||||||
int allow_outside = w < 0; // negative w allows negative X or Y, that is, window frame
|
int allow_outside = w < 0; // negative w allows negative X or Y, that is, window frame
|
||||||
if (w < 0) w = - w;
|
if (w < 0) w = - w;
|
||||||
// when capturing window decoration, X,Y,w and h are in pixels (not in FLTK units).
|
|
||||||
Window xid = (win && !allow_outside ? fl_xid(win) : fl_window);
|
Window xid = (win && !allow_outside ? fl_xid(win) : fl_window);
|
||||||
|
|
||||||
float s = allow_outside ? 1 : Fl_Surface_Device::surface()->driver()->scale();
|
float s = allow_outside ? 1 : Fl_Surface_Device::surface()->driver()->scale();
|
||||||
|
|||||||
@@ -382,28 +382,13 @@ void Fl_X11_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_R
|
|||||||
fl_window = parent;
|
fl_window = parent;
|
||||||
if (htop) {
|
if (htop) {
|
||||||
if (true_sides) {
|
if (true_sides) {
|
||||||
top = Fl::screen_driver()->read_win_rectangle(1, 1, -(ww-1), htop, pWindow);
|
top = Fl::screen_driver()->read_win_rectangle(1, 1, -(ww-2), hh-2, pWindow);
|
||||||
if (top) top->scale(decorated_w()+1, (htop / s)+1, 0, 1);
|
if (top) top->scale(decorated_w(), decorated_h(), 0, 1);
|
||||||
} else {
|
} else {
|
||||||
top = Fl::screen_driver()->read_win_rectangle(wsides, wsides, -(ww-1), htop, pWindow);
|
top = Fl::screen_driver()->read_win_rectangle(wsides, wsides, -(ww-1), htop, pWindow);
|
||||||
if (top) top->scale(w(), htop / s, 0, 1);
|
if (top) top->scale(w(), htop / s, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (true_sides && wsides) {
|
|
||||||
left = Fl::screen_driver()->read_win_rectangle(1, htop, -wsides, hh - htop - wsides, pWindow);
|
|
||||||
if (left) {
|
|
||||||
left->scale(wsides/s, h(), 0, 1);
|
|
||||||
}
|
|
||||||
if (left) {
|
|
||||||
right = (Fl_RGB_Image*)left->copy(left->data_w(), left->data_h());
|
|
||||||
right->scale(left->w(), left->h(), 0, 1);
|
|
||||||
} else right = NULL;
|
|
||||||
|
|
||||||
bottom = Fl::screen_driver()->read_win_rectangle(1, hh-wsides, -(ww-1), wsides, pWindow);
|
|
||||||
if (bottom) {
|
|
||||||
bottom->scale(decorated_w(), wsides / s, 0, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fl_window = from;
|
fl_window = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user