Add "fl_" prefix to libdecor symbols when using the built-in copy of libdecor

This allows client apps to use other versions of libdecor if they wish,
just like what FLTK already does with libpng and libjpeg.
This commit is contained in:
ManoloFLTK 2024-04-20 13:35:53 +02:00
parent d2bd3c6240
commit 7ec6f96d9c
7 changed files with 115 additions and 9 deletions

View File

@ -1096,10 +1096,14 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
[ [
plugin_dir="$($PKGCONFIG --variable=libdir libdecor-0)/libdecor/plugins-1" plugin_dir="$($PKGCONFIG --variable=libdir libdecor-0)/libdecor/plugins-1"
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR" CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR"
CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR"
CFLAGS="$CFLAGS -DLIBDECOR_PLUGIN_DIR=\\\"$plugin_dir\\\" " CFLAGS="$CFLAGS -DLIBDECOR_PLUGIN_DIR=\\\"$plugin_dir\\\" "
LIBS="$LIBS $($PKGCONFIG --libs libdecor-0)" LIBS="$LIBS $($PKGCONFIG --libs libdecor-0)"
], ],
[CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0 -DLIBDECOR_PLUGIN_DIR=\\\"\\\" "] [
CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR=0 -DLIBDECOR_PLUGIN_DIR=\\\"\\\" "
CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR=0"
]
) )
LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangocairo) " LIBS="$LIBS $($PKGCONFIG --libs wayland-cursor) $($PKGCONFIG --libs wayland-client) $($PKGCONFIG --libs xkbcommon) $($PKGCONFIG --libs pangocairo) "
AS_IF([test x$enable_x11 != xno], [LIBS="$LIBS $($PKGCONFIG --libs x11)"] ) AS_IF([test x$enable_x11 != xno], [LIBS="$LIBS $($PKGCONFIG --libs x11)"] )

View File

@ -24,7 +24,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <string.h> #include <string.h>
#include "../src/libdecor.h" #include "fl_libdecor.h"
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#include <dlfcn.h> #include <dlfcn.h>

View File

