- Setup dynamic linking to libdecor
This commit is contained in:
@@ -34,7 +34,7 @@ endif()
|
|||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
|
|
||||||
if(TARGET OpenGL::GL AND TARGET GLEW::GLEW)
|
if(TARGET OpenGL::GL AND TARGET GLEW::GLEW)
|
||||||
message(STATUS "Found OpenGL: ${OPENGL_gl_LIBRARY}")
|
message(STATUS "Found OpenGL: ${OPENGL_LIBRARIES}")
|
||||||
fennec_add_link_libraries(OpenGL::GL GLEW::GLEW)
|
fennec_add_link_libraries(OpenGL::GL GLEW::GLEW)
|
||||||
fennec_add_definitions(FENNEC_GRAPHICS_OPENGL=1)
|
fennec_add_definitions(FENNEC_GRAPHICS_OPENGL=1)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,17 @@
|
|||||||
|
|
||||||
# some of this code is based on SDL3's use of wayland-scanner
|
# some of this code is based on SDL3's use of wayland-scanner
|
||||||
|
|
||||||
|
function(fennec_wayland_get_protocol)
|
||||||
|
set( _OPTIONS_ARGS )
|
||||||
|
set( _ONE_VALUE_ARGS )
|
||||||
|
set( _MULTI_VALUE_ARGS NAMES PATHS )
|
||||||
|
|
||||||
|
cmake_parse_arguments(_FINDPROTOCOLS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
|
||||||
|
|
||||||
|
find_file(_FINDPROTOCOLS_TEMP NAMES ${_FINDPROTOCOLS_NAMES} PATHS ${_FINDPROTOCOLS_PATHS})
|
||||||
|
file(COPY ${_FINDPROTOCOLS_TEMP} DESTINATION ${WAYLAND_PROTOCOLS_DIR})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
macro(fennec_wayland_get_header _SCANNER _XML _FILE)
|
macro(fennec_wayland_get_header _SCANNER _XML _FILE)
|
||||||
set(_WAYLAND_PROT_H_CODE "${WAYLAND_HEADERS_DIR}/${_FILE}-client-protocols.h")
|
set(_WAYLAND_PROT_H_CODE "${WAYLAND_HEADERS_DIR}/${_FILE}-client-protocols.h")
|
||||||
set(_WAYLAND_PROT_C_CODE "${WAYLAND_SOURCES_DIR}/${_FILE}-client.c")
|
set(_WAYLAND_PROT_C_CODE "${WAYLAND_SOURCES_DIR}/${_FILE}-client.c")
|
||||||
@@ -59,6 +70,7 @@ macro(fennec_check_wayland)
|
|||||||
NAMES wayland-egl libwayland-egl
|
NAMES wayland-egl libwayland-egl
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY AND WAYLAND_SCANNER)
|
if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY AND WAYLAND_SCANNER)
|
||||||
AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY))
|
AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY))
|
||||||
message(STATUS "Found Wayland: ${WAYLAND_CLIENT_LIBRARY}")
|
message(STATUS "Found Wayland: ${WAYLAND_CLIENT_LIBRARY}")
|
||||||
@@ -68,12 +80,8 @@ macro(fennec_check_wayland)
|
|||||||
set(WAYLAND_SOURCES_DIR ${FENNEC_SOURCE_DIR}/source/platform/linux/wayland/lib/sources)
|
set(WAYLAND_SOURCES_DIR ${FENNEC_SOURCE_DIR}/source/platform/linux/wayland/lib/sources)
|
||||||
|
|
||||||
# Search for base protocol xml
|
# Search for base protocol xml
|
||||||
find_file(WAYLAND_PROTOCOL NAMES wayland.xml PATHS /usr/share/wayland /usr/share/wayland-protocols)
|
fennec_wayland_get_protocol(NAMES "wayland.xml" PATHS "/usr/share/wayland" "/usr/share/wayland-protocols")
|
||||||
file(COPY ${WAYLAND_PROTOCOL} DESTINATION ${WAYLAND_PROTOCOLS_DIR})
|
fennec_wayland_get_protocol(NAMES "xdg-shell.xml" PATHS "/usr/share/wayland/stable/xdg-shell" "/usr/share/wayland-protocols/stable/xdg-shell")
|
||||||
|
|
||||||
# search for xdg protocols
|
|
||||||
find_file(XDG_SHELL_PROTOCOL NAMES xdg-shell.xml PATHS /usr/share/wayland-protocols/stable/xdg-shell)
|
|
||||||
file(COPY ${XDG_SHELL_PROTOCOL} DESTINATION ${WAYLAND_PROTOCOLS_DIR})
|
|
||||||
|
|
||||||
# include sub-dependencies
|
# include sub-dependencies
|
||||||
include("${FENNEC_SOURCE_DIR}/cmake/xkb.cmake")
|
include("${FENNEC_SOURCE_DIR}/cmake/xkb.cmake")
|
||||||
@@ -123,5 +131,38 @@ macro(fennec_check_wayland)
|
|||||||
FENNEC_LIB_WAYLAND="${WAYLAND_CLIENT_LIBRARY}"
|
FENNEC_LIB_WAYLAND="${WAYLAND_CLIENT_LIBRARY}"
|
||||||
FENNEC_LIB_WAYLAND_EGL="${WAYLAND_EGL_LIBRARY}"
|
FENNEC_LIB_WAYLAND_EGL="${WAYLAND_EGL_LIBRARY}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# find libdecor
|
||||||
|
find_path(
|
||||||
|
LIBDECOR_INCLUDE_DIR
|
||||||
|
PATH_SUFFIXES libdecor libdecor-0
|
||||||
|
NAMES libdecor.h libdecor.h
|
||||||
|
)
|
||||||
|
find_library(
|
||||||
|
LIBDECOR_LIBRARY
|
||||||
|
PATH_SUFFIXES libdecor libdecor-0
|
||||||
|
NAMES libdecor.so libdecor-0.so
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LIBDECOR_INCLUDE_DIR AND LIBDECOR_LIBRARY)
|
||||||
|
message(STATUS "Found libdecor: ${LIBDECOR_LIBRARY}")
|
||||||
|
|
||||||
|
fennec_add_definitions(
|
||||||
|
FENNEC_HAS_LIBDECOR=1
|
||||||
|
FENNEC_LIB_LIBDECOR="${LIBDECOR_LIBRARY}"
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${LIBDECOR_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
fennec_add_sources(
|
||||||
|
include/fennec/platform/linux/wayland/libdecor/sym.h
|
||||||
|
include/fennec/platform/linux/wayland/libdecor/libdecor.h
|
||||||
|
include/fennec/platform/linux/wayland/libdecor/loader.h source/platform/linux/wayland/libdecor/loader.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
80
include/fennec/platform/linux/wayland/libdecor/libdecor.h
Normal file
80
include/fennec/platform/linux/wayland/libdecor/libdecor.h
Normal 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
|
||||||
50
include/fennec/platform/linux/wayland/libdecor/loader.h
Normal file
50
include/fennec/platform/linux/wayland/libdecor/loader.h
Normal 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
|
||||||
96
include/fennec/platform/linux/wayland/libdecor/sym.h
Normal file
96
include/fennec/platform/linux/wayland/libdecor/sym.h
Normal 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
|
||||||
@@ -71,7 +71,7 @@ private:
|
|||||||
wl_compositor* compositor;
|
wl_compositor* compositor;
|
||||||
xdg_wm_base* xdg;
|
xdg_wm_base* xdg;
|
||||||
wl_seat* seat;
|
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(void*, wl_registry*, uint32_t, const char*, uint32_t);
|
||||||
static void listen_global_remove(void*, wl_registry*, uint32_t);
|
static void listen_global_remove(void*, wl_registry*, uint32_t);
|
||||||
|
|||||||
87
source/platform/linux/wayland/libdecor/loader.cpp
Normal file
87
source/platform/linux/wayland/libdecor/loader.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// =====================================================================================================================
|
||||||
|
// 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 <libdecor.h>
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/loader.h>
|
||||||
|
|
||||||
|
#define FENNEC_LIB(name) bool FENNEC_HAS_LIB_##name;
|
||||||
|
#define FENNEC_SYMBOL(ret, fn, ...) using LIBDECOR_sym_##fn = ret(*)(__VA_ARGS__); \
|
||||||
|
LIBDECOR_sym_##fn LIBDECOR_##fn;
|
||||||
|
#define FENNEC_GLOBAL(type, name) type* LIBDECOR_##name;
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/sym.h>
|
||||||
|
|
||||||
|
namespace fennec
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace libdecor
|
||||||
|
{
|
||||||
|
|
||||||
|
using shared_object = platform::shared_object;
|
||||||
|
|
||||||
|
struct shared_lib {
|
||||||
|
shared_object* obj;
|
||||||
|
const cstring name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int _load_count = 0;
|
||||||
|
|
||||||
|
// Create private variables
|
||||||
|
#define FENNEC_LIB(lib) static shared_lib _FENNEC_LIB_##lib = { nullptr, FENNEC_LIB_##lib };
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/sym.h>
|
||||||
|
|
||||||
|
bool load_symbols(platform* platform) {
|
||||||
|
if (_load_count++ != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_lib* current_lib = nullptr;
|
||||||
|
#define FENNEC_LIB(lib) _FENNEC_LIB_##lib.obj = platform->load_object(_FENNEC_LIB_##lib.name); \
|
||||||
|
FENNEC_HAS_LIB_##lib = _FENNEC_LIB_##lib.obj != nullptr; \
|
||||||
|
if(not FENNEC_HAS_LIB_##lib) { \
|
||||||
|
unload_symbols(platform); \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
current_lib = &_FENNEC_LIB_##lib;
|
||||||
|
#define FENNEC_SYMBOL(ret, fn, ...) LIBDECOR_##fn = (LIBDECOR_sym_##fn)(platform->find_symbol(current_lib->obj, #fn)); \
|
||||||
|
assertf(LIBDECOR_##fn != nullptr, "Failed to find symbol: " #fn);
|
||||||
|
#define FENNEC_GLOBAL(type, name) LIBDECOR_##name = (type*)(platform->find_symbol(current_lib->obj, #name)); \
|
||||||
|
assertf(LIBDECOR_##name != nullptr, "Failed to find global: " #name);
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/sym.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void unload_symbols(platform* platform) {
|
||||||
|
if (--_load_count != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FENNEC_LIB(lib) platform->unload_object(_FENNEC_LIB_##lib.obj); \
|
||||||
|
_FENNEC_LIB_##lib.obj = nullptr;
|
||||||
|
#define FENNEC_SYMBOL(ret, fn, ...) LIBDECOR_##fn = nullptr;
|
||||||
|
#define FENNEC_GLOBAL(type, name) LIBDECOR_##name = nullptr;
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/sym.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,24 +17,33 @@
|
|||||||
// =====================================================================================================================
|
// =====================================================================================================================
|
||||||
|
|
||||||
#include <fennec/core/logger.h>
|
#include <fennec/core/logger.h>
|
||||||
|
|
||||||
|
#include <fennec/renderers/interface/gfxcontext.h>
|
||||||
|
|
||||||
#include <fennec/platform/linux/wayland/server.h>
|
#include <fennec/platform/linux/wayland/server.h>
|
||||||
#include <fennec/platform/linux/wayland/window.h>
|
#include <fennec/platform/linux/wayland/window.h>
|
||||||
|
|
||||||
#include <fennec/platform/linux/wayland/lib/loader.h>
|
#include <fennec/platform/linux/wayland/lib/loader.h>
|
||||||
#include <fennec/platform/linux/wayland/lib/wayland.h>
|
#include <fennec/platform/linux/wayland/lib/wayland.h>
|
||||||
#include <fennec/platform/linux/wayland/lib/headers/xdg-shell-client-protocols.h>
|
#include <fennec/platform/linux/wayland/lib/headers/xdg-shell-client-protocols.h>
|
||||||
#include <fennec/renderers/interface/gfxcontext.h>
|
|
||||||
|
#if FENNEC_HAS_LIBDECOR
|
||||||
|
#include <fennec/platform/linux/wayland/libdecor/loader.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace fennec
|
namespace fennec
|
||||||
{
|
{
|
||||||
|
|
||||||
wayland_server::wayland_server(fennec::platform* p)
|
wayland_server::wayland_server(fennec::platform* p)
|
||||||
: display_server_base(p)
|
: display_server_base(p)
|
||||||
, display(nullptr), registry(nullptr), compositor(nullptr), seat(nullptr), fifo(false) {
|
, display(nullptr), registry(nullptr), compositor(nullptr), seat(nullptr), fifo(false), libdecor(false) {
|
||||||
|
|
||||||
// load shared lib
|
// load shared lib
|
||||||
if (libwayland::load_symbols(platform)) {
|
assertf(libwayland::load_symbols(platform), "Failed to load libwayland.");
|
||||||
return;
|
|
||||||
}
|
#if FENNEC_HAS_LIBDECOR
|
||||||
|
libdecor = libdecor::load_symbols(platform);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wayland_server::~wayland_server() {
|
wayland_server::~wayland_server() {
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ void wayland_window::show() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_running()) {
|
||||||
|
// reshow window
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wayland_window* root = this;
|
wayland_window* root = this;
|
||||||
while (root != nullptr and root->is_popup()) {
|
while (root != nullptr and root->is_popup()) {
|
||||||
root = static_cast<wayland_window*>(root->get_parent());
|
root = static_cast<wayland_window*>(root->get_parent());
|
||||||
@@ -78,6 +84,10 @@ void wayland_window::show() {
|
|||||||
xdgtoplevel = xdg_surface_get_toplevel(xdgsurface);
|
xdgtoplevel = xdg_surface_get_toplevel(xdgsurface);
|
||||||
xdg_toplevel_add_listener(xdgtoplevel, &xdg_toplevel_listener, this);
|
xdg_toplevel_add_listener(xdgtoplevel, &xdg_toplevel_listener, this);
|
||||||
|
|
||||||
|
if (has_decorations()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
frame_callback = wl_surface_frame(surface);
|
frame_callback = wl_surface_frame(surface);
|
||||||
wl_callback_add_listener(frame_callback, &frame_callback_listener, this);
|
wl_callback_add_listener(frame_callback, &frame_callback_listener, this);
|
||||||
|
|||||||
Reference in New Issue
Block a user