summaryrefslogtreecommitdiff
path: root/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-08-09 10:31:36 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-08-09 10:31:36 +0200
commit1943fe54c8fdf759a3f4da88ea8a8fb5f6f5f7cb (patch)
tree698368755555882244b7eaab9fcbb931e7959fda /src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
parent06e8cf98a6a08c202333bff893be55741961bfd3 (diff)
Wayland: fix fl_read_image() from offscreen buffer
Diffstat (limited to 'src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 764a4e8df..204a058ca 100644
--- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -1495,9 +1495,13 @@ void Fl_Wayland_Screen_Driver::get_system_colors()
Fl_RGB_Image *Fl_Wayland_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win,
bool ignore, bool *p_ignore) {
struct wld_window* xid = win ? fl_wl_xid(win) : NULL;
- struct fl_wld_draw_buffer *buffer = win ? &xid->buffer->draw_buffer :
- (struct fl_wld_draw_buffer *)
- (((Fl_Image_Surface*)Fl_Surface_Device::surface())->offscreen());//to check
+ if (win && (!xid || !xid->buffer)) return NULL;
+ struct fl_wld_draw_buffer *buffer;
+ if (win) buffer = &xid->buffer->draw_buffer;
+ else {
+ Fl_Image_Surface_Driver *dr = (Fl_Image_Surface_Driver*)Fl_Surface_Device::surface();
+ buffer = (struct fl_wld_draw_buffer *)dr->image_surface()->offscreen();
+ }
float s = win ?
Fl_Wayland_Window_Driver::driver(win)->wld_scale() * scale(win->screen_num()) :
Fl_Surface_Device::surface()->driver()->scale();