Add get_api() and get_api_name() to WindowDriver

This commit is contained in:
2025-04-12 10:32:30 +10:00
parent 1849593dfc
commit 6cbf8df17a
4 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/**
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
namespace Nova {
enum class WindowAPI { WAYLAND, WIN32, X11 };
} // namespace Nova

View File

@@ -7,6 +7,7 @@
#pragma once
#include <nova/api.h>
#include <nova/platform/window_api.h>
#include <nova/types.h>
#include <string_view>
@@ -22,6 +23,9 @@ namespace Nova {
static WindowDriver* create();
virtual ~WindowDriver() = default;
[[nodiscard]] virtual WindowAPI get_api() const = 0;
[[nodiscard]] virtual std::string get_api_name() const = 0;
virtual void poll_events() = 0;
virtual void beep() = 0;

View File

@@ -46,6 +46,14 @@ X11WindowDriver::~X11WindowDriver() {
}
}
WindowAPI X11WindowDriver::get_api() const {
return WindowAPI::X11;
}
std::string X11WindowDriver::get_api_name() const {
return "X11";
}
void X11WindowDriver::poll_events() {
while (XPending(m_display)) {
XEvent event;

View File

@@ -24,6 +24,9 @@ namespace Nova {
X11WindowDriver();
~X11WindowDriver() override;
[[nodiscard]] WindowAPI get_api() const override;
[[nodiscard]] std::string get_api_name() const override;
void poll_events() override;
void beep() override;