aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-04-18 12:58:35 +0200
committerdec05eba <dec05eba@protonmail.com>2025-04-18 12:58:35 +0200
commitcd64ce74bf39cc0587b3a3cba4071b18312c89a6 (patch)
treeb8e88049c81f744c8bbc57d43b17afb95e8b7e1e
parent18ed06b01363e674d81e8afd5773188b900b50ec (diff)
Separate glx and egl from window system to prepare for wayland
m---------depends/mgl0
-rw-r--r--include/mglpp/mglpp.hpp10
-rw-r--r--include/mglpp/window/Window.hpp2
-rw-r--r--src/mglpp.cpp4
4 files changed, 11 insertions, 5 deletions
diff --git a/depends/mgl b/depends/mgl
-Subproject 506c271eafec23bf469caf6c29431191fa885e5
+Subproject 0e12a1d216b85c8e864cc2d7d18c3d18864542c
diff --git a/include/mglpp/mglpp.hpp b/include/mglpp/mglpp.hpp
index 2e49da5..58f956d 100644
--- a/include/mglpp/mglpp.hpp
+++ b/include/mglpp/mglpp.hpp
@@ -1,9 +1,15 @@
#ifndef MGLPP_MGLPP_HPP
#define MGLPP_MGLPP_HPP
-#include <stdexcept>
+#include <exception>
namespace mgl {
+ enum class WindowSystem {
+ NATIVE, // Use X11 on X11 and Wayland on Wayland
+ X11, // Use X11 on X11 and XWayland on Wayland
+ WAYLAND, // Use Wayland. If user runs on X11 then it fails to connect
+ };
+
class InitException : public std::exception {
public:
const char* what() const noexcept override {
@@ -14,7 +20,7 @@ namespace mgl {
class Init {
public:
// Throws InitException on failure
- Init();
+ Init(WindowSystem window_system = WindowSystem::NATIVE);
~Init();
bool is_connected_to_display_server();
diff --git a/include/mglpp/window/Window.hpp b/include/mglpp/window/Window.hpp
index eb14e23..8458d71 100644
--- a/include/mglpp/window/Window.hpp
+++ b/include/mglpp/window/Window.hpp
@@ -55,7 +55,7 @@ namespace mgl {
const char *class_name = nullptr;
mgl_window_type window_type = MGL_WINDOW_TYPE_NORMAL;
WindowHandle transient_for_window = 0; /* 0 = none */
- mgl_render_api render_api = MGL_RENDER_API_GLX;
+ mgl_graphics_api graphics_api = MGL_GRAPHICS_API_EGL;
};
Window();
diff --git a/src/mglpp.cpp b/src/mglpp.cpp
index ca0845d..2f0670a 100644
--- a/src/mglpp.cpp
+++ b/src/mglpp.cpp
@@ -4,8 +4,8 @@ extern "C" {
}
namespace mgl {
- Init::Init() {
- if(mgl_init() != 0)
+ Init::Init(WindowSystem window_system) {
+ if(mgl_init((mgl_window_system)window_system) != 0)
throw InitException();
}