Adjusted Platform Structure

This commit is contained in:
2025-07-23 12:12:29 -04:00
parent 2117e4347c
commit f9de242b87
10 changed files with 35 additions and 25 deletions

View File

@@ -174,6 +174,7 @@ add_library(fennec STATIC
include/fennec/lang/type_operators.h include/fennec/lang/type_operators.h
include/fennec/containers/tuple.h include/fennec/containers/tuple.h
include/fennec/containers/detail/__tuple.h include/fennec/containers/detail/__tuple.h
include/fennec/platform/linux/wayland/window.h
) )
add_dependencies(fennec metaprogramming) add_dependencies(fennec metaprogramming)

View File

@@ -48,7 +48,7 @@ PROJECT_NAME = fennec
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 1.0.2 PROJECT_NUMBER =
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View File

@@ -34,8 +34,6 @@ public:
}; };
virtual bool connected() const = 0; virtual bool connected() const = 0;
protected:
virtual ~display() = default; virtual ~display() = default;
private: private:

View File

@@ -28,9 +28,6 @@
namespace fennec namespace fennec
{ {
namespace wayland
{
class wayland_display : public display { class wayland_display : public display {
public: public:
wayland_display(linux_platform* platform); wayland_display(linux_platform* platform);
@@ -46,6 +43,4 @@ private:
} }
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H #endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H

View File

@@ -24,7 +24,7 @@
namespace fennec namespace fennec
{ {
namespace wayland namespace libwayland
{ {
bool load_symbols(linux_platform* platform); bool load_symbols(linux_platform* platform);

View File

@@ -0,0 +1,22 @@
// =====================================================================================================================
// 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/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H

View File

@@ -28,8 +28,6 @@
namespace fennec namespace fennec
{ {
using namespace wayland;
linux_platform::linux_platform(user _type) linux_platform::linux_platform(user _type)
: platform(_type) : platform(_type)
, _display_driver(display_none) { , _display_driver(display_none) {
@@ -45,7 +43,10 @@ linux_platform::linux_platform(user _type)
} }
linux_platform::~linux_platform() { linux_platform::~linux_platform() {
if (_display) {
delete _display;
_display = nullptr;
}
} }
shared_object* linux_platform::load_object(const cstring& file) { shared_object* linux_platform::load_object(const cstring& file) {
@@ -77,10 +78,10 @@ display* linux_platform::get_display() {
void linux_platform::_runtime_client_checks() { void linux_platform::_runtime_client_checks() {
#ifdef FENNEC_LIB_WAYLAND #ifdef FENNEC_LIB_WAYLAND
if (wayland::load_symbols(this)) { if (libwayland::load_symbols(this)) {
_display_driver = display_wayland; _display_driver = display_wayland;
_display = new wayland_display(this); _display = new wayland_display(this);
wayland::unload_symbols(this); // Doesn't actually unload symbols, just resets ref counter to only consider libwayland::unload_symbols(this); // Doesn't actually unload symbols, just resets ref counter to only consider
// the created display // the created display
} }
#endif #endif

View File

@@ -23,14 +23,11 @@
namespace fennec namespace fennec
{ {
namespace wayland
{
wayland_display::wayland_display(linux_platform* platform) wayland_display::wayland_display(linux_platform* platform)
: display() : display()
, _handle() , _handle()
, _platform(platform) { , _platform(platform) {
load_symbols(_platform); libwayland::load_symbols(_platform);
_handle = wl_display_connect(nullptr); _handle = wl_display_connect(nullptr);
} }
@@ -38,13 +35,13 @@ wayland_display::wayland_display(linux_platform* platform, const cstring& drv)
: display() : display()
, _handle() , _handle()
, _platform(platform) { , _platform(platform) {
load_symbols(_platform); libwayland::load_symbols(_platform);
_handle = wl_display_connect(drv); _handle = wl_display_connect(drv);
} }
wayland_display::~wayland_display() { wayland_display::~wayland_display() {
wl_display_disconnect(_handle); wl_display_disconnect(_handle);
unload_symbols(_platform); libwayland::unload_symbols(_platform);
_handle = nullptr; _handle = nullptr;
_platform = nullptr; _platform = nullptr;
} }
@@ -53,6 +50,4 @@ bool wayland_display::connected() const {
return _handle != nullptr; return _handle != nullptr;
} }
}
} }

View File

@@ -22,7 +22,7 @@
namespace fennec namespace fennec
{ {
namespace wayland namespace libwayland
{ {
using shared_lib = platform::shared_lib; using shared_lib = platform::shared_lib;

View File

@@ -25,8 +25,6 @@
namespace fennec::test namespace fennec::test
{ {
using namespace wayland;
inline void fennec_test_platform_linux_wayland(linux_platform& platform) { inline void fennec_test_platform_linux_wayland(linux_platform& platform) {
wayland_display* display = static_cast<wayland_display*>(platform.get_display()); wayland_display* display = static_cast<wayland_display*>(platform.get_display());