@ -1,7 +1,7 @@
// //
// Interface with the libdecor library for the Fast Light Tool Kit (FLTK). // Interface with the libdecor library for the Fast Light Tool Kit (FLTK).
// //
// Copyright 2022-2023 by Bill Spitzak and others. // Copyright 2022-2024 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // 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 // the file "COPYING" which should have been included with this file. If this
@ -22,15 +22,20 @@
# define HAVE_XDG_SHELL_V6 1 # define HAVE_XDG_SHELL_V6 1
#endif #endif
#define libdecor_frame_set_minimized libdecor_frame_set_minimized_orig
#define libdecor_new libdecor_new_orig
#include <dlfcn.h> #include <dlfcn.h>
static void *dlopen_corrected(const char *, int); static void *dlopen_corrected(const char *, int);
#define dlopen(A, B) dlopen_corrected(A, B) #define dlopen(A, B) dlopen_corrected(A, B)
#include "fl_libdecor.h"
#undef libdecor_new
#define libdecor_new libdecor_new_orig
#undef libdecor_frame_set_minimized
#define libdecor_frame_set_minimized libdecor_frame_set_minimized_orig
#include "../src/libdecor.c" #include "../src/libdecor.c"
#undef dlopen #undef dlopen
#undef libdecor_frame_set_minimized #undef libdecor_frame_set_minimized
#undef libdecor_new #undef libdecor_new
#define libdecor_new fl_libdecor_new
#define libdecor_frame_set_minimized fl_libdecor_frame_set_minimized
extern bool fl_libdecor_using_weston(void); extern bool fl_libdecor_using_weston(void);
extern const struct libdecor_plugin_description *fl_libdecor_plugin_description; extern const struct libdecor_plugin_description *fl_libdecor_plugin_description;
@ -57,7 +62,7 @@ static void *dlopen_corrected(const char *filename, int flags) {
} }
LIBDECOR_EXPORT void libdecor_frame_set_minimized(struct libdecor_frame *frame) void fl_libdecor_frame_set_minimized(struct libdecor_frame *frame)
{ {
static bool done = false; static bool done = false;
static bool using_weston = false; static bool using_weston = false;
@ -104,7 +109,7 @@ LIBDECOR_EXPORT void libdecor_frame_set_minimized(struct libdecor_frame *frame)
so a plugin may be loaded that way only if FLTK was built with FLTK_USE_SYSTEM_LIBDECOR turned ON. so a plugin may be loaded that way only if FLTK was built with FLTK_USE_SYSTEM_LIBDECOR turned ON.
*/ */
LIBDECOR_EXPORT struct libdecor *libdecor_new(struct wl_display *wl_display, const struct libdecor_interface *iface) struct libdecor *fl_libdecor_new(struct wl_display *wl_display, const struct libdecor_interface *iface)
{ {
struct libdecor *context; struct libdecor *context;
context = zalloc(sizeof *context); context = zalloc(sizeof *context);

View File

@ -0,0 +1,92 @@
//
// Interface with the libdecor library for the Fast Light Tool Kit (FLTK).
//
// Copyright 2024 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
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#ifndef FL_LIBDECOR_H
#define FL_LIBDECOR_H
#if ! USE_SYSTEM_LIBDECOR
// add "fl_" prefix to libdecor.h symbols
#define libdecor_unref fl_libdecor_unref
#define libdecor_new fl_libdecor_new
#define libdecor_new_with_user_data fl_libdecor_new_with_user_data
#define libdecor_get_user_data fl_libdecor_get_user_data
#define libdecor_set_user_data fl_libdecor_set_user_data
#define libdecor_get_fd fl_libdecor_get_fd
#define libdecor_dispatch fl_libdecor_dispatch
#define libdecor_decorate fl_libdecor_decorate
#define libdecor_frame_ref fl_libdecor_frame_ref
#define libdecor_frame_unref fl_libdecor_frame_unref
#define libdecor_frame_get_user_data fl_libdecor_frame_get_user_data
#define libdecor_frame_set_user_data fl_libdecor_frame_set_user_data
#define libdecor_frame_set_visibility fl_libdecor_frame_set_visibility
#define libdecor_frame_is_visible fl_libdecor_frame_is_visible
#define libdecor_frame_set_parent fl_libdecor_frame_set_parent
#define libdecor_frame_set_title fl_libdecor_frame_set_title
#define libdecor_frame_get_title fl_libdecor_frame_get_title
#define libdecor_frame_set_app_id fl_libdecor_frame_set_app_id
#define libdecor_frame_set_capabilities fl_libdecor_frame_set_capabilities
#define libdecor_frame_unset_capabilities fl_libdecor_frame_unset_capabilitiesf
#define libdecor_frame_has_capability fl_libdecor_frame_has_capability
#define libdecor_frame_show_window_menu fl_libdecor_frame_show_window_menu
#define libdecor_frame_popup_grab fl_libdecor_frame_popup_grab
#define libdecor_frame_popup_ungrab fl_libdecor_frame_popup_ungrab
#define libdecor_frame_translate_coordinate fl_libdecor_frame_translate_coordinate
#define libdecor_frame_set_min_content_size fl_libdecor_frame_set_min_content_size
#define libdecor_frame_set_max_content_size fl_libdecor_frame_set_max_content_size
#define libdecor_frame_get_min_content_size fl_libdecor_frame_get_min_content_size
#define libdecor_frame_get_max_content_size fl_libdecor_frame_get_max_content_size
#define libdecor_frame_resize fl_libdecor_frame_resize
#define libdecor_frame_move fl_libdecor_frame_move
#define libdecor_frame_commit fl_libdecor_frame_commit
#define libdecor_frame_set_minimized fl_libdecor_frame_set_minimized
#define libdecor_frame_set_maximized fl_libdecor_frame_set_maximized
#define libdecor_frame_unset_maximized fl_libdecor_frame_unset_maximized
#define libdecor_frame_set_fullscreen fl_libdecor_frame_set_fullscreen
#define libdecor_frame_unset_fullscreen fl_libdecor_frame_unset_fullscreen
#define libdecor_frame_is_floating fl_libdecor_frame_is_floating
#define libdecor_frame_close fl_libdecor_frame_close
#define libdecor_frame_map fl_libdecor_frame_map
#define libdecor_frame_get_xdg_surface fl_libdecor_frame_get_xdg_surface
#define libdecor_frame_get_xdg_toplevel fl_libdecor_frame_get_xdg_toplevel
#define libdecor_frame_get_wm_capabilities fl_libdecor_frame_get_wm_capabilities
#define libdecor_state_new fl_libdecor_state_new
#define libdecor_state_free fl_libdecor_state_free
#define libdecor_configuration_get_content_size fl_libdecor_configuration_get_content_size
#define libdecor_configuration_get_window_state fl_libdecor_configuration_get_window_state
// add "fl_" prefix to libdecor-plugin.h symbols
#define libdecor_frame_get_wl_surface fl_libdecor_frame_get_wl_surface
#define libdecor_frame_get_content_width fl_libdecor_frame_get_content_width
#define libdecor_frame_get_content_height fl_libdecor_frame_get_content_height
#define libdecor_frame_get_window_state fl_libdecor_frame_get_window_state
#define libdecor_frame_get_capabilities fl_libdecor_frame_get_capabilities
#define libdecor_frame_dismiss_popup fl_libdecor_frame_dismiss_popup
#define libdecor_frame_toplevel_commit fl_libdecor_frame_toplevel_commit
#define libdecor_get_wl_display fl_libdecor_get_wl_display
#define libdecor_notify_plugin_ready fl_libdecor_notify_plugin_ready
#define libdecor_notify_plugin_error fl_libdecor_notify_plugin_error
#define libdecor_state_get_content_width fl_libdecor_state_get_content_width
#define libdecor_state_get_content_height fl_libdecor_state_get_content_height
#define libdecor_state_get_window_state fl_libdecor_state_get_window_state
#define libdecor_plugin_init fl_libdecor_plugin_init
#define libdecor_plugin_release fl_libdecor_plugin_release
#endif // ! USE_SYSTEM_LIBDECOR
#include "../src/libdecor.h"
#endif // ! FL_LIBDECOR_H

View File

@ -575,6 +575,11 @@ if(FLTK_BACKEND_WAYLAND)
COMPILE_OPTIONS "${COPTS}" COMPILE_OPTIONS "${COPTS}"
) )
endif(USE_SYSTEM_LIBDECOR) endif(USE_SYSTEM_LIBDECOR)
set_source_files_properties(
${FLTK_SOURCE_DIR}/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
${FLTK_SOURCE_DIR}/src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
PROPERTIES COMPILE_DEFINITIONS "USE_SYSTEM_LIBDECOR=${USE_SYSTEM_LIBDECOR}"
)
list(APPEND CFILES list(APPEND CFILES
scandir_posix.c scandir_posix.c

View File

@ -18,7 +18,7 @@
#include "Fl_Wayland_Window_Driver.H" #include "Fl_Wayland_Window_Driver.H"
#include "Fl_Wayland_Graphics_Driver.H" #include "Fl_Wayland_Graphics_Driver.H"
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include "../../../libdecor/src/libdecor.h" #include "../../../libdecor/build/fl_libdecor.h"
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include "../Posix/Fl_Posix_System_Driver.H" #include "../Posix/Fl_Posix_System_Driver.H"
#include <FL/Fl.H> #include <FL/Fl.H>

View File

@ -20,7 +20,7 @@
#include "Fl_Wayland_Graphics_Driver.H" #include "Fl_Wayland_Graphics_Driver.H"
#include <FL/filename.H> #include <FL/filename.H>
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include "../../../libdecor/src/libdecor.h" #include "../../../libdecor/build/fl_libdecor.h"
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#include <FL/Fl_Overlay_Window.H> #include <FL/Fl_Overlay_Window.H>