diff --git a/src/absinthe-toplevel.c b/src/absinthe-toplevel.c index 17ff7ae..fe8ffac 100644 --- a/src/absinthe-toplevel.c +++ b/src/absinthe-toplevel.c @@ -2,6 +2,7 @@ #include #include +#include #include "types.h" #include "absinthe-toplevel.h" @@ -58,6 +59,11 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data) wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false); toplevel->tiled = true; + if (wl_resource_get_version(toplevel->toplevel.xdg->resource) >= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) { + wlr_xdg_toplevel_set_tiled(toplevel->toplevel.xdg, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); + } else { + wlr_xdg_toplevel_set_maximized(toplevel->toplevel.xdg, true); + } toplevel->border_width = absinthe_toplevel_is_unmanaged(toplevel) ? 0 @@ -200,8 +206,12 @@ 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) + if (width <= toplevel->border_width || height <= toplevel->border_width || (width == toplevel->geometry.width && height == toplevel->geometry.height)) return; + + toplevel->geometry.width = width; + toplevel->geometry.height = height; + if (toplevel->type == ABSINTHE_TOPLEVEL_XDG) { toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width - 2 * toplevel->border_width, height - 2 * toplevel->border_width); } @@ -209,10 +219,16 @@ void absinthe_toplevel_set_size(struct absinthe_toplevel *toplevel, int32_t widt else if (toplevel->type == ABSINTHE_TOPLEVEL_X11) { wlr_xwayland_surface_configure(toplevel->toplevel.x11, toplevel->geometry.x, toplevel->geometry.y, width - 2 * toplevel->border_width, height - 2 * toplevel->border_width); - absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); - absinthe_toplevel_update_borders_geometry(toplevel); + absinthe_toplevel_set_position(toplevel, toplevel->geometry.x + toplevel->border_width, toplevel->geometry.y + toplevel->border_width); } #endif + struct wlr_box clip = { + .x = 0, + .y = 0, + .width = width - toplevel->border_width, + .height = height - toplevel->border_width, + }; + wlr_scene_subsurface_tree_set_clip(&toplevel->scene_surface->node, &clip); } void absinthe_toplevel_set_fullscreen(struct absinthe_toplevel *toplevel, bool fullscreen) diff --git a/src/cursor.c b/src/cursor.c index 7581776..600d416 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -34,8 +34,6 @@ static void process_cursor_move(struct absinthe_server *server) { static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new_geometry) { - int32_t borders_width = 2 * toplevel->border_width; - int32_t min_width = toplevel->toplevel.xdg->current.min_width; int32_t min_height = toplevel->toplevel.xdg->current.min_height; @@ -49,20 +47,20 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new if (max_height == 0) max_height = 10000; - if (new_geometry->width - borders_width >= min_width && new_geometry->width - borders_width <= max_width) { + if (toplevel->geometry.width != min_width && new_geometry->width >= min_width && new_geometry->width <= max_width) { toplevel->geometry.x = new_geometry->x; toplevel->geometry.width = new_geometry->width; resize = true; } - if (new_geometry->height - borders_width >= min_height && new_geometry->height - borders_width <= max_height) { + if (toplevel->geometry.height != min_height && new_geometry->height >= min_height && new_geometry->height<= max_height) { toplevel->geometry.y = new_geometry->y; toplevel->geometry.height = new_geometry->height; resize = true; } if (resize) - absinthe_toplevel_set_size(toplevel, toplevel->geometry.width - borders_width, toplevel->geometry.height - borders_width); + absinthe_toplevel_set_size(toplevel, toplevel->geometry.width, toplevel->geometry.height); } static void process_cursor_resize(struct absinthe_server *server) { diff --git a/src/keyboard.c b/src/keyboard.c index 7efb37d..f1fb1af 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -27,7 +27,7 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t break; case XKB_KEY_Return: if (fork() == 0) - execl("/bin/sh", "sh", "-c", "alacritty", NULL); + execl("/bin/sh", "sh", "-c", "foot", NULL); break; case XKB_KEY_r: if (fork() == 0) diff --git a/src/main.c b/src/main.c index f3bb24a..226340e 100644 --- a/src/main.c +++ b/src/main.c @@ -97,7 +97,7 @@ int main(int argc, char **argv) wl_list_init(&server.toplevels); wl_list_init(&server.focus_stack); - server.xdg_shell = wlr_xdg_shell_create(server.display, 3); + server.xdg_shell = wlr_xdg_shell_create(server.display, 6); server.new_xdg_toplevel.notify = server_new_xdg_toplevel; wl_signal_add(&server.xdg_shell->events.new_toplevel, &server.new_xdg_toplevel); server.new_xdg_popup.notify = server_new_xdg_popup; diff --git a/src/xdg-toplevel.c b/src/xdg-toplevel.c index 8b67419..51dd033 100644 --- a/src/xdg-toplevel.c +++ b/src/xdg-toplevel.c @@ -27,9 +27,6 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data) toplevel->resizing = wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, 0, 0); return; } - /* Check for size because we did't set it on initial commit */ - toplevel->geometry.width = toplevel->toplevel.xdg->base->geometry.width + borders_width; - toplevel->geometry.height = toplevel->toplevel.xdg->base->geometry.height + borders_width; /* Update borders and position only after client prepared new buffer */ absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y);