xwayland and somemother stuff

This commit is contained in:
2026-04-15 22:57:27 +07:00
parent 1f9116eb94
commit 3e1c61e9b6
5 changed files with 52 additions and 25 deletions
+1 -1
View File
@@ -7,4 +7,4 @@ compile: proto
gcc -o absinthe src/* \
-DXWAYLAND \
-I./ -I./include -DWLR_USE_UNSTABLE $(shell pkg-config wlroots-0.20 --libs --cflags) -lwayland-server -lxkbcommon \
-ggdb
-g
+1 -1
View File
@@ -126,7 +126,7 @@ struct absinthe_toplevel {
enum absinthe_toplevel_type type;
struct wl_list link;
struct wl_list flink; // for focus stack
struct wl_list flink;
struct absinthe_server *server;
struct absinthe_output *output;
struct wlr_scene_tree *scene_tree;
+31 -5
View File
@@ -1,3 +1,5 @@
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wlr/util/log.h>
@@ -23,6 +25,15 @@ bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel)
return false;
}
struct wlr_surface *absinthe_toplevel_surface(struct absinthe_toplevel *toplevel)
{
#ifdef XWAYLAND
if (absinthe_toplevel_is_x11(toplevel))
return toplevel->toplevel.x11->surface;
#endif
return toplevel->toplevel.xdg->base->surface;
}
void absinthe_toplevel_map(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
@@ -34,9 +45,14 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data)
? 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);
#ifdef XWAYLAND
if (absinthe_toplevel_is_x11(toplevel)) {
toplevel->scene_surface = wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.x11->surface);
} else
#endif
{
toplevel->scene_surface = wlr_scene_subsurface_tree_create(toplevel->scene_tree, toplevel->toplevel.xdg->base->surface);
}
toplevel->scene_surface->node.data = toplevel;
for (int i = 0; i < 4; ++i) {
@@ -60,11 +76,14 @@ 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);
if (toplevel == toplevel->server->focused_toplevel)
toplevel->server->focused_toplevel = NULL;
wl_list_remove(&toplevel->link);
wl_list_remove(&toplevel->flink);
wlr_scene_node_destroy(&toplevel->scene_tree->node);
layout_arrange(toplevel->output);
}
@@ -162,8 +181,15 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt
{
if (width < 0 || height < 0)
return;
if (toplevel->type == ABSINTHE_TOPLEVEL_XDG)
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
#ifdef XWAYLAND
else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) {
wlr_xwayland_surface_configure(toplevel->toplevel.x11,
toplevel->geometry.x, toplevel->geometry.y, width, height);
absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);
}
#endif
}
void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen)
+7 -6
View File
@@ -1,3 +1,4 @@
#include "absinthe-toplevel.h"
#include "types.h"
void layout_arrange(struct absinthe_output *output)
@@ -24,11 +25,11 @@ void layout_arrange(struct absinthe_output *output)
break;
}
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg,
output->geometry.width - borders_width - 2 * output_gap,
output->geometry.height - borders_width - 2 * output_gap);
toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + output_gap;
absinthe_toplevel_set_size(toplevel,
output->geometry.width - borders_width - 2 * output_gap,
output->geometry.height - borders_width - 2 * output_gap);
return;
}
@@ -47,9 +48,9 @@ void layout_arrange(struct absinthe_output *output)
continue;
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, main_stack_width, height);
dy += height + borders_width + layout_gap;
i++;
@@ -64,17 +65,17 @@ void layout_arrange(struct absinthe_output *output)
if (i < ABSINTHE_MAIN_STACK_SIZE) {
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, main_stack_width, height);
dy += height + borders_width + layout_gap;
} else {
if (i == ABSINTHE_MAIN_STACK_SIZE)
dy = output_gap;
height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
toplevel->geometry.x = output->geometry.x + main_stack_width + layout_gap + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
absinthe_toplevel_set_size(toplevel, width, height);
dy += height + borders_width + layout_gap;
}
+1 -1
View File
@@ -32,7 +32,7 @@ void xwayland_dissociate(struct wl_listener *listener, void *data)
void xwayland_configure(struct wl_listener *listener, void *data)
{
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_activate);
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_configure);
struct wlr_xwayland_surface_configure_event *event = data;
if (!toplevel->toplevel.x11->surface || !toplevel->toplevel.x11->surface->mapped) {