- Setup dynamic linking to libdecor

This commit is contained in:
2025-12-15 15:23:30 -05:00
parent 1acf00138a
commit b64ce44d4e
9 changed files with 386 additions and 13 deletions

View File

@@ -0,0 +1,80 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file libdecor.h
/// \brief
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LIBDECOR_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LIBDECOR_H
#include <libdecor.h>
#define FENNEC_LIB(name) extern "C" bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using LIBDECOR_sym_##fn = ret(*)(__VA_ARGS__); \
extern "C" LIBDECOR_sym_##fn WAYLAND_##fn;
#define FENNEC_GLOBAL(type, name) extern "C" type* LIBDECOR_##name;
#include <fennec/platform/linux/wayland/libdecor/sym.h>
#define libdecor_unref WAYLAND_libdecor_unref
#define libdecor_new WAYLAND_libdecor_new
#define libdecor_decorate WAYLAND_libdecor_decorate
#define libdecor_frame_unref WAYLAND_libdecor_frame_unref
#define libdecor_frame_set_title WAYLAND_libdecor_frame_set_title
#define libdecor_frame_set_app_id WAYLAND_libdecor_frame_set_app_id
#define libdecor_frame_set_max_content_size WAYLAND_libdecor_frame_set_max_content_size
#define libdecor_frame_get_max_content_size WAYLAND_libdecor_frame_get_max_content_size
#define libdecor_frame_set_min_content_size WAYLAND_libdecor_frame_set_min_content_size
#define libdecor_frame_get_min_content_size WAYLAND_libdecor_frame_get_min_content_size
#define libdecor_frame_resize WAYLAND_libdecor_frame_resize
#define libdecor_frame_move WAYLAND_libdecor_frame_move
#define libdecor_frame_commit WAYLAND_libdecor_frame_commit
#define libdecor_frame_set_minimized WAYLAND_libdecor_frame_set_minimized
#define libdecor_frame_set_maximized WAYLAND_libdecor_frame_set_maximized
#define libdecor_frame_unset_maximized WAYLAND_libdecor_frame_unset_maximized
#define libdecor_frame_set_fullscreen WAYLAND_libdecor_frame_set_fullscreen
#define libdecor_frame_unset_fullscreen WAYLAND_libdecor_frame_unset_fullscreen
#define libdecor_frame_set_capabilities WAYLAND_libdecor_frame_set_capabilities
#define libdecor_frame_unset_capabilities WAYLAND_libdecor_frame_unset_capabilities
#define libdecor_frame_has_capability WAYLAND_libdecor_frame_has_capability
#define libdecor_frame_set_visibility WAYLAND_libdecor_frame_set_visibility
#define libdecor_frame_is_visible WAYLAND_libdecor_frame_is_visible
#define libdecor_frame_is_floating WAYLAND_libdecor_frame_is_floating
#define libdecor_frame_set_parent WAYLAND_libdecor_frame_set_parent
#define libdecor_frame_show_window_menu WAYLAND_libdecor_frame_show_window_menu
#define libdecor_frame_get_wm_capabilities WAYLAND_libdecor_frame_get_wm_capabilities
#define libdecor_frame_get_xdg_surface WAYLAND_libdecor_frame_get_xdg_surface
#define libdecor_frame_get_xdg_toplevel WAYLAND_libdecor_frame_get_xdg_toplevel
#define libdecor_frame_translate_coordinate WAYLAND_libdecor_frame_translate_coordinate
#define libdecor_frame_map WAYLAND_libdecor_frame_map
#define libdecor_state_new WAYLAND_libdecor_state_new
#define libdecor_state_free WAYLAND_libdecor_state_free
#define libdecor_configuration_get_content_size WAYLAND_libdecor_configuration_get_content_size
#define libdecor_configuration_get_window_state WAYLAND_libdecor_configuration_get_window_state
#define libdecor_dispatch WAYLAND_libdecor_dispatch
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LIBDECOR_H

View File

