new structure

This commit is contained in:
Jorijn van der Graaf 2025-11-16 15:32:11 +01:00
commit 1155e67d63
37 changed files with 2399 additions and 751 deletions

View file

@ -0,0 +1,83 @@
/*
Crafter®.Graphics
Copyright (C) 2025 Catcrafts®
Catcrafts.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
module;
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
export module Crafter.Graphics:WindowWayland;
import std;
import Crafter.Event;
import :UiElement;
import :Types;
import :Window;
export namespace Crafter {
/**
* @class WindowWayland
* @brief A window using the Wayland display server protocol.
*
* This class inherits from the base Window class and provides
* functionality specific to Wayland for creating and managing
* windows.
*/
class WindowWayland : public Window {
public:
/**
* @brief Constructs a Wayland window with a given name and size.
* @param name The title for the window.
* @param width The width of the window in pixels.
* @param height The height of the window in pixels.
*/
WindowWayland(std::string name, std::uint32_t width, std::uint32_t height);
/**
* @brief Destructor cleans up Wayland-specific window resources.
*/
~WindowWayland();
protected:
bool configured = false;
wl_shm* shm = NULL;
wl_seat* seat = NULL;
xdg_toplevel* xdgToplevel = NULL;
xdg_wm_base* xdgWmBase = NULL;
zxdg_decoration_manager_v1* manager = NULL;
wl_surface* surface = NULL;
wl_buffer* buffer = NULL;
xdg_surface* xdgSurface = NULL;
wl_display* display = NULL;
inline static wl_compositor* compositor = NULL;
static wl_pointer_listener pointer_listener;
static wl_keyboard_listener keyboard_listener;
static wl_seat_listener seat_listener;
static wl_registry_listener registry_listener;
static xdg_surface_listener xdg_surface_listener;
static xdg_toplevel_listener xdg_toplevel_listener;
static void PointerListenerHandleMotion(void* data, wl_pointer* wl_pointer, uint time, wl_fixed_t surface_x, wl_fixed_t surface_y);
static void PointerListenerHandleAxis(void*, wl_pointer*, std::uint32_t, std::uint32_t, wl_fixed_t value);
static void PointerListenerHandleEnter(void* data, wl_pointer* wl_pointer, uint serial, wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y);
static void PointerListenerHandleLeave(void*, wl_pointer*, std::uint32_t, wl_surface*);
static void xdg_toplevel_handle_close(void* data, xdg_toplevel*);
static void handle_global(void* data, wl_registry* registry, std::uint32_t name, const char* interface, std::uint32_t version);
static void pointer_handle_button(void* data, wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state);
static void seat_handle_capabilities(void* data, wl_seat* seat, uint32_t capabilities);
static void xdg_surface_handle_configure(void* data, xdg_surface* xdg_surface, std::uint32_t serial);
};
}