Browse Source

Fix "fltk autotools build does not link against libXft" (#1202)

libXft was erroneously present in the link command when using Pango and Cairo.
This is fixed by disconnecting the GUI scaling code from use of Xft.

This commit also makes sure that when Wayland is used, pkg-config is available
on the build machine. This allows to remove from file CMake/options.cmake
code that was labelled with "FIXME".
pull/1217/head
ManoloFLTK 3 months ago
parent
commit
7f60f019d7
  1. 93
      CMake/options.cmake
  2. 41
      src/Fl_x.cxx
  3. 4
      src/drivers/X11/Fl_X11_Gl_Window_Driver.H
  4. 10
      src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
  5. 6
      src/drivers/X11/Fl_X11_Screen_Driver.H
  6. 24
      src/drivers/X11/Fl_X11_Screen_Driver.cxx
  7. 10
      src/drivers/X11/Fl_X11_Window_Driver.H
  8. 6
      src/drivers/X11/Fl_X11_Window_Driver.cxx
  9. 4
      src/drivers/X11/fl_X11_platform_init.cxx
  10. 4
      src/drivers/Xlib/Fl_Font.H
  11. 8
      src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
  12. 8
      src/fl_dnd_x.cxx
  13. 14
      src/xutf8/lcUniConv/cp936ext.h

93
CMake/options.cmake

@ -280,6 +280,9 @@ if(UNIX) @@ -280,6 +280,9 @@ if(UNIX)
option(FLTK_BACKEND_WAYLAND "support the Wayland backend" ON)
endif(NOT APPLE)
if(FLTK_BACKEND_WAYLAND)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR "Option FLTK_BACKEND_WAYLAND requires availability of pkg-config on the build machine.")
endif(NOT PKG_CONFIG_FOUND)
pkg_check_modules(WLDCLIENT IMPORTED_TARGET wayland-client>=1.18)
pkg_check_modules(WLDCURSOR IMPORTED_TARGET wayland-cursor)
pkg_check_modules(WLDPROTO IMPORTED_TARGET wayland-protocols>=1.15)
@ -323,7 +326,6 @@ if(UNIX) @@ -323,7 +326,6 @@ if(UNIX)
if(NOT X11_Xft_FOUND)
message(WARNING "Install development headers for libXft (e.g., libxft-dev)")
endif()
set(USE_XFT 1)
if(NOT X11_Xcursor_FOUND)
message(WARNING "Install development headers for libXcursor (e.g., libxcursor-dev)")
endif()
@ -829,11 +831,13 @@ endif(FLTK_USE_XCURSOR) @@ -829,11 +831,13 @@ endif(FLTK_USE_XCURSOR)
#######################################################################
if(X11_Xft_FOUND)
option(FLTK_USE_XFT "use lib Xft" ON)
option(FLTK_USE_PANGO "use lib Pango" OFF)
if(NOT FLTK_BACKEND_WAYLAND)
option(FLTK_GRAPHICS_CAIRO "all drawing to X11 windows uses Cairo" OFF)
endif(NOT FLTK_BACKEND_WAYLAND)
if(NOT FLTK_GRAPHICS_CAIRO)
option(FLTK_USE_XFT "use lib Xft" ON)
endif()
endif(X11_Xft_FOUND)
# test option compatibility: Cairo for Xlib requires Pango
@ -842,19 +846,19 @@ if(FLTK_GRAPHICS_CAIRO) @@ -842,19 +846,19 @@ if(FLTK_GRAPHICS_CAIRO)
set(FLTK_USE_PANGO TRUE CACHE BOOL "use lib Pango")
endif(FLTK_GRAPHICS_CAIRO)
if(FLTK_USE_X11 AND (FLTK_USE_PANGO OR FLTK_GRAPHICS_CAIRO)) # implies to use PANGOXFT
if(FLTK_USE_X11 AND FLTK_USE_PANGO AND NOT FLTK_GRAPHICS_CAIRO)
set(USE_PANGOXFT true)
endif()
# test option compatibility: Pango requires Xft
# test option compatibility: PangoXft requires Xft
if(USE_PANGOXFT)
if(NOT X11_Xft_FOUND)
message(STATUS "Pango requires Xft but Xft library or headers could not be found.")
message(STATUS "PangoXft requires Xft but Xft library or headers could not be found.")
message(STATUS "Please install Xft development files and try again or disable FLTK_USE_PANGO.")
message(FATAL_ERROR "*** Aborting ***")
else()
if(NOT FLTK_USE_XFT)
message(STATUS "Pango requires Xft but usage of Xft was disabled.")
message(STATUS "PangoXft requires Xft but usage of Xft was disabled.")
message(STATUS "Please enable FLTK_USE_XFT and try again or disable FLTK_USE_PANGO.")
message(FATAL_ERROR "*** Aborting ***")
endif(NOT FLTK_USE_XFT)
@ -863,6 +867,9 @@ endif(USE_PANGOXFT) @@ -863,6 +867,9 @@ endif(USE_PANGOXFT)
#######################################################################
if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR "Option FLTK_USE_PANGO requires availability of pkg-config on the build machine.")
endif(NOT PKG_CONFIG_FOUND)
pkg_check_modules(CAIRO IMPORTED_TARGET cairo)
if(USE_PANGOXFT)
pkg_check_modules(PANGOXFT IMPORTED_TARGET pangoxft)
@ -877,23 +884,6 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) @@ -877,23 +884,6 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO)
endif(USE_PANGOXFT)
list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIRS})
find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH})
mark_as_advanced(HAVE_LIB_PANGO)
if(USE_PANGOXFT)
find_library(HAVE_LIB_PANGOXFT pangoxft-1.0 ${CMAKE_LIBRARY_PATH})
mark_as_advanced(HAVE_LIB_PANGOXFT)
endif(USE_PANGOXFT)
find_library(HAVE_LIB_PANGOCAIRO pangocairo-1.0 ${CMAKE_LIBRARY_PATH})
mark_as_advanced(HAVE_LIB_PANGOCAIRO)
find_library(HAVE_LIB_CAIRO cairo ${CMAKE_LIBRARY_PATH})
mark_as_advanced(HAVE_LIB_CAIRO)
find_library(HAVE_LIB_GOBJECT gobject-2.0 ${CMAKE_LIBRARY_PATH})
mark_as_advanced(HAVE_LIB_GOBJECT)
set(USE_PANGO TRUE)
# add required libraries to fltk-config ...
@ -902,62 +892,6 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO) @@ -902,62 +892,6 @@ if((X11_Xft_FOUND OR NOT USE_PANGOXFT) AND FLTK_USE_PANGO)
endif(USE_PANGOXFT)
list(APPEND FLTK_LDLIBS ${PANGOCAIRO_LDFLAGS})
# *FIXME* Libraries should not be added explicitly if possible
if(FLTK_BACKEND_WAYLAND AND FLTK_USE_LIBDECOR_GTK AND NOT USE_SYSTEM_LIBDECOR)
list(APPEND FLTK_LDLIBS -lgtk-3 -lgdk-3 -lgio-2.0)
endif()
if(FLTK_BACKEND_X11)
list(APPEND FLTK_LDLIBS -lX11)
endif()
if(APPLE)
get_filename_component(PANGO_L_PATH ${HAVE_LIB_PANGO} PATH)
set(LDFLAGS "${LDFLAGS} -L${PANGO_L_PATH}")
endif(APPLE)
else()
# this covers Debian, Ubuntu, FreeBSD, NetBSD, Darwin
if(APPLE AND FLTK_BACKEND_X11)
find_file(FINK_PREFIX NAMES /opt/sw /sw)
if(FINK_PREFIX)
list(APPEND CMAKE_INCLUDE_PATH ${FINK_PREFIX}/include)
list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${FINK_PREFIX}/include/cairo)
list(APPEND CMAKE_LIBRARY_PATH ${FINK_PREFIX}/lib)
endif(FINK_PREFIX)
endif(APPLE AND FLTK_BACKEND_X11)
find_file(HAVE_PANGO_H pango-1.0/pango/pango.h ${CMAKE_INCLUDE_PATH})
find_file(HAVE_PANGOXFT_H pango-1.0/pango/pangoxft.h ${CMAKE_INCLUDE_PATH})
if(HAVE_PANGO_H AND HAVE_PANGOXFT_H)
find_library(HAVE_LIB_PANGO pango-1.0 ${CMAKE_LIBRARY_PATH})
find_library(HAVE_LIB_PANGOXFT pangoxft-1.0 ${CMAKE_LIBRARY_PATH})
if(APPLE)
set(HAVE_LIB_GOBJECT TRUE)
else()
find_library(HAVE_LIB_GOBJECT gobject-2.0 ${CMAKE_LIBRARY_PATH})
endif(APPLE)
endif(HAVE_PANGO_H AND HAVE_PANGOXFT_H)
if(HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT)
set(USE_PANGO TRUE)
# remove last 3 components of HAVE_PANGO_H and put in PANGO_H_PREFIX
get_filename_component(PANGO_H_PREFIX ${HAVE_PANGO_H} PATH)
get_filename_component(PANGO_H_PREFIX ${PANGO_H_PREFIX} PATH)
get_filename_component(PANGO_H_PREFIX ${PANGO_H_PREFIX} PATH)
get_filename_component(PANGOLIB_DIR ${HAVE_LIB_PANGO} PATH)
# glib.h is usually in ${PANGO_H_PREFIX}/glib-2.0/ ...
find_path(GLIB_H_PATH glib.h
PATHS ${PANGO_H_PREFIX}/glib-2.0
${PANGO_H_PREFIX}/glib/glib-2.0)
list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${PANGO_H_PREFIX}/pango-1.0 ${GLIB_H_PATH} ${PANGOLIB_DIR}/glib-2.0/include)
# *FIXME* Libraries should not be added explicitly if possible
list(APPEND FLTK_LDLIBS -lpango-1.0 -lpangoxft-1.0 -lgobject-2.0)
endif(HAVE_LIB_PANGO AND HAVE_LIB_PANGOXFT AND HAVE_LIB_GOBJECT)
endif((PANGOXFT_FOUND OR NOT USE_PANGOXFT) AND PANGOCAIRO_FOUND AND CAIRO_FOUND)
if(USE_PANGO AND (FLTK_GRAPHICS_CAIRO OR FLTK_BACKEND_WAYLAND))
@ -974,6 +908,7 @@ if(FLTK_BACKEND_WAYLAND) @@ -974,6 +908,7 @@ if(FLTK_BACKEND_WAYLAND)
pkg_check_modules(GTK IMPORTED_TARGET gtk+-3.0)
if(GTK_FOUND)
list(APPEND FLTK_BUILD_INCLUDE_DIRECTORIES ${GTK_INCLUDE_DIRS})
list(APPEND FLTK_LDLIBS ${GTK_LDFLAGS})
else()
message(WARNING "Installation of the development files for the GTK library "
"(e.g., libgtk-3-dev) is recommended when using the gnome desktop.")

