Files
2026-02-25 10:08:29 +01:00

62 lines
2.0 KiB
C++

#include "window.h"
#include <wayland-client-protocol.h>
#include "xdg-shell-client-protocol.h"
class WaylandWindowImpl : public WindowImpl {
public:
WaylandWindowImpl(size_t width, size_t height);
~WaylandWindowImpl() override;
static void Init();
public:
bool Dispatch() override;
void OnFrame(IFrameListener fn) override;
size_t GetWidth() const override;
size_t GetHeight() const override;
private:
void render_frame();
private: // wayland listeners
static void handle_frame_callback(void *data, struct wl_callback *cb,
uint32_t time);
static void xsurface_handle_configure(void *data, struct xdg_surface *surface,
uint32_t serial);
static void xtoplevel_handle_configure(void *data,
struct xdg_toplevel *toplevel,
int32_t width, int32_t height,
struct wl_array *states);
static void xtoplevel_handle_close(void *data, struct xdg_toplevel *toplevel);
static void xtoplevel_handle_configure_bounds(void *data,
struct xdg_toplevel *toplevel,
int32_t width, int32_t height);
static void xtoplevel_handle_wm_capabilities(void *data,
struct xdg_toplevel *toplevel,
struct wl_array *capabilities);
private: // wayland internals
EGLSurface m_egl_surface;
EGLContext m_egl_context;
GLuint m_program;
struct wl_egl_window *m_egl_window;
struct wl_surface *m_wsurface;
struct xdg_surface *m_xsurface;
struct xdg_toplevel *m_toplevel;
struct wl_callback_listener m_frame_listener;
struct xdg_surface_listener m_xsurface_listener;
struct xdg_toplevel_listener m_toplevel_listener;
private:
bool m_running = false;
size_t m_width, m_height;
IFrameListener m_on_frame;
bool m_frame_cb_pending = false;
bool m_redraw_requested = false;
};