focused toplevel

This commit is contained in:
2026-01-14 09:56:27 +07:00
parent 6416e742ac
commit a79ef6929e
7 changed files with 12 additions and 24 deletions
+1 -1
View File
@@ -72,12 +72,12 @@ struct absinthe_server {
struct wl_listener request_set_selection;
struct wl_list keyboards;
enum absinthe_cursor_mode cursor_mode;
struct absinthe_toplevel *grabbed_toplevel;
struct wlr_box grabbed_geometry;
uint32_t grab_x, grab_y;
enum absinthe_cursor_resize_corner cursor_resize_corner;
struct wl_list toplevels;
struct absinthe_toplevel *focused_toplevel;
struct wl_list focus_stack;
struct absinthe_output *focused_output;
-1
View File
@@ -2,7 +2,6 @@
#include <wlr/util/log.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)
{
+5 -6
View File
@@ -8,14 +8,13 @@ void reset_cursor_mode(struct absinthe_server *server)
{
server->cursor_mode = ABSINTHE_CURSOR_PASSTHROUGH;
wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default");
if (server->grabbed_toplevel) {
wlr_xdg_toplevel_set_resizing(server->grabbed_toplevel->xdg_toplevel, false);
server->grabbed_toplevel = NULL;
if (server->focused_toplevel) {
wlr_xdg_toplevel_set_resizing(server->focused_toplevel->xdg_toplevel, false);
}
}
static void process_cursor_move(struct absinthe_server *server) {
struct absinthe_toplevel *toplevel = server->grabbed_toplevel;
struct absinthe_toplevel *toplevel = server->focused_toplevel;
if (!toplevel)
return;
@@ -66,7 +65,7 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new
}
static void process_cursor_resize(struct absinthe_server *server) {
struct absinthe_toplevel *toplevel = server->grabbed_toplevel;
struct absinthe_toplevel *toplevel = server->focused_toplevel;
if (!toplevel)
return;
@@ -122,7 +121,7 @@ static void process_cursor_resize(struct absinthe_server *server) {
.height = new_height,
};
apply_resize(server->grabbed_toplevel, &new_geometry);
apply_resize(server->focused_toplevel, &new_geometry);
}
}
+2
View File
@@ -25,6 +25,8 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
}
}
toplevel->server->focused_toplevel = toplevel;
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
wlr_scene_node_raise_to_top(&toplevel->scene_tree->node);
wl_list_remove(&toplevel->flink);
+2 -14
View File
@@ -20,10 +20,6 @@ void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t keysym)
{
struct wlr_surface *surface;
struct wlr_xdg_toplevel *xdg_toplevel;
struct absinthe_toplevel *toplevel;
switch (keysym) {
case XKB_KEY_Escape:
wl_display_terminate(server->display);
@@ -37,16 +33,8 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
execl("/bin/sh", "sh", "-c", "wofi --show drun", NULL);
break;
case XKB_KEY_f:
surface = server->seat->pointer_state.focused_surface;
if (surface)
xdg_toplevel = wlr_xdg_toplevel_try_from_wlr_surface(surface);
if (xdg_toplevel)
toplevel = xdg_toplevel->base->data;
if (toplevel)
absinthe_toplevel_set_fullscreen(toplevel, !toplevel->fullscreen);
if (server->focused_toplevel)
absinthe_toplevel_set_fullscreen(server->focused_toplevel, !server->focused_toplevel->fullscreen);
break;
case XKB_KEY_j:
focus_next(server);
-1
View File
@@ -174,7 +174,6 @@ void server_cursor_button(struct wl_listener *listener, void *data)
server->grabbed_geometry.y = ly;
server->grabbed_geometry.width = toplevel->geometry.width;
server->grabbed_geometry.height = toplevel->geometry.height;
server->grabbed_toplevel = toplevel;
if (server->cursor_mode != ABSINTHE_CURSOR_RESIZE)
goto handle;
+2 -1
View File
@@ -58,8 +58,9 @@ void xdg_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);
}
void xdg_toplevel_destroy(struct wl_listener *listener, void *data)