adding xwayland support

This commit is contained in:
2026-04-04 16:42:55 +07:00
parent cba94498b1
commit b92d1c1b02
10 changed files with 155 additions and 126 deletions
+21 -15
View File
@@ -3,6 +3,14 @@
#include "types.h"
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel)
{
#ifdef XWAYLAND
return toplevel->type == ABSINTHE_TOPLEVEL_TYPE_X11;
#endif
return false;
}
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
struct wlr_scene_node *node = wlr_scene_node_at(&server->scene->tree.node, lx, ly, sx, sy);
@@ -40,12 +48,10 @@ void absinthe_toplevel_set_position(struct absinthe_toplevel *toplevel, int32_t
void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t width, int32_t height)
{
int32_t bw = toplevel->border_width;
if (width < 0 || height < 0)
return;
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, width, height);
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
}
void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen)
@@ -55,7 +61,7 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f
struct absinthe_output *output = toplevel->server->focused_output;
toplevel->fullscreen = fullscreen;
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, fullscreen);
wlr_xdg_toplevel_set_fullscreen(toplevel->toplevel.xdg, fullscreen);
if (fullscreen) {
toplevel->prev_geometry = toplevel->geometry;
@@ -64,7 +70,7 @@ void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool f
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height);
} else {
toplevel->geometry = toplevel->prev_geometry;
toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH;
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH;
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height);
}
}
@@ -78,21 +84,21 @@ void absinthe_toplevel_set_border_color(struct absinthe_toplevel *toplevel, cons
void absinthe_toplevel_update_borders_geometry(struct absinthe_toplevel *toplevel)
{
int32_t bw = toplevel->border_width;
int32_t border_width = toplevel->border_width;
if (toplevel->geometry.width - 2 * bw < 0 || toplevel->geometry.height - 2 * bw < 0)
if (toplevel->geometry.width - 2 * border_width < 0 || toplevel->geometry.height - 2 * border_width < 0)
return;
wlr_scene_node_set_position(&toplevel->scene_tree->node, toplevel->geometry.x, toplevel->geometry.y);
wlr_scene_node_set_position(&toplevel->scene_surface->node, bw, bw);
wlr_scene_node_set_position(&toplevel->scene_surface->node, border_width, border_width);
wlr_scene_rect_set_size(toplevel->border[0], toplevel->geometry.width - 2 * bw, bw);
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * bw, bw);
wlr_scene_rect_set_size(toplevel->border[2], bw, toplevel->geometry.height);
wlr_scene_rect_set_size(toplevel->border[3], bw, toplevel->geometry.height);
wlr_scene_rect_set_size(toplevel->border[0], toplevel->geometry.width - 2 * border_width, border_width);
wlr_scene_rect_set_size(toplevel->border[1], toplevel->geometry.width - 2 * border_width, border_width);
wlr_scene_rect_set_size(toplevel->border[2], border_width, toplevel->geometry.height);
wlr_scene_rect_set_size(toplevel->border[3], border_width, toplevel->geometry.height);
wlr_scene_node_set_position(&toplevel->border[0]->node, bw, 0);
wlr_scene_node_set_position(&toplevel->border[1]->node, bw, toplevel->geometry.height - bw);
wlr_scene_node_set_position(&toplevel->border[0]->node, border_width, 0);
wlr_scene_node_set_position(&toplevel->border[1]->node, border_width, toplevel->geometry.height - border_width);
wlr_scene_node_set_position(&toplevel->border[2]->node, 0, 0);
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - bw, 0);
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - border_width, 0);
}