semi working wayland
This commit is contained in:
parent
e795ab880c
commit
4bb7219ccf
34 changed files with 13863 additions and 3121 deletions
|
|
@ -18,6 +18,13 @@ 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>
|
||||
#include "../lib/xdg-shell-client-protocol.h"
|
||||
#include "../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
import std;
|
||||
import Crafter.Event;
|
||||
|
|
@ -32,15 +39,9 @@ export namespace Crafter {
|
|||
std::int32_t height;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents a GUI window handling input events, mouse states, keyboard states, and UI elements.
|
||||
*
|
||||
* The Window class encapsulates event handling for mouse and keyboard interactions,
|
||||
* manages the state of the mouse and keyboard, and stores UI elements contained within the window.
|
||||
* It also holds window-specific properties such as name, dimensions, and scaling factor.
|
||||
*/
|
||||
class Window {
|
||||
public:
|
||||
Pixel_BU8_GU8_RU8_AU8* framebuffer = nullptr;
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
|
|
@ -70,19 +71,42 @@ export namespace Crafter {
|
|||
std::uint32_t height;
|
||||
float scale = 1;
|
||||
bool open = true;
|
||||
/**
|
||||
* @brief Constructs a Window with a given name and dimensions.
|
||||
* @param name The title of the window.
|
||||
* @param width The width of the window in pixels.
|
||||
* @param height The height of the window in pixels.
|
||||
*/
|
||||
|
||||
Window(std::string name, std::uint32_t width, std::uint32_t height);
|
||||
/**
|
||||
* @brief Calculates the real position and size of an UiElement
|
||||
*
|
||||
* @param element The UI element to get the position from.
|
||||
* @return The actual position and size of the element after scaling.
|
||||
*/
|
||||
~Window();
|
||||
void StartSync();
|
||||
ScaleData ScaleElement(const UiElement& element);
|
||||
|
||||
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;
|
||||
wl_buffer* backBuffer = NULL;
|
||||
xdg_surface* xdgSurface = NULL;
|
||||
wl_display* display = NULL;
|
||||
wl_callback* cb = nullptr;
|
||||
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 wl_callback_listener surface_frame_listener;
|
||||
static void wl_surface_frame_done(void *data, wl_callback *cb, uint32_t time);
|
||||
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);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue