summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-03-22 21:01:36 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-03-22 21:01:36 +0100
commit8b327d1dddcbaf039b3eafc9a5e13b58a0173122 (patch)
treebf1eddc7bd923b6e8922f55a15bf8ec132e6d15b
parent510ba8e46dc3a5fc980e31ec9621de6dc423c806 (diff)
Fix option CAIRO_EXT in combination with X11 on macOS
This modification became necessary since "__APPLE__" is no longer undefined by the build system when X11 is used on macOS.
-rw-r--r--src/Fl_Cairo.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Fl_Cairo.cxx b/src/Fl_Cairo.cxx
index 2def2698a..fb6b1d578 100644
--- a/src/Fl_Cairo.cxx
+++ b/src/Fl_Cairo.cxx
@@ -26,6 +26,14 @@
#ifdef FLTK_HAVE_CAIRO
+// Define USE_MAC_OS for convenience (below). We use macOS specific features
+// if USE_MAC_OS is defined, otherwise we're using X11 (XQuartz) on macOS
+
+#if defined __APPLE__ && !defined(FLTK_USE_X11)
+#define USE_MAC_OS
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
#include <FL/platform.H>
#include <FL/Fl_Window.H>
@@ -118,7 +126,7 @@ cairo_t *Fl::cairo_make_current(Fl_Window *wi) {
// Scale the Cairo context appropriately. This is platform dependent
-#ifndef __APPLE__
+#if !defined(USE_MAC_OS)
float scale = Fl::screen_scale(wi->screen_num()); // get the screen scaling factor
#endif
@@ -129,7 +137,7 @@ cairo_t *Fl::cairo_make_current(Fl_Window *wi) {
cairo_ctxt = Fl::cairo_make_current(fl_gc, wi->w(), wi->h());
#endif
-#ifndef __APPLE__
+#if !defined(USE_MAC_OS)
cairo_scale(cairo_ctxt, scale, scale);
#endif
return cairo_ctxt;
@@ -215,7 +223,7 @@ cairo_t *Fl::cairo_make_current(void *gc, int W, int H) {
cairo_state_.gc(gc); // keep track for next time
cairo_surface_t *s = cairo_create_surface(gc, W, H);
-#if defined(__APPLE__) && defined(FLTK_HAVE_CAIROEXT)
+#if defined(USE_MAC_OS) && defined(FLTK_HAVE_CAIROEXT)
CGAffineTransform at = CGContextGetCTM((CGContextRef)gc);
CGContextSaveGState((CGContextRef)gc);
CGContextConcatCTM((CGContextRef)gc, CGAffineTransformInvert(at));
@@ -223,7 +231,7 @@ cairo_t *Fl::cairo_make_current(void *gc, int W, int H) {
cairo_t *c = cairo_create(s);
-#if defined(__APPLE__) && defined(FLTK_HAVE_CAIROEXT)
+#if defined(USE_MAC_OS) && defined(FLTK_HAVE_CAIROEXT)
CGContextRestoreGState((CGContextRef)gc);
#endif