summaryrefslogtreecommitdiff
path: root/cairo
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-03-04 15:40:29 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-03-04 15:41:00 +0100
commit3718effc431f5622a23c55b254153efdfe4e72c4 (patch)
treed8a805870c6a3785022e2f52f0c3715410e29a37 /cairo
parenta773fdc44bfb818f1830e9e48ba765881e68c942 (diff)
Add the Wayland platform to FLTK 1.4
Diffstat (limited to 'cairo')
-rw-r--r--cairo/Fl_Cairo.cxx19
1 files changed, 16 insertions, 3 deletions
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 <cairo-win32.h>
#elif defined(__APPLE_QUARTZ__) // macOS
# include <cairo-quartz.h>
+#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 <FL/Fl_Export.H>