From 18ed06b01363e674d81e8afd5773188b900b50ec Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 17 Apr 2025 16:36:38 +0200 Subject: Move x11 code to separate place for main window code to prepare for wayland support --- src/window/Window.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/window/Window.cpp') diff --git a/src/window/Window.cpp b/src/window/Window.cpp index ab42de0..fffacca 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -16,24 +16,34 @@ namespace mgl { } Window::Window() { - window.window = 0; + } Window::~Window() { - if(window.window) + if(window_created) mgl_window_deinit(&window); } bool Window::create(const char *title, CreateParams create_params) { - if(window.window) + if(window_created) return false; - return mgl_window_create(&window, title, (const mgl_window_create_params*)&create_params) == 0; + + if(mgl_window_create(&window, title, (const mgl_window_create_params*)&create_params) == 0) { + window_created = true; + return true; + } + return false; } bool Window::create(WindowHandle existing_window) { - if(window.window) + if(window_created) return false; - return mgl_window_init_from_existing_window(&window, existing_window) == 0; + + if(mgl_window_init_from_existing_window(&window, existing_window) == 0) { + window_created = true; + return true; + } + return false; } bool Window::poll_event(Event &event) { @@ -197,7 +207,7 @@ namespace mgl { } WindowHandle Window::get_system_handle() const { - return window.window; + return mgl_window_get_system_handle(&window); } mgl_window* Window::internal_window() { -- cgit v1.2.3-70-g09d2