Use custom wlroots fork

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-07-10 02:07:58 +03:00
parent dd6cadb50d
commit 1cc97753a5
4 changed files with 169 additions and 23 deletions

View File

@@ -24,11 +24,10 @@ extern "C" {
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
}
PFNGLDRAWBUFFERSEXTPROC glDrawBuffersEXT = NULL;
#include <raylib.h>
#include <raymath.h>
#include <rlgl.h>
@@ -790,8 +789,9 @@ private:
bool m_initialized {};
struct Keyboard {
struct wl_list link;
struct LunarWM *server;
struct wl_list link;
struct wlr_keyboard *wlr_keyboard;
struct wl_listener modifiers;
@@ -799,6 +799,29 @@ private:
struct wl_listener destroy;
};
struct Toplevel {
Toplevel(LunarWM *server, wlr_xdg_toplevel *xdg_toplevel)
: server(server)
, xdg_toplevel(xdg_toplevel)
{
surface = wlr_surface_from_resource(xdg_toplevel->resource);
texture = wlr_surface_get_texture(surface);
gles_texture = gles2_get_texture(texture);
rl_texture.width = texture->width;
rl_texture.height = texture->height;
}
operator Texture2D &() { return rl_texture; }
LunarWM *server {};
wlr_xdg_toplevel *xdg_toplevel {};
wlr_surface *surface {};
wlr_texture *texture {};
wlr_gles2_texture *gles_texture {};
Texture2D rl_texture {};
};
struct {
wl_display *display {};
wl_event_loop *event_loop {};
@@ -820,7 +843,13 @@ private:
wl_list keyboards;
wl_listener new_input_listener {};
wlr_xdg_shell *xdg_shell;
wl_listener new_xdg_toplevel_listener {};
wl_listener new_xdg_popup_listener {};
wlr_cursor *cursor {};
std::vector<Toplevel> toplevels;
} m_wayland;
struct {
@@ -1148,6 +1177,28 @@ void LunarWM::init_wayland()
if (!m_wayland.seat) {
throw std::runtime_error("Failed to create wlroots seat");
}
m_wayland.xdg_shell = wlr_xdg_shell_create(m_wayland.display, 3);
m_wayland.new_xdg_toplevel_listener.notify
= [](wl_listener *listener, void *data) {
LunarWM *server
= wl_container_of(listener, static_cast<LunarWM *>(nullptr),
m_wayland.new_xdg_toplevel_listener);
};
wl_signal_add(&m_wayland.xdg_shell->events.new_toplevel,
&m_wayland.new_xdg_toplevel_listener);
m_wayland.new_xdg_popup_listener.notify = [](wl_listener *listener,
void *data) {
LunarWM *server = wl_container_of(listener,
static_cast<LunarWM *>(nullptr), m_wayland.new_xdg_popup_listener);
auto toplevel = reinterpret_cast<wlr_xdg_toplevel *>(data);
Toplevel tl(server, toplevel);
};
wl_signal_add(&m_wayland.xdg_shell->events.new_popup,
&m_wayland.new_xdg_popup_listener);
}
void LunarWM::init_xr()
@@ -1302,8 +1353,6 @@ void LunarWM::init_xr()
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
{
glDrawBuffersEXT
= (PFNGLDRAWBUFFERSEXTPROC)eglGetProcAddress("glDrawBuffersEXT");
XrGraphicsBindingEGLMNDX gbind = {
.type = XR_TYPE_GRAPHICS_BINDING_EGL_MNDX,
.next = nullptr,
@@ -1852,21 +1901,6 @@ bool LunarWM::render_layer(RenderLayerInfo &info, float dt)
return true;
}
void LunarWM::render_3d(float dt)
{
static float animT { 0.0f };
animT += dt;
DrawGrid(10, 1);
Vector3 forward = Vector3Normalize(
Vector3Subtract(m_renderer.camera.target, m_renderer.camera.position));
float distance = 5.0f + sinf(animT) * 3.0f;
Vector3 spherePos = Vector3Add(
m_renderer.camera.position, Vector3Scale(forward, distance));
DrawSphere(spherePos, 0.5f, YELLOW);
}
LunarWM::~LunarWM()
{
assert(m_initialized);
@@ -2011,6 +2045,21 @@ void LunarWM::run()
}
}
void LunarWM::render_3d(float dt)
{
static float animT { 0.0f };
animT += dt;
DrawGrid(10, 1);
Vector3 forward = Vector3Normalize(
Vector3Subtract(m_renderer.camera.target, m_renderer.camera.position));
float distance = 5.0f + sinf(animT) * 3.0f;
Vector3 spherePos = Vector3Add(
m_renderer.camera.position, Vector3Scale(forward, distance));
DrawSphere(spherePos, 0.5f, YELLOW);
}
void LunarWM::terminate()
{
wlr_log(WLR_INFO, "Stopping compositor");