Rename SystemDriver to WindowDriver and removed LinuxSystemDriver
Hopefully the last time I change my mind on what I want these to be called. Reason behind this change is to minimize scope of a single module. The WindowDriver should really only handle stuff related to windows. If we need OS level functionality (e.g. get_os_name), that should be the responsibility of the OS driver (or whatever that ends being called). Remember, composition over inheritance.
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifdef NOVA_LINUX
|
||||
|
||||
#include "drivers/linux/system_driver.h"
|
||||
|
||||
#include "drivers/linux/wayland/system_driver.h" // IWYU pragma: keep
|
||||
#include "drivers/linux/x11/system_driver.h" // IWYU pragma: keep
|
||||
|
||||
#include <nova/core/debug.h>
|
||||
|
||||
using namespace Nova;
|
||||
|
||||
LinuxSystemDriver::LinuxSystemDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
LinuxSystemDriver::~LinuxSystemDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
const char* LinuxSystemDriver::get_surface_extension() const {
|
||||
NOVA_WARN("System driver does not support surfaces");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<SystemDriver> LinuxSystemDriver::get_default_driver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
|
||||
#ifdef NOVA_WAYLAND
|
||||
if (std::getenv("WAYLAND_DISPLAY")) {
|
||||
return std::make_unique<WaylandSystemDriver>();
|
||||
}
|
||||
#endif
|
||||
#ifdef NOVA_X11
|
||||
if (std::getenv("DISPLAY")) {
|
||||
return std::make_unique<X11SystemDriver>();
|
||||
}
|
||||
#endif
|
||||
|
||||
NOVA_WARN("Unsupported display server");
|
||||
return std::make_unique<LinuxSystemDriver>();
|
||||
}
|
||||
|
||||
#endif // NOVA_LINUX
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef NOVA_LINUX
|
||||
|
||||
#include <nova/platform/system_driver.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Nova {
|
||||
class LinuxSystemDriver : public SystemDriver {
|
||||
public:
|
||||
LinuxSystemDriver();
|
||||
~LinuxSystemDriver() override;
|
||||
|
||||
[[nodiscard]] const char* get_surface_extension() const override;
|
||||
|
||||
static std::unique_ptr<SystemDriver> get_default_driver();
|
||||
};
|
||||
} // namespace Nova
|
||||
|
||||
#endif // NOVA_LINUX
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#ifdef NOVA_WAYLAND
|
||||
|
||||
#include "drivers/linux/wayland/system_driver.h"
|
||||
#include "drivers/wayland/window_driver.h"
|
||||
|
||||
#ifdef NOVA_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
using namespace Nova;
|
||||
|
||||
WaylandSystemDriver::WaylandSystemDriver() {
|
||||
WaylandWindowDriver::WaylandWindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
WaylandSystemDriver::~WaylandSystemDriver() {
|
||||
WaylandWindowDriver::~WaylandWindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
const char* WaylandSystemDriver::get_surface_extension() const {
|
||||
const char* WaylandWindowDriver::get_surface_extension() const {
|
||||
#ifdef NOVA_VULKAN
|
||||
return VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
|
||||
#else
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
#ifdef NOVA_WAYLAND
|
||||
|
||||
#include "drivers/linux/system_driver.h"
|
||||
#include <nova/platform/window_driver.h>
|
||||
|
||||
namespace Nova {
|
||||
class WaylandSystemDriver final : public LinuxSystemDriver {
|
||||
class WaylandWindowDriver final : public WindowDriver {
|
||||
public:
|
||||
WaylandSystemDriver();
|
||||
~WaylandSystemDriver() override;
|
||||
WaylandWindowDriver();
|
||||
~WaylandWindowDriver() override;
|
||||
|
||||
[[nodiscard]] const char* get_surface_extension() const override;
|
||||
};
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#ifdef NOVA_WINDOWS
|
||||
|
||||
#include "drivers/windows/system_driver.h"
|
||||
#include "drivers/win32/window_driver.h"
|
||||
|
||||
#ifdef NOVA_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
using namespace Nova;
|
||||
|
||||
WindowsSystemDriver::WindowsSystemDriver() {
|
||||
Win32WindowDriver::Win32WindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
WindowsSystemDriver::~WindowsSystemDriver() {
|
||||
Win32WindowDriver::~Win32WindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
const char* WindowsSystemDriver::get_surface_extension() const {
|
||||
const char* Win32WindowDriver::get_surface_extension() const {
|
||||
#ifdef NOVA_VULKAN
|
||||
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
|
||||
#else
|
||||
@@ -8,14 +8,14 @@
|
||||
|
||||
#ifdef NOVA_WINDOWS
|
||||
|
||||
#include <nova/platform/system_driver.h>
|
||||
#include <nova/platform/window_driver.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace Nova {
|
||||
class WindowsSystemDriver final : public SystemDriver {
|
||||
class Win32WindowDriver final : public WindowDriver {
|
||||
public:
|
||||
WindowsSystemDriver();
|
||||
~WindowsSystemDriver() override;
|
||||
Win32WindowDriver();
|
||||
~Win32WindowDriver() override;
|
||||
|
||||
[[nodiscard]] const char* get_surface_extension() const override;
|
||||
};
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#ifdef NOVA_X11
|
||||
|
||||
#include "drivers/linux/x11/system_driver.h"
|
||||
#include "drivers/x11/window_driver.h"
|
||||
|
||||
#ifdef NOVA_VULKAN
|
||||
#include <vulkan/vulkan.h>
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
using namespace Nova;
|
||||
|
||||
X11SystemDriver::X11SystemDriver() {
|
||||
X11WindowDriver::X11WindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
X11SystemDriver::~X11SystemDriver() {
|
||||
X11WindowDriver::~X11WindowDriver() {
|
||||
NOVA_AUTO_TRACE();
|
||||
}
|
||||
|
||||
const char* X11SystemDriver::get_surface_extension() const {
|
||||
const char* X11WindowDriver::get_surface_extension() const {
|
||||
#ifdef NOVA_VULKAN
|
||||
return VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
|
||||
#else
|
||||
@@ -8,15 +8,14 @@
|
||||
|
||||
#ifdef NOVA_X11
|
||||
|
||||
#include "drivers/linux/system_driver.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <nova/platform/window_driver.h>
|
||||
|
||||
namespace Nova {
|
||||
class X11SystemDriver final : public LinuxSystemDriver {
|
||||
class X11WindowDriver final : public WindowDriver {
|
||||
public:
|
||||
X11SystemDriver();
|
||||
~X11SystemDriver() override;
|
||||
X11WindowDriver();
|
||||
~X11WindowDriver() override;
|
||||
|
||||
[[nodiscard]] const char* get_surface_extension() const override;
|
||||
};
|
||||
@@ -4,8 +4,9 @@
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "drivers/linux/system_driver.h" // IWYU pragma: keep
|
||||
#include "drivers/windows/system_driver.h" // IWYU pragma: keep
|
||||
#include "drivers/wayland/window_driver.h" // IWYU pragma: keep
|
||||
#include "drivers/win32/window_driver.h" // IWYU pragma: keep
|
||||
#include "drivers/x11/window_driver.h" // IWYU pragma: keep
|
||||
|
||||
#include <nova/core/debug.h>
|
||||
#include <nova/platform/system.h>
|
||||
@@ -14,7 +15,7 @@
|
||||
|
||||
using namespace Nova;
|
||||
|
||||
static std::unique_ptr<SystemDriver> s_driver;
|
||||
static std::unique_ptr<WindowDriver> s_driver;
|
||||
|
||||
void System::init() {
|
||||
NOVA_AUTO_TRACE();
|
||||
@@ -23,7 +24,19 @@ void System::init() {
|
||||
#ifdef NOVA_WINDOWS
|
||||
s_driver = std::make_unique<WindowsSystemDriver>();
|
||||
#elif NOVA_LINUX
|
||||
s_driver = LinuxSystemDriver::get_default_driver();
|
||||
#ifdef NOVA_WAYLAND
|
||||
if (std::getenv("WAYLAND_DISPLAY")) {
|
||||
s_driver = std::make_unique<WaylandWindowDriver>();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef NOVA_X11
|
||||
if (std::getenv("DISPLAY")) {
|
||||
s_driver = std::make_unique<X11WindowDriver>();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
throw std::runtime_error("No suitable display server found");
|
||||
#else
|
||||
throw std::runtime_error("Unsupported platform");
|
||||
#endif
|
||||
@@ -34,7 +47,7 @@ void System::shutdown() {
|
||||
s_driver.reset();
|
||||
}
|
||||
|
||||
SystemDriver* System::get_driver() {
|
||||
WindowDriver* System::get_driver() {
|
||||
NOVA_ASSERT(s_driver);
|
||||
return s_driver.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user