FLTK logo

[master] 7ec6f96 - Add "fl_" prefix to libdecor symbols when using the built-in copy of libdecor

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 7ec6f96 - Add "fl_" prefix to libdecor symbols when using the built-in copy of libdecor "ManoloFLTK" 04:47 Apr 20  
 
commit 7ec6f96d9c53f23e9137a2deea2cbf71f959534e
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sat Apr 20 13:35:53 2024 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sat Apr 20 13:35:53 2024 +0200

    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.

 configure.ac                                     |  6 +-
 libdecor/build/fl_libdecor-plugins.c             |  2 +-
 libdecor/build/fl_libdecor.c                     | 15 ++--
 libdecor/build/fl_libdecor.h                     | 92 ++++++++++++++++++++++++
 src/CMakeLists.txt                               |  5 ++
 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx |  2 +-
 src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx |  2 +-
 7 files changed, 115 insertions(+), 9 deletions(-)

diff --git configure.ac configure.ac
index ad2dd59..049be70 100644
--- configure.ac
+++ configure.ac
@@ -1096,10 +1096,14 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
       [
         plugin_dir="$($PKGCONFIG --variable=libdir libdecor-0)/libdecor/plugins-1"
         CFLAGS="$CFLAGS -DUSE_SYSTEM_LIBDECOR"
+        CXXFLAGS="$CXXFLAGS -DUSE_SYSTEM_LIBDECOR"
         CFLAGS="$CFLAGS -DLIBDECOR_PLUGIN_DIR=\\\"$plugin_dir\\\" "
         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) "
       AS_IF([test x$enable_x11 != xno], [LIBS="$LIBS $($PKGCONFIG --libs x11)"] )
diff --git libdecor/build/fl_libdecor-plugins.c libdecor/build/fl_libdecor-plugins.c
index 60f6bf5..f04f8cf 100644
--- libdecor/build/fl_libdecor-plugins.c
+++ libdecor/build/fl_libdecor-plugins.c
@@ -24,7 +24,7 @@
 
 #include <dlfcn.h>
 #include <string.h>
-#include "../src/libdecor.h"
+#include "fl_libdecor.h"
 #include <pango/pangocairo.h>
 #include <dlfcn.h>
 
diff --git libdecor/build/fl_libdecor.c libdecor/build/fl_libdecor.c
index 71a4fc3..7026827 100644
--- libdecor/build/fl_libdecor.c
+++ libdecor/build/fl_libdecor.c
@@ -1,7 +1,7 @@
 //
 // 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
 // the file "COPYING" which should have been included with this file.  If this
@@ -22,15 +22,20 @@
 #  define HAVE_XDG_SHELL_V6 1
 #endif
 
-#define libdecor_frame_set_minimized libdecor_frame_set_minimized_orig
-#define libdecor_new libdecor_new_orig
 #include <dlfcn.h>
 static void *dlopen_corrected(const char *, int);
 #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"
 #undef dlopen
 #undef libdecor_frame_set_minimized
 #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 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 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.
  
  */
-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;
   context = zalloc(sizeof *context);
diff --git libdecor/build/fl_libdecor.h libdecor/build/fl_libdecor.h
new file mode 100644
index 0000000..87cbd31
--- /dev/null
+++ libdecor/build/fl_libdecor.h
@@ -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
diff --git src/CMakeLists.txt src/CMakeLists.txt
index dfbdfa2..2770e9b 100644
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -575,6 +575,11 @@ if(FLTK_BACKEND_WAYLAND)
       COMPILE_OPTIONS "${COPTS}"
       )
   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
     scandir_posix.c
diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 6001139..92e9530 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -18,7 +18,7 @@
 #include "Fl_Wayland_Window_Driver.H"
 #include "Fl_Wayland_Graphics_Driver.H"
 #include <wayland-cursor.h>
-#include "../../../libdecor/src/libdecor.h"
+#include "../../../libdecor/build/fl_libdecor.h"
 #include "xdg-shell-client-protocol.h"
 #include "../Posix/Fl_Posix_System_Driver.H"
 #include <FL/Fl.H>
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index ff1682e..e1b5b0b 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -20,7 +20,7 @@
 #include "Fl_Wayland_Graphics_Driver.H"
 #include <FL/filename.H>
 #include <wayland-cursor.h>
-#include "../../../libdecor/src/libdecor.h"
+#include "../../../libdecor/build/fl_libdecor.h"
 #include "xdg-shell-client-protocol.h"
 #include <pango/pangocairo.h>
 #include <FL/Fl_Overlay_Window.H>
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.