add xdg decoration, scene/tree factories, geometry + seat focus

more wrapper soup. xdg decoration manager, scene/tree node factories so
callers stop touching raw wlr_scene_*_create, a box geometry helper, and
seat pointer/keyboard focus clearing. dragging myself through it.
This commit is contained in:
AstralZX
2026-08-29 10:01:39 +02:00
parent d96315ca66
commit 7ad2b0a5fa
9 changed files with 192 additions and 43 deletions
+10 -32
View File
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <pixman.h>
#include <string>
#include "wlr/wlr.hpp"
#include "wlr/color.hpp"
#include "wlr/node.hpp"
namespace wlr {
@@ -36,39 +37,16 @@ public:
void set_blur_saturation(float saturation) { wlr_scene_set_blur_saturation(m_scene, saturation); }
struct wlr_scene_tree* root() { return &m_scene->tree; }
Tree add_tree() { return Tree{wlr_scene_tree_create(&m_scene->tree)}; }
Rect add_rect(int w, int h, const Color& c) {
float col[4]; c.apply(col);
return Rect{wlr_scene_rect_create(&m_scene->tree, w, h, col)};
}
Buffer add_buffer() { return Buffer{wlr_scene_buffer_create(&m_scene->tree, nullptr)}; }
Surface add_surface(struct wlr_surface* s) { return Surface{wlr_scene_surface_create(&m_scene->tree, s)}; }
private:
struct wlr_scene* m_scene;
};
struct Box {
int x = 0, y = 0, width = 0, height = 0;
pixman_box32 to_box() const { return {x, y, x + width, y + height}; }
static Box from_box(pixman_box32 b) {
return {b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1};
}
};
struct Color {
float r = 1.0f, g = 1.0f, b = 1.0f, a = 1.0f;
void apply(float out[4]) const {
out[0] = r; out[1] = g; out[2] = b; out[3] = a;
}
};
struct CornerRadii {
uint16_t top_left = 0, top_right = 0, bottom_right = 0, bottom_left = 0;
CornerRadii() = default;
CornerRadii(uint16_t all) : top_left(all), top_right(all), bottom_right(all), bottom_left(all) {}
CornerRadii(uint16_t tl, uint16_t tr, uint16_t br, uint16_t bl)
: top_left(tl), top_right(tr), bottom_right(br), bottom_left(bl) {}
fx_corner_radii raw() const {
return fx_corner_radii{top_left, top_right, bottom_right, bottom_left};
}
static CornerRadii from_radii(fx_corner_radii r) {
return {r.top_left, r.top_right, r.bottom_right, r.bottom_left};
}
};
}