Add get_api() and get_api_name() to WindowDriver
This commit is contained in:
11
engine/include/nova/platform/window_api.h
Normal file
11
engine/include/nova/platform/window_api.h
Normal 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
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nova/api.h>
|
#include <nova/api.h>
|
||||||
|
#include <nova/platform/window_api.h>
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@@ -22,6 +23,9 @@ namespace Nova {
|
|||||||
static WindowDriver* create();
|
static WindowDriver* create();
|
||||||
virtual ~WindowDriver() = default;
|
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 poll_events() = 0;
|
||||||
virtual void beep() = 0;
|
virtual void beep() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -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() {
|
void X11WindowDriver::poll_events() {
|
||||||
while (XPending(m_display)) {
|
while (XPending(m_display)) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ namespace Nova {
|
|||||||
X11WindowDriver();
|
X11WindowDriver();
|
||||||
~X11WindowDriver() override;
|
~X11WindowDriver() override;
|
||||||
|
|
||||||
|
[[nodiscard]] WindowAPI get_api() const override;
|
||||||
|
[[nodiscard]] std::string get_api_name() const override;
|
||||||
|
|
||||||
void poll_events() override;
|
void poll_events() override;
|
||||||
void beep() override;
|
void beep() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user