From 54ecae9bda20ac0788525d793c8107c8de7dee40 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 23 Mar 2022 14:11:49 +0100 Subject: [PATCH] Create struct wld_window *Fl_Wayland_Window_Driver::wld_window to replace eventually fl_window. --- src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx | 2 +- src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 6 +++--- src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H | 2 +- .../Wayland/Fl_Wayland_Image_Surface_Driver.cxx | 10 +++++----- src/drivers/Wayland/Fl_Wayland_Window_Driver.H | 1 + src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx index 2759c7d60..a7eb5471d 100644 --- a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx @@ -24,7 +24,7 @@ Fl_Wayland_Copy_Surface_Driver::Fl_Wayland_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) { - int os_scale = (fl_window ? fl_window->scale : 1); + int os_scale = (Fl_Wayland_Window_Driver::wld_window ? Fl_Wayland_Window_Driver::wld_window->scale : 1); img_surf = new Fl_Image_Surface(w * os_scale, h * os_scale); driver(img_surf->driver()); driver()->scale(os_scale); diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index e28588369..6f2e22895 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -84,10 +84,10 @@ void Fl_Wayland_Gl_Window_Driver::init() { char *Fl_Wayland_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs) { // write str to a bitmap just big enough - Window save_win = fl_window; - fl_window = NULL; + struct wld_window *save_win = Fl_Wayland_Window_Driver::wld_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = NULL; Fl_Image_Surface *surf = new Fl_Image_Surface(w, h); - fl_window = save_win; + fl_window = Fl_Wayland_Window_Driver::wld_window = save_win; Fl_Font f=fl_font(); Fl_Surface_Device::push_current(surf); fl_color(FL_BLACK); diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H index b65d858b4..7959267f8 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H @@ -22,7 +22,7 @@ class Fl_Wayland_Image_Surface_Driver : public Fl_Image_Surface_Driver { virtual void end_current(); - Window pre_window; + struct wld_window *pre_window; public: Fl_Wayland_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); ~Fl_Wayland_Image_Surface_Driver(); diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx index 3e25b7873..a5d97fdcd 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx @@ -25,8 +25,8 @@ Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, i float d = 1; if (!off) { fl_open_display(); - if (fl_window) { - d = fl_window->scale; + if (Fl_Wayland_Window_Driver::wld_window) { + d = Fl_Wayland_Window_Driver::wld_window->scale; } d *= fl_graphics_driver->scale(); if (d != 1 && high_res) { @@ -56,14 +56,14 @@ 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)->activate(offscreen, driver()->scale()); - pre_window = fl_window; - fl_window = NULL; + pre_window = Fl_Wayland_Window_Driver::wld_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = NULL; } void Fl_Wayland_Image_Surface_Driver::end_current() { cairo_surface_t *surf = cairo_get_target(offscreen->cairo_); cairo_surface_flush(surf); - fl_window = pre_window; + fl_window = Fl_Wayland_Window_Driver::wld_window = pre_window; } void Fl_Wayland_Image_Surface_Driver::translate(int x, int y) { diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H index 99a67dbba..2ee8a4f35 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.H +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.H @@ -88,6 +88,7 @@ public: struct xdg_toplevel *xdg_toplevel(); Fl_Wayland_Window_Driver(Fl_Window*); virtual ~Fl_Wayland_Window_Driver(); + static struct wld_window *wld_window; static void redraw(struct wld_window *window); static inline Fl_Wayland_Window_Driver* driver(const Fl_Window *w) {return (Fl_Wayland_Window_Driver*)Fl_Window_Driver::driver(w);} diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 1cf6e084f..d2e3d9305 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -52,6 +52,7 @@ extern "C" { #define fl_max(a,b) ((a) > (b) ? (a) : (b)) Window fl_window; +struct wld_window *Fl_Wayland_Window_Driver::wld_window = NULL; void Fl_Wayland_Window_Driver::destroy_double_buffer() { @@ -405,7 +406,7 @@ void Fl_Wayland_Window_Driver::make_current() { } fl_graphics_driver->clip_region(0); - fl_window = window; + fl_window = Fl_Wayland_Window_Driver::wld_window = window; if (!window->buffer) { window->buffer = Fl_Wayland_Graphics_Driver::create_shm_buffer( pWindow->w() * scale, pWindow->h() * scale);