From d6aa3a67a0fba50869e9b65b5fb6e171e43e5d1b Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 9 Feb 2020 07:52:20 +0100 Subject: Add screen scaling support to Fl_Cairo_Window under X11 platform. --- cairo/Fl_Cairo.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'cairo') diff --git a/cairo/Fl_Cairo.cxx b/cairo/Fl_Cairo.cxx index 41a4e4b6d..de70d33df 100644 --- a/cairo/Fl_Cairo.cxx +++ b/cairo/Fl_Cairo.cxx @@ -84,11 +84,20 @@ 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 #if defined(USE_X11) - return Fl::cairo_make_current(0, wi->w(), wi->h()); + cairo_ctxt = Fl::cairo_make_current(0, wi->w() * scale, wi->h() * scale); #else - return Fl::cairo_make_current(fl_gc, wi->w(), wi->h()); + // on macOS, scaling is done before by Fl_Window::make_current(), on Windows, the size is not used + cairo_ctxt = Fl::cairo_make_current(fl_gc, wi->w(), wi->h()); +#endif +#ifndef __APPLE__ + cairo_scale(cairo_ctxt, scale, scale); #endif + return cairo_ctxt; } /* -- cgit v1.2.3