41
src/Fl_x.cxx

@ -327,7 +327,10 @@ extern "C" { @@ -327,7 +327,10 @@ extern "C" {
}
}
#if !(USE_XFT || FLTK_USE_CAIRO)
extern char *fl_get_font_xfld(int fnum, int size);
#endif
void Fl_X11_Screen_Driver::new_ic()
{
@ -343,7 +346,7 @@ void Fl_X11_Screen_Driver::new_ic() @@ -343,7 +346,7 @@ void Fl_X11_Screen_Driver::new_ic()
int sarea = 0;
XIMStyles* xim_styles = NULL;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
#if defined(__GNUC__)
// FIXME: warning XFT support here
@ -662,7 +665,7 @@ int Fl_X11_Screen_Driver::get_mouse_unscaled(int &mx, int &my) { @@ -662,7 +665,7 @@ int Fl_X11_Screen_Driver::get_mouse_unscaled(int &mx, int &my) {
Window root = RootWindow(fl_display, fl_screen);
Window c; int cx,cy; unsigned int mask;
XQueryPointer(fl_display, root, &root, &c, &mx, &my, &cx, &cy, &mask);
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
int screen = screen_num_unscaled(mx, my);
return screen >= 0 ? screen : 0;
#else
@ -1012,7 +1015,7 @@ static void set_event_xy(Fl_Window *win) { @@ -1012,7 +1015,7 @@ static void set_event_xy(Fl_Window *win) {
send_motion = 0;
# endif
float s = 1;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(win)->screen_num());
#endif
Fl::e_x_root = fl_xevent->xbutton.x_root/s;
@ -1206,7 +1209,7 @@ static KeySym fl_KeycodeToKeysym(Display *d, KeyCode k, unsigned i) { @@ -1206,7 +1209,7 @@ static KeySym fl_KeycodeToKeysym(Display *d, KeyCode k, unsigned i) {
#if USE_XRANDR
static void react_to_screen_reconfiguration() {
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
// memorize previous screen sizes and scales
int old_count = Fl::screen_count();
int (*sizes)[4] = new int[old_count][4];
@ -1215,9 +1218,9 @@ static void react_to_screen_reconfiguration() { @@ -1215,9 +1218,9 @@ static void react_to_screen_reconfiguration() {
Fl::screen_xywh(sizes[screen][0], sizes[screen][1], sizes[screen][2], sizes[screen][3], screen);
scales[screen] = Fl::screen_scale(screen);
}
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
Fl::call_screen_init(); // compute new screen sizes
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
// detect whether screen sizes were unchanged
bool nochange = (old_count == Fl::screen_count());
if (nochange) {
@ -1248,11 +1251,11 @@ static void react_to_screen_reconfiguration() { @@ -1248,11 +1251,11 @@ static void react_to_screen_reconfiguration() {
}
}
delete[] scales;
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
}
#endif // USE_XRANDR
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
static void after_display_rescale(float *p_current_xft_dpi) {
Display *new_dpy = XOpenDisplay(XDisplayString(fl_display));
if (!new_dpy) return;
@ -1269,7 +1272,7 @@ static void after_display_rescale(float *p_current_xft_dpi) { @@ -1269,7 +1272,7 @@ static void after_display_rescale(float *p_current_xft_dpi) {
}
XCloseDisplay(new_dpy);
}
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
static Window *xid_vector = NULL; // list of FLTK-created xid's (see issue #935)
@ -1347,9 +1350,9 @@ int fl_handle(const XEvent& thisevent) @@ -1347,9 +1350,9 @@ int fl_handle(const XEvent& thisevent)
if (xevent.type == PropertyNotify && xevent.xproperty.atom == fl_NET_WORKAREA) {
Fl_X11_Screen_Driver *d = (Fl_X11_Screen_Driver*)Fl::screen_driver();
d->init_workarea();
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
after_display_rescale(&(d->current_xft_dpi));
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
}
switch (xevent.type) {
@ -1713,7 +1716,7 @@ int fl_handle(const XEvent& thisevent) @@ -1713,7 +1716,7 @@ int fl_handle(const XEvent& thisevent)
in_a_window = true;
fl_dnd_source_window = data[0];
float s = 1;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
if (window) s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(window)->screen_num());
#endif
Fl::e_x_root = (data[2]>>16)/s;
@ -1788,7 +1791,7 @@ int fl_handle(const XEvent& thisevent) @@ -1788,7 +1791,7 @@ int fl_handle(const XEvent& thisevent)
case GraphicsExpose:
{
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
int ns = Fl_Window_Driver::driver(window)->screen_num();
float s = Fl::screen_driver()->scale(ns);
window->damage(FL_DAMAGE_EXPOSE, xevent.xexpose.x/s, xevent.xexpose.y/s,
@ -2208,7 +2211,7 @@ int fl_handle(const XEvent& thisevent) @@ -2208,7 +2211,7 @@ int fl_handle(const XEvent& thisevent)
Window cr; int X, Y, W = actual.width, H = actual.height;
XTranslateCoordinates(fl_display, fl_xid(window), actual.root,
0, 0, &X, &Y, &cr);
#if USE_XFT // detect when window centre changes screen
#if USE_XFT || FLTK_USE_CAIRO // detect when window centre changes screen
Fl_X11_Screen_Driver *d = (Fl_X11_Screen_Driver*)Fl::screen_driver();
Fl_X11_Window_Driver *wd = Fl_X11_Window_Driver::driver(window);
int olds = wd->screen_num();
@ -2230,13 +2233,13 @@ int fl_handle(const XEvent& thisevent) @@ -2230,13 +2233,13 @@ int fl_handle(const XEvent& thisevent)
Fl::remove_timeout(Fl_X11_Window_Driver::resize_after_screen_change, window);
Fl_X11_Window_Driver::data_for_resize_window_between_screens_.busy = false;
}
#else // ! USE_XFT
#else // ! (USE_XFT || FLTK_USE_CAIRO)
Fl_Window_Driver::driver(window)->screen_num( Fl::screen_num(X, Y, W, H) );
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
// tell Fl_Window about it and set flag to prevent echoing:
resize_bug_fix = window;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
if (!Fl_X11_Window_Driver::data_for_resize_window_between_screens_.busy &&
( ceil(W/s) != window->w() || ceil(H/s) != window->h() ) ) {
window->resize(rint(X/s), rint(Y/s), ceil(W/s), ceil(H/s));
@ -2267,7 +2270,7 @@ int fl_handle(const XEvent& thisevent) @@ -2267,7 +2270,7 @@ int fl_handle(const XEvent& thisevent)
// tell Fl_Window about it and set flag to prevent echoing:
if ( !wasXExceptionRaised() ) {
resize_bug_fix = window;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
int ns = Fl_Window_Driver::driver(window)->screen_num();
float s = Fl::screen_driver()->scale(ns);
#else
@ -2659,7 +2662,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap) @@ -2659,7 +2662,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
#endif // (ENABLE_BOXCHEAT)
float s = 1;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
//compute adequate screen where to put the window
int nscreen = 0;
if (win->parent()) {

4
src/drivers/X11/Fl_X11_Gl_Window_Driver.H

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Class Fl_X11_Gl_Window_Driver for the Fast Light Tool Kit (FLTK).
//
// Copyright 2022 by Bill Spitzak and others.
// Copyright 2022-2025 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
@ -47,7 +47,7 @@ class Fl_X11_Gl_Window_Driver : public Fl_Gl_Window_Driver { @@ -47,7 +47,7 @@ class Fl_X11_Gl_Window_Driver : public Fl_Gl_Window_Driver {
void gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize) FL_OVERRIDE;
void get_list(Fl_Font_Descriptor *fd, int r) FL_OVERRIDE;
int genlistsize() FL_OVERRIDE;
#if !USE_XFT
#if !(USE_XFT || FLTK_USE_CAIRO)
virtual Fl_Font_Descriptor** fontnum_to_fontdescriptor(int fnum) FL_OVERRIDE;
#endif
//static GLContext create_gl_context(XVisualInfo* vis);

10
src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Class Fl_X11_Gl_Window_Driver for the Fast Light Tool Kit (FLTK).
//
// Copyright 2021-2024 by Bill Spitzak and others.
// Copyright 2021-2025 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
@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
#include "../../Fl_Screen_Driver.H"
#include "Fl_X11_Gl_Window_Driver.H"
#include <GL/glx.h>
#if ! USE_XFT
#if ! (USE_XFT || FLTK_USE_CAIRO)
# include "../Xlib/Fl_Font.H"
#endif
@ -51,7 +51,7 @@ void Fl_X11_Gl_Window_Driver::draw_string_legacy(const char* str, int n) { @@ -51,7 +51,7 @@ void Fl_X11_Gl_Window_Driver::draw_string_legacy(const char* str, int n) {
}
int Fl_X11_Gl_Window_Driver::genlistsize() {
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
return 256;
#else
return 0x10000;
@ -86,7 +86,7 @@ void Fl_X11_Gl_Window_Driver::gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize) { @@ -86,7 +86,7 @@ void Fl_X11_Gl_Window_Driver::gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize) {
void Fl_X11_Gl_Window_Driver::get_list(Fl_Font_Descriptor *fd, int r) {
# if USE_XFT
# if USE_XFT || FLTK_USE_CAIRO
/* We hope not to come here: We hope that any system using XFT will also
* have sufficient GL capability to support our font texture pile mechansim,
* allowing XFT to render the face directly. */
@ -107,7 +107,7 @@ void Fl_X11_Gl_Window_Driver::get_list(Fl_Font_Descriptor *fd, int r) { @@ -107,7 +107,7 @@ void Fl_X11_Gl_Window_Driver::get_list(Fl_Font_Descriptor *fd, int r) {
# endif
}
#if !USE_XFT
#if !(USE_XFT || FLTK_USE_CAIRO)
Fl_Font_Descriptor** Fl_X11_Gl_Window_Driver::fontnum_to_fontdescriptor(int fnum) {
Fl_Xlib_Fontdesc *s = ((Fl_Xlib_Fontdesc*)fl_fonts) + fnum;
return &(s->first);

6
src/drivers/X11/Fl_X11_Screen_Driver.H

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// Definition of X11 Screen interface
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2022 by Bill Spitzak and others.
// Copyright 2010-2025 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
@ -40,7 +40,7 @@ protected: @@ -40,7 +40,7 @@ protected:
short y_org;
short width;
short height;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
float scale;
#endif
} FLScreenInfo;
@ -49,7 +49,7 @@ protected: @@ -49,7 +49,7 @@ protected:
int get_mouse_unscaled(int &xx, int &yy);
public:
#if USE_XFT // scaling does not work without Xft
#if USE_XFT || FLTK_USE_CAIRO // scaling does not work without Xft
float current_xft_dpi; // current value of the Xft.dpi X resource
APP_SCALING_CAPABILITY rescalable() FL_OVERRIDE { return PER_SCREEN_APP_SCALING; }
float scale(int n) FL_OVERRIDE {return screens[n].scale;}

24
src/drivers/X11/Fl_X11_Screen_Driver.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Definition of X11 Screen interface
//
// Copyright 1998-2024 by Bill Spitzak and others.
// Copyright 1998-2025 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
@ -54,7 +54,7 @@ extern const char *fl_bg; @@ -54,7 +54,7 @@ extern const char *fl_bg;
extern const char *fl_bg2;
// end of extern additions workaround
#if !USE_XFT
#if !(USE_XFT || FLTK_USE_CAIRO)
extern char *fl_get_font_xfld(int fnum, int size);
#endif
@ -239,7 +239,7 @@ void Fl_X11_Screen_Driver::init_workarea() @@ -239,7 +239,7 @@ void Fl_X11_Screen_Driver::init_workarea()
int Fl_X11_Screen_Driver::x() {
if (!fl_display) open_display();
return fl_workarea_xywh[0]
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
/ screens[0].scale
#endif
;
@ -248,7 +248,7 @@ int Fl_X11_Screen_Driver::x() { @@ -248,7 +248,7 @@ int Fl_X11_Screen_Driver::x() {
int Fl_X11_Screen_Driver::y() {
if (!fl_display) open_display();
return fl_workarea_xywh[1]
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
/ screens[0].scale
#endif
;
@ -257,7 +257,7 @@ int Fl_X11_Screen_Driver::y() { @@ -257,7 +257,7 @@ int Fl_X11_Screen_Driver::y() {
int Fl_X11_Screen_Driver::w() {
if (!fl_display) open_display();
return fl_workarea_xywh[2]
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
/ screens[0].scale
#endif
;
@ -266,7 +266,7 @@ int Fl_X11_Screen_Driver::w() { @@ -266,7 +266,7 @@ int Fl_X11_Screen_Driver::w() {
int Fl_X11_Screen_Driver::h() {
if (!fl_display) open_display();
return fl_workarea_xywh[3]
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
/ screens[0].scale
#endif
;
@ -349,7 +349,7 @@ void Fl_X11_Screen_Driver::init() { @@ -349,7 +349,7 @@ void Fl_X11_Screen_Driver::init() {
screens[i].y_org = 0;
screens[i].width = DisplayWidth(fl_display, i);
screens[i].height = DisplayHeight(fl_display, i);
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
screens[i].scale = 1;
#endif
if (dpi_by_randr) {
@ -390,7 +390,7 @@ void Fl_X11_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n) @@ -390,7 +390,7 @@ void Fl_X11_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
n = 0;
if (num_screens > 0) {
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
float s = screens[n].scale;
#else
float s = 1;
@ -597,7 +597,7 @@ void Fl_X11_Screen_Driver::compose_reset() @@ -597,7 +597,7 @@ void Fl_X11_Screen_Driver::compose_reset()
}
int Fl_X11_Screen_Driver::text_display_can_leak() const {
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
return 1;
#else
return 0;
@ -1131,7 +1131,7 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int @@ -1131,7 +1131,7 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int
if (fs) {
XFreeFontSet(fl_display, fs);
}
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
fnt = NULL; // FIXME: missing XFT support here
#else
fnt = fl_get_font_xfld(font, size);
@ -1163,7 +1163,7 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int @@ -1163,7 +1163,7 @@ void Fl_X11_Screen_Driver::set_spot(int font, int size, int X, int Y, int W, int
}
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
//NOTICE: returns -1 if x,y is not in any screen
int Fl_X11_Screen_Driver::screen_num_unscaled(int x, int y)
{
@ -1198,4 +1198,4 @@ void Fl_X11_Screen_Driver::desktop_scale_factor() @@ -1198,4 +1198,4 @@ void Fl_X11_Screen_Driver::desktop_scale_factor()
}
}
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO

10
src/drivers/X11/Fl_X11_Window_Driver.H

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// Definition of X11 window driver
// for the Fast Light Tool Kit (FLTK).
//
// Copyright 2010-2024 by Bill Spitzak and others.
// Copyright 2010-2025 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
@ -66,14 +66,14 @@ private: @@ -66,14 +66,14 @@ private:
Fl_Image* shape_; ///< shape image
Fl_Bitmap *effective_bitmap_; ///< auxiliary bitmap image
} *shape_data_;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
// --- support for screen-specific scaling factors
struct type_for_resize_window_between_screens {
int screen;
bool busy;
};
static type_for_resize_window_between_screens data_for_resize_window_between_screens_;
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
#if FLTK_USE_CAIRO
cairo_t *cairo_;
#endif // FLTK_USE_CAIRO
@ -89,9 +89,9 @@ public: @@ -89,9 +89,9 @@ public:
Fl_X11_Window_Driver(Fl_Window*);
~Fl_X11_Window_Driver() FL_OVERRIDE;
static inline Fl_X11_Window_Driver* driver(const Fl_Window *w) {return (Fl_X11_Window_Driver*)Fl_Window_Driver::driver(w);}
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
static void resize_after_screen_change(void *data);
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
// --- window data
int decorated_w() FL_OVERRIDE;

6
src/drivers/X11/Fl_X11_Window_Driver.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Definition of X11 window driver.
//
// Copyright 1998-2024 by Bill Spitzak and others.
// Copyright 1998-2025 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
@ -561,7 +561,7 @@ Window fl_x11_xid(const Fl_Window *win) { @@ -561,7 +561,7 @@ Window fl_x11_xid(const Fl_Window *win) {
}
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
Fl_X11_Window_Driver::type_for_resize_window_between_screens Fl_X11_Window_Driver::data_for_resize_window_between_screens_ = {0, false};
@ -572,7 +572,7 @@ void Fl_X11_Window_Driver::resize_after_screen_change(void *data) { @@ -572,7 +572,7 @@ void Fl_X11_Window_Driver::resize_after_screen_change(void *data) {
data_for_resize_window_between_screens_.busy = false;
}
#endif // USE_XFT
#endif // USE_XFT || FLTK_USE_CAIRO
fl_uintptr_t Fl_X11_Window_Driver::os_id() {
return fl_xid(pWindow);

4
src/drivers/X11/fl_X11_platform_init.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// X11-specific code to initialize wayland support.
//
// Copyright 2022-2023 by Bill Spitzak and others.
// Copyright 2022-2025 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
@ -47,7 +47,7 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() @@ -47,7 +47,7 @@ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
{
Fl_X11_Screen_Driver *d = new Fl_X11_Screen_Driver();
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
for (int i = 0; i < MAX_SCREENS; i++) d->screens[i].scale = 1;
d->current_xft_dpi = 0.; // means the value of the Xft.dpi resource is still unknown
#else

4
src/drivers/Xlib/Fl_Font.H

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Font definitions for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2018 by Bill Spitzak and others.
// Copyright 1998-2025 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
@ -32,7 +32,7 @@ typedef struct _XftFont XftFont; @@ -32,7 +32,7 @@ typedef struct _XftFont XftFont;
class Fl_Xlib_Font_Descriptor : public Fl_Font_Descriptor {
public:
# if USE_XFT
# if USE_XFT || FLTK_USE_CAIRO
# if USE_PANGO
int descent_;
int height_;

8
src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2022 by Bill Spitzak and others.
// Copyright 1998-2025 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
@ -24,10 +24,6 @@ @@ -24,10 +24,6 @@
#include <string.h>
#include <stdlib.h>
#if !USE_XFT
extern char *fl_get_font_xfld(int fnum, int size);
#endif
GC Fl_Xlib_Graphics_Driver::gc_ = NULL;
int Fl_Xlib_Graphics_Driver::fl_overlay = 0;
@ -62,7 +58,7 @@ void Fl_Xlib_Graphics_Driver::gc(void *value) { @@ -62,7 +58,7 @@ void Fl_Xlib_Graphics_Driver::gc(void *value) {
}
void Fl_Xlib_Graphics_Driver::scale(float f) {
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
if (f != scale()) {
size_ = 0;
Fl_Graphics_Driver::scale(f);

8
src/fl_dnd_x.cxx

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
//
// Drag & Drop code for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2023 by Bill Spitzak and others.
// Copyright 1998-2025 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
@ -106,7 +106,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) { @@ -106,7 +106,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) {
if ((new_local_window = fl_find(child))) break;
if ((new_version = dnd_aware(new_window))) break;
}
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
if (new_local_window) {
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(new_local_window)->screen_num());
Fl::e_x_root /= s;
@ -158,7 +158,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) { @@ -158,7 +158,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) {
local_handle(FL_DND_DRAG, local_window);
} else if (dndversion) {
int exroot = Fl::e_x_root, eyroot = Fl::e_y_root;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
Fl_Window *target = fl_find(target_window);
if (target) {
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num());
@ -189,7 +189,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) { @@ -189,7 +189,7 @@ int Fl_X11_Screen_Driver::dnd(int unused) {
msg.x = dest_x;
msg.y = dest_y;
float s = 1;
#if USE_XFT
#if USE_XFT || FLTK_USE_CAIRO
Fl_Window *target = fl_find(target_window);
if (target) s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num());
#endif

14
src/xutf8/lcUniConv/cp936ext.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
/*
* Character encoding support for the Fast Light Tool Kit (FLTK).
*
* Copyright 1998-2018 by Bill Spitzak and others.
* Copyright 1998-2025 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
@ -13,12 +13,8 @@ @@ -13,12 +13,8 @@
*
* https://www.fltk.org/bugs.php
*/
#if defined(_WIN32) || defined(__APPLE__) /* PORTME: is this really needed? It's huge! */
/* not needed */
#else
#include <FL/fl_config.h>
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(FLTK_USE_X11))
#ifndef CP936
#ifdef NEED_TOWC
@ -38,7 +34,7 @@ cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) @@ -38,7 +34,7 @@ cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
}
#endif /* NEED_TOMB */
#else
#else /* CP936 */
/*
* CP936EXT
*/
@ -6246,4 +6242,4 @@ cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) @@ -6246,4 +6242,4 @@ cp936ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
#endif /* CP936 */
#endif /* _WIN32 || __APPLE__ */ /* PORTME: Unicode stuff */
#endif /* _WIN32 || __APPLE__ */

Loading…
Cancel
Save