From 3718effc431f5622a23c55b254153efdfe4e72c4 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 4 Mar 2022 15:40:29 +0100 Subject: Add the Wayland platform to FLTK 1.4 --- cairo/Fl_Cairo.cxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'cairo') diff --git a/cairo/Fl_Cairo.cxx b/cairo/Fl_Cairo.cxx index 3a5b59f73..a6b2043ae 100644 --- a/cairo/Fl_Cairo.cxx +++ b/cairo/Fl_Cairo.cxx @@ -1,7 +1,7 @@ // // Main header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-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 @@ -30,6 +30,9 @@ # include #elif defined(__APPLE_QUARTZ__) // macOS # include +#elif defined(FLTK_USE_WAYLAND) +# include "../src/drivers/Wayland/Fl_Wayland_Graphics_Driver.H" +# include "../src/drivers/Wayland/Fl_Wayland_Window_Driver.H" #else # error Cairo is not supported on this platform. #endif @@ -69,7 +72,13 @@ void Fl_Cairo_State::autolink(bool b) { */ cairo_t * Fl::cairo_make_current(Fl_Window* wi) { if (!wi) return NULL; // Precondition - + cairo_t * cairo_ctxt; +#if defined(FLTK_USE_WAYLAND) + Window xid = fl_xid(wi); + if (!xid->buffer) return NULL; // this may happen with GL windows + cairo_ctxt = xid->buffer->cairo_; + cairo_state_.cc(cairo_ctxt, false); +#else // FLTK_USE_WAYLAND if (fl_gc==0) { // means remove current cc Fl::cairo_cc(0); // destroy any previous cc cairo_state_.window(0); @@ -82,7 +91,6 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) { cairo_state_.window(wi); - cairo_t * cairo_ctxt; #ifndef __APPLE__ float scale = Fl::screen_scale(wi->screen_num()); // get the screen scaling factor #endif @@ -95,9 +103,11 @@ cairo_t * Fl::cairo_make_current(Fl_Window* wi) { #ifndef __APPLE__ cairo_scale(cairo_ctxt, scale, scale); #endif +#endif // FLTK_USE_WAYLAND return cairo_ctxt; } +#if !defined(FLTK_USE_WAYLAND) /* Creates transparently a cairo_surface_t object. gc is an HDC context in Windows, a CGContext* in Quartz, and @@ -176,6 +186,9 @@ cairo_t * Fl::cairo_make_current(void *gc, int W, int H) { cairo_surface_destroy(s); return c; } + +#endif // !FLTK_USE_WAYLAND + #else // just don't leave the libfltk_cairo lib empty to avoid warnings #include -- cgit v1.2.3