@@ -0,0 +1,50 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
///
/// \file loader.h
/// \brief
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LOADER_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LOADER_H
#include <fennec/platform/interface/platform.h>
namespace fennec
{
namespace libdecor
{
bool load_symbols(platform* platform);
void unload_symbols(platform* platform);
}
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_LIBDECOR_LOADER_H

View File

@@ -0,0 +1,96 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <fennec/lang/types.h>
#ifndef FENNEC_LIB
#define FENNEC_LIB(...)
#endif
#ifndef FENNEC_SYMBOL
#define FENNEC_SYMBOL(...)
#endif
#ifndef FENNEC_GLOBAL
#define FENNEC_GLOBAL(...)
#endif
FENNEC_LIB(LIBDECOR)
FENNEC_SYMBOL(void, libdecor_unref, struct libdecor*)
FENNEC_SYMBOL(int, libdecor_dispatch, struct libdecor*, int)
FENNEC_SYMBOL(struct libdecor*, libdecor_new, struct wl_display*, \
struct libdecor_interface*)
FENNEC_SYMBOL(struct libdecor_frame*, libdecor_decorate, struct libdecor*, \
struct wl_surface*, \
struct libdecor_frame_interface*, void*)
FENNEC_SYMBOL(void, libdecor_frame_unref, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_set_title, struct libdecor_frame*, const char*)
FENNEC_SYMBOL(void, libdecor_frame_set_app_id, struct libdecor_frame*, const char*)
FENNEC_SYMBOL(void, libdecor_frame_set_max_content_size, struct libdecor_frame*, int, int)
FENNEC_SYMBOL(void, libdecor_frame_set_min_content_size, struct libdecor_frame*, int, int)
FENNEC_SYMBOL(void, libdecor_frame_get_min_content_size, const struct libdecor_frame*, int*, int*)
FENNEC_SYMBOL(void, libdecor_frame_get_max_content_size, const struct libdecor_frame*, int*, int*)
FENNEC_SYMBOL(void, libdecor_frame_resize, struct libdecor_frame*, struct wl_seat*, uint32_t, \
enum libdecor_resize_edge)
FENNEC_SYMBOL(void, libdecor_frame_move, struct libdecor_frame*, struct wl_seat*, uint32_t)
FENNEC_SYMBOL(void, libdecor_frame_commit, struct libdecor_frame*, struct libdecor_state*,\
struct libdecor_configuration*)
FENNEC_SYMBOL(void, libdecor_frame_set_minimized, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_set_maximized, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_unset_maximized, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_set_fullscreen, struct libdecor_frame*, struct wl_output*)
FENNEC_SYMBOL(void, libdecor_frame_unset_fullscreen, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_set_capabilities, struct libdecor_frame*, enum libdecor_capabilities)
FENNEC_SYMBOL(void, libdecor_frame_unset_capabilities, struct libdecor_frame*, enum libdecor_capabilities)
FENNEC_SYMBOL(bool, libdecor_frame_has_capability, struct libdecor_frame*, enum libdecor_capabilities)
FENNEC_SYMBOL(void, libdecor_frame_set_visibility, struct libdecor_frame*, bool)
FENNEC_SYMBOL(bool, libdecor_frame_is_visible, struct libdecor_frame*)
FENNEC_SYMBOL(bool, libdecor_frame_is_floating, struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_set_parent, struct libdecor_frame*,\
struct libdecor_frame*)
FENNEC_SYMBOL(void, libdecor_frame_show_window_menu, struct libdecor_frame*, struct wl_seat*, uint32_t, int, int)
FENNEC_SYMBOL(void, libdecor_frame_translate_coordinate, struct libdecor_frame*, int, int, int*, int*)
FENNEC_SYMBOL(void, libdecor_frame_map, struct libdecor_frame*)
FENNEC_SYMBOL(struct xdg_surface*, libdecor_frame_get_xdg_surface, struct libdecor_frame*)
FENNEC_SYMBOL(struct xdg_toplevel*, libdecor_frame_get_xdg_toplevel, struct libdecor_frame*)
FENNEC_SYMBOL(struct libdecor_state*, libdecor_state_new, int, int)
FENNEC_SYMBOL(void, libdecor_state_free, struct libdecor_state*)
FENNEC_SYMBOL(bool, libdecor_configuration_get_content_size, struct libdecor_configuration*,\
struct libdecor_frame*,\
int*,\
int*)
FENNEC_SYMBOL(bool, libdecor_configuration_get_window_state, struct libdecor_configuration*,\
enum libdecor_window_state*)
#undef FENNEC_LIB
#undef FENNEC_SYMBOL
#undef FENNEC_GLOBAL

View File

@@ -71,7 +71,7 @@ private:
wl_compositor* compositor;
xdg_wm_base* xdg;
wl_seat* seat;
bool fifo;
bool fifo, libdecor;
static void listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
static void listen_global_remove(void*, wl_registry*, uint32_t);