adding xwayland support

This commit is contained in:
2026-04-07 11:48:15 +07:00
parent 9756e9921f
commit c4b2727eb0
6 changed files with 126 additions and 121 deletions
+103
View File
@@ -2,6 +2,9 @@
#include <wlr/util/log.h>
#include "types.h"
#include "absinthe-toplevel.h"
#include "output.h"
#include "layout.h"
bool absinthe_toplevel_is_x11(struct absinthe_toplevel *toplevel)
{
@@ -20,6 +23,106 @@ bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel)
return false;
}
void absinthe_toplevel_map(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree);
toplevel->scene_tree->node.data = toplevel;
toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel)
? 0
: ABSINTHE_TOPLEVEL_BORDER_WIDTH;
toplevel->scene_surface = toplevel->type == ABSINTHE_TOPLEVEL_XDG
? wlr_scene_xdg_surface_create(toplevel->scene_tree, toplevel->toplevel.xdg->base)
: wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.x11->surface);
toplevel->scene_surface->node.data = toplevel;
for (int i = 0; i < 4; ++i) {
toplevel->border[i] = wlr_scene_rect_create(toplevel->scene_tree, 0, 0, unfocused_border_color);
toplevel->border[i]->node.data = toplevel;
}
toplevel->border_width = ABSINTHE_TOPLEVEL_BORDER_WIDTH;
update_focused_output(toplevel->server);
toplevel->output = toplevel->server->focused_output;
toplevel->fullscreen = false;
wl_list_insert(&toplevel->server->toplevels, &toplevel->link);
wl_list_insert(&toplevel->server->focus_stack, &toplevel->flink);
layout_arrange(toplevel->output);
}
void absinthe_toplevel_unmap(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, unmap);
wlr_scene_node_destroy(&toplevel->scene_tree->node);
wl_list_remove(&toplevel->link);
wl_list_remove(&toplevel->flink);
layout_arrange(toplevel->output);
}
void absinthe_toplevel_destroy(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, destroy);
#ifdef XWAYLAND
if (absinthe_toplevel_is_x11(toplevel)) {
wl_list_remove(&toplevel->xwayland_activate.link);
wl_list_remove(&toplevel->xwayland_associate.link);
wl_list_remove(&toplevel->xwayland_dissociate.link);
wl_list_remove(&toplevel->xwayland_configure.link);
wl_list_remove(&toplevel->xwayland_set_hints.link);
} else
#endif
{
wl_list_remove(&toplevel->map.link);
wl_list_remove(&toplevel->unmap.link);
wl_list_remove(&toplevel->commit.link);
wl_list_remove(&toplevel->request_move.link);
wl_list_remove(&toplevel->request_resize.link);
}
wl_list_remove(&toplevel->destroy.link);
wl_list_remove(&toplevel->request_maximize.link);
wl_list_remove(&toplevel->request_fullscreen.link);
free(toplevel);
}
void absinthe_toplevel_request_move(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
if (toplevel->toplevel.xdg->base->initialized)
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
}
void absinthe_toplevel_request_resize(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
if (toplevel->toplevel.xdg->base->initialized)
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
}
void absinthe_toplevel_request_maximize(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
if (toplevel->toplevel.xdg->base->initialized)
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
}
void absinthe_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_fullscreen);
absinthe_toplevel_set_fullscreen(toplevel, toplevel->toplevel.xdg->requested.fullscreen);
}
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);