From 7bb8bdb1fa2768dc19cf428e0b013ab66191b9e9 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:20:01 +0100 Subject: Fix Fl_{Wayland|Xlib}_{Copy|Image}_Surface_Driver::set_current() Member function Fl_Cairo_Graphics_Driver::set_cairo() needs be called only to initialize the driver. Doing it also later undoes the effect of Fl_Widget_Surface::translate() if used when Fl_Surface_Device::pop_current() calls the overridden Fl_Surface_Device::set_current(). --- src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx | 3 ++- src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/drivers/Wayland') diff --git a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx index 0b84a037b..043114781 100644 --- a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx @@ -45,7 +45,8 @@ Fl_Wayland_Copy_Surface_Driver::~Fl_Wayland_Copy_Surface_Driver() { void Fl_Wayland_Copy_Surface_Driver::set_current() { Fl_Surface_Device::set_current(); - ((Fl_Wayland_Graphics_Driver*)driver())->set_cairo((cairo_t*)img_surf->offscreen()); + Fl_Cairo_Graphics_Driver *dr = (Fl_Cairo_Graphics_Driver*)driver(); + if (!dr->cr()) dr->set_cairo((cairo_t*)img_surf->offscreen()); } diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx index a3850f6da..ec9c56cb7 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx @@ -76,7 +76,8 @@ Fl_Wayland_Image_Surface_Driver::~Fl_Wayland_Image_Surface_Driver() { void Fl_Wayland_Image_Surface_Driver::set_current() { Fl_Surface_Device::set_current(); - ((Fl_Wayland_Graphics_Driver*)fl_graphics_driver)->set_cairo((cairo_t*)offscreen); + Fl_Cairo_Graphics_Driver *dr = (Fl_Cairo_Graphics_Driver*)driver(); + if (!dr->cr()) dr->set_cairo((cairo_t*)offscreen); pre_window = Fl_Wayland_Window_Driver::wld_window; Fl_Wayland_Window_Driver::wld_window = NULL; fl_window = 0; -- cgit v1.2.3