From 2ea85ea6d7a9d377abcc01f4755d146dcbe30d60 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 11 Sep 2022 09:15:42 +0200 Subject: [PATCH] Fix regression in fl_read_image() after introduction of hybrid Wayland/X11 platform. The special use context of fl_read_image() inside the draw() function of an Fl_Double_Window, where the function should read inside the window's double buffer rather than the on-screen window, no longer worked. Removal of all uses of the fl_window global variable from platform-independent code remains necessary, because this variable is ill-defined in the Wayland/X11 library. --- src/fl_read_image.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fl_read_image.cxx b/src/fl_read_image.cxx index 0d5f7ec5c..b34585197 100644 --- a/src/fl_read_image.cxx +++ b/src/fl_read_image.cxx @@ -40,7 +40,9 @@ uchar *fl_read_image(uchar *p, int X, int Y, int w, int h, int alpha) { uchar *image_data = NULL; Fl_RGB_Image *img; - if (Fl_Surface_Device::surface()->as_image_surface()) { // read from off_screen buffer + // TODO: strive to remove use of the fl_window global variable in platform-independent code + //if (Fl_Surface_Device::surface()->as_image_surface()) { // read from off_screen buffer + if (fl_find(fl_window)==0) { // read from off_screen buffer img = Fl::screen_driver()->read_win_rectangle(X, Y, w, h, 0); if (!img) { return NULL;