diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-03-13 08:56:23 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-03-13 08:56:35 +0100 |
| commit | b549cfaaea11ce5e881e2151a838c91a031ad9ba (patch) | |
| tree | a8a34a8cd7270a4d4ca68bca08c1b6e6388220d4 /src/drivers/Wayland | |
| parent | e8461a6191e0afa5fd96290856d1a056437469d0 (diff) | |
Separate platform init functions from platform-specific driver files
Diffstat (limited to 'src/drivers/Wayland')
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H | 34 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx | 19 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H | 67 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx | 38 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx | 7 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H | 33 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx | 17 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 10 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_System_Driver.cxx | 10 | ||||
| -rw-r--r-- | src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 6 | ||||
| -rw-r--r-- | src/drivers/Wayland/fl_wayland_gl_platform_init.cxx | 24 | ||||
| -rw-r--r-- | src/drivers/Wayland/fl_wayland_platform_init.cxx | 60 |
12 files changed, 221 insertions, 104 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H new file mode 100644 index 000000000..f5f6eee11 --- /dev/null +++ b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.H @@ -0,0 +1,34 @@ +// +// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_WAYLAND_COPY_SURFACE_DRIVER_H +#define FL_WAYLAND_COPY_SURFACE_DRIVER_H + +#include <FL/Fl_Copy_Surface.H> +#include <FL/Fl_Image_Surface.H> + +class Fl_Wayland_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { + friend class Fl_Copy_Surface_Driver; + Fl_Image_Surface *img_surf; +protected: + Fl_Wayland_Copy_Surface_Driver(int w, int h); + ~Fl_Wayland_Copy_Surface_Driver(); + void set_current(); + void translate(int x, int y); + void untranslate(); +}; + +#endif // FL_WAYLAND_COPY_SURFACE_DRIVER_H diff --git a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx index addcfbebd..2759c7d60 100644 --- a/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Copy_Surface_Driver.cxx @@ -15,30 +15,13 @@ // #include <config.h> -#include <FL/Fl_Copy_Surface.H> +#include "Fl_Wayland_Copy_Surface_Driver.H" #include <FL/Fl_Image_Surface.H> #include "Fl_Wayland_Graphics_Driver.H" #include "Fl_Wayland_Screen_Driver.H" #include "Fl_Wayland_Window_Driver.H" #include <FL/platform.H> -class Fl_Wayland_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { - friend class Fl_Copy_Surface_Driver; - Fl_Image_Surface *img_surf; -protected: - Fl_Wayland_Copy_Surface_Driver(int w, int h); - ~Fl_Wayland_Copy_Surface_Driver(); - void set_current(); - void translate(int x, int y); - void untranslate(); -}; - - -Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h) -{ - return new Fl_Wayland_Copy_Surface_Driver(w, h); -} - 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); diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H new file mode 100644 index 000000000..486051f6f --- /dev/null +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.H @@ -0,0 +1,67 @@ +// +// Class Fl_Wayland_Gl_Window_Driver for the Fast Light Tool Kit (FLTK). +// +// Copyright 2021-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_WAYLAND_GL_WINDOW_DRIVER_H +#define FL_WAYLAND_GL_WINDOW_DRIVER_H + +#include <config.h> +#if HAVE_GL +#include <FL/platform.H> +#include "../../Fl_Gl_Window_Driver.H" +#include <wayland-egl.h> +#include <EGL/egl.h> +#include <FL/gl.h> + +/* Implementation note about OpenGL drawing on the Wayland platform + +After eglCreateWindowSurface() with attributes {EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER, EGL_NONE}, +eglQueryContext() reports that EGL_RENDER_BUFFER equals EGL_BACK_BUFFER. +This experiment suggests that the platform only supports double-buffer drawing. +Consequently, FL_DOUBLE is enforced in all Fl_Gl_Window::mode_ values under Wayland. +*/ + +class Fl_Wayland_Gl_Window_Driver : public Fl_Gl_Window_Driver { + friend class Fl_Gl_Window_Driver; + bool egl_resize_in_progress; +protected: + Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win); + virtual float pixels_per_unit(); + virtual void make_current_before(); + virtual int mode_(int m, const int *a); + virtual void swap_buffers(); + virtual void resize(int is_a_resize, int w, int h); + virtual char swap_type(); + virtual Fl_Gl_Choice *find(int m, const int *alistp); + virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0); + virtual void set_gl_context(Fl_Window* w, GLContext context); + virtual void delete_gl_context(GLContext); + virtual void make_overlay_current(); + virtual void redraw_overlay(); + virtual void waitGL(); + virtual void gl_start(); + virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h); + char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs); +public: + static EGLDisplay egl_display; + static EGLint configs_count; + static struct wl_event_queue *gl_event_queue; + void init(); + struct wl_egl_window *egl_window; + EGLSurface egl_surface; +}; + +#endif // HAVE_GL +#endif // FL_WAYLAND_GL_WINDOW_DRIVER_H diff --git a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx index 290a52361..4d8f478e3 100644 --- a/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Gl_Window_Driver.cxx @@ -22,7 +22,7 @@ #include "../../Fl_Screen_Driver.H" #include "Fl_Wayland_Window_Driver.H" #include "Fl_Wayland_Graphics_Driver.H" -#include "../../Fl_Gl_Window_Driver.H" +#include "Fl_Wayland_Gl_Window_Driver.H" #include <wayland-egl.h> #include <EGL/egl.h> #include <FL/gl.h> @@ -35,36 +35,6 @@ This experiment suggests that the platform only supports double-buffer drawing. Consequently, FL_DOUBLE is enforced in all Fl_Gl_Window::mode_ values under Wayland. */ -class Fl_Wayland_Gl_Window_Driver : public Fl_Gl_Window_Driver { - friend class Fl_Gl_Window_Driver; - bool egl_resize_in_progress; -protected: - Fl_Wayland_Gl_Window_Driver(Fl_Gl_Window *win); - virtual float pixels_per_unit(); - virtual void make_current_before(); - virtual int mode_(int m, const int *a); - virtual void swap_buffers(); - virtual void resize(int is_a_resize, int w, int h); - virtual char swap_type(); - virtual Fl_Gl_Choice *find(int m, const int *alistp); - virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0); - virtual void set_gl_context(Fl_Window* w, GLContext context); - virtual void delete_gl_context(GLContext); - virtual void make_overlay_current(); - virtual void redraw_overlay(); - virtual void waitGL(); - virtual void gl_start(); - virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h); - char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs); -public: - static EGLDisplay egl_display; - static EGLint configs_count; - static struct wl_event_queue *gl_event_queue; - void init(); - struct wl_egl_window *egl_window; - EGLSurface egl_surface; -}; - // Describes crap needed to create a GLContext. class Fl_Wayland_Gl_Choice : public Fl_Gl_Choice { friend class Fl_Wayland_Gl_Window_Driver; @@ -247,12 +217,6 @@ void Fl_Wayland_Gl_Window_Driver::redraw_overlay() { } -Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w) -{ - return new Fl_Wayland_Gl_Window_Driver(w); -} - - static void gl_frame_ready(void *data, struct wl_callback *cb, uint32_t time) { *(bool*)data = true; } diff --git a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx index 2e50f2e2b..9a337dde8 100644 --- a/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx @@ -152,13 +152,6 @@ Fl_Wayland_Graphics_Driver::Fl_Wayland_Graphics_Driver () : Fl_Cairo_Graphics_Dr } -Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() -{ - fl_graphics_driver = new Fl_Wayland_Graphics_Driver(); - return fl_graphics_driver; -} - - void Fl_Wayland_Graphics_Driver::activate(struct fl_wld_buffer *buffer, float scale) { if (dummy_pango_layout_) { cairo_surface_t *surf = cairo_get_target(cairo_); diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H new file mode 100644 index 000000000..cb80d355a --- /dev/null +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.H @@ -0,0 +1,33 @@ +// +// Draw-to-image code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2021 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_WAYLAND_IMAGE_SURFACE_DRIVER_H +#define FL_WAYLAND_IMAGE_SURFACE_DRIVER_H + +#include <FL/Fl_Image_Surface.H> + +class Fl_Wayland_Image_Surface_Driver : public Fl_Image_Surface_Driver { + virtual void end_current(); +public: + Fl_Wayland_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); + ~Fl_Wayland_Image_Surface_Driver(); + void set_current(); + void translate(int x, int y); + void untranslate(); + Fl_RGB_Image *image(); +}; + +#endif // FL_WAYLAND_IMAGE_SURFACE_DRIVER_H diff --git a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx index d79ad0f2e..d30356396 100644 --- a/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Image_Surface_Driver.cxx @@ -18,23 +18,8 @@ #include <FL/platform.H> #include "Fl_Wayland_Graphics_Driver.H" #include "Fl_Wayland_Window_Driver.H" -#include <FL/Fl_Image_Surface.H> +#include "Fl_Wayland_Image_Surface_Driver.H" -class Fl_Wayland_Image_Surface_Driver : public Fl_Image_Surface_Driver { - virtual void end_current(); -public: - Fl_Wayland_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); - ~Fl_Wayland_Image_Surface_Driver(); - void set_current(); - void translate(int x, int y); - void untranslate(); - Fl_RGB_Image *image(); -}; - -Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off) -{ - return new Fl_Wayland_Image_Surface_Driver(w, h, high_res, off); -} Fl_Wayland_Image_Surface_Driver::Fl_Wayland_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Image_Surface_Driver(w, h, high_res, off) { float d = 1; diff --git a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx index 84b2c8c91..f4ba06d56 100644 --- a/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx @@ -157,16 +157,6 @@ extern const char *fl_bg2; // end of extern additions workaround -/** - Creates a driver that manages all screen and display related calls. - - This function must be implemented once for every platform. - */ -Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() -{ - return new Fl_Wayland_Screen_Driver(); -} - FL_EXPORT struct wl_display *fl_display = NULL; static bool has_xrgb = false; diff --git a/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx index 46351646c..a54e2ac5f 100644 --- a/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_System_Driver.cxx @@ -21,16 +21,6 @@ #include <FL/platform.H> #include "../../../libdecor/src/libdecor.h" -/** - Creates a driver that manages all system related calls. - - This function must be implemented once for every platform. - */ -Fl_System_Driver *Fl_System_Driver::newSystemDriver() -{ - return new Fl_Wayland_System_Driver(); -} - int Fl_Wayland_System_Driver::event_key(int k) { if (k > FL_Button && k <= FL_Button+8) diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx index 6241d5af8..1e3990559 100644 --- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx +++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx @@ -60,12 +60,6 @@ void Fl_Wayland_Window_Driver::destroy_double_buffer() { } -Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) -{ - return new Fl_Wayland_Window_Driver(w); -} - - Fl_Wayland_Window_Driver::Fl_Wayland_Window_Driver(Fl_Window *win) : Fl_Window_Driver(win) { icon_ = new icon_data; diff --git a/src/drivers/Wayland/fl_wayland_gl_platform_init.cxx b/src/drivers/Wayland/fl_wayland_gl_platform_init.cxx new file mode 100644 index 000000000..5a2a78bee --- /dev/null +++ b/src/drivers/Wayland/fl_wayland_gl_platform_init.cxx @@ -0,0 +1,24 @@ +// +// Wayland-specific code to initialize wayland support. +// +// Copyright 2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + + +#include "Fl_Wayland_Gl_Window_Driver.H" + + +Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w) +{ + return new Fl_Wayland_Gl_Window_Driver(w); +} diff --git a/src/drivers/Wayland/fl_wayland_platform_init.cxx b/src/drivers/Wayland/fl_wayland_platform_init.cxx new file mode 100644 index 000000000..e6aebd174 --- /dev/null +++ b/src/drivers/Wayland/fl_wayland_platform_init.cxx @@ -0,0 +1,60 @@ +// +// Wayland-specific code to initialize wayland support. +// +// Copyright 2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + + +#include "Fl_Wayland_Copy_Surface_Driver.H" +#include "Fl_Wayland_Graphics_Driver.H" +#include "Fl_Wayland_Screen_Driver.H" +#include "Fl_Wayland_System_Driver.H" +#include "Fl_Wayland_Window_Driver.H" +#include "Fl_Wayland_Image_Surface_Driver.H" + + +Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h) +{ + return new Fl_Wayland_Copy_Surface_Driver(w, h); +} + + +Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() +{ + fl_graphics_driver = new Fl_Wayland_Graphics_Driver(); + return fl_graphics_driver; +} + + +Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() +{ + return new Fl_Wayland_Screen_Driver(); +} + + +Fl_System_Driver *Fl_System_Driver::newSystemDriver() +{ + return new Fl_Wayland_System_Driver(); +} + + +Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w) +{ + return new Fl_Wayland_Window_Driver(w); +} + + +Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off) +{ + return new Fl_Wayland_Image_Surface_Driver(w, h, high_res, off); +} |
