moving window on commit

This commit is contained in:
2026-01-06 21:55:52 +07:00
parent e4657bb3db
commit 47e9badb14
7 changed files with 54 additions and 27 deletions
+18 -6
View File
@@ -1,6 +1,7 @@
#include <wayland-server-core.h>
#include "types.h"
#include "xdg-toplevel.h"
struct absinthe_toplevel *absinthe_toplevel_at(struct absinthe_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
@@ -30,6 +31,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)
{
if (width < 0 || height < 0) {
return;
}
if (width == toplevel->xdg_toplevel->current.width && height == toplevel->xdg_toplevel->current.height) {
return;
}
@@ -37,24 +42,31 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt
toplevel->geometry.width = width;
toplevel->geometry.height = height;
int bw = ABSINTHE_BORDER_WIDTH;
wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, width, height);
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
}
void absinthe_toplevel_update_border_geometry(struct absinthe_toplevel *toplevel)
{
int bw = ABSINTHE_BORDER_WIDTH;
if (toplevel->geometry.width - 2 * bw < 0 || toplevel->geometry.height - 2 * bw < 0) {
return;
}
wlr_scene_node_set_position(&toplevel->scene_surface->node, bw, bw);
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_node_set_position(&toplevel->border[0]->node, 0, -bw);
wlr_scene_node_set_position(&toplevel->border[1]->node, 0, toplevel->geometry.height - 2 * bw);
wlr_scene_node_set_position(&toplevel->border[2]->node, -bw, -bw);
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - 2 * bw, -bw);
absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - 2 * bw, toplevel->geometry.height - 2 * bw);
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[2]->node, 0, 0);
wlr_scene_node_set_position(&toplevel->border[3]->node, toplevel->geometry.width - bw, 0);
}
void absinthe_toplevel_set_border_color(struct absinthe_toplevel *toplevel, const float color[4])