focus stack and next/prev toplevel keybinds
This commit is contained in:
+37
-2
@@ -1,4 +1,5 @@
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "absinthe-toplevel.h"
|
||||
@@ -26,11 +27,45 @@ void focus_toplevel(struct absinthe_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->link);
|
||||
wl_list_insert(&server->toplevels, &toplevel->link);
|
||||
wl_list_remove(&toplevel->flink);
|
||||
wl_list_insert(&server->focus_stack, &toplevel->flink);
|
||||
wlr_xdg_toplevel_set_activated(toplevel->xdg_toplevel, true);
|
||||
absinthe_toplevel_set_border_color(toplevel, focused_border_color);
|
||||
|
||||
if (keyboard)
|
||||
wlr_seat_keyboard_notify_enter(seat, surface, keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
|
||||
}
|
||||
|
||||
static struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel;
|
||||
wl_list_for_each(toplevel, &server->focus_stack, flink) {
|
||||
if (toplevel)
|
||||
return toplevel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void focus_next(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||
struct absinthe_toplevel *next;
|
||||
wl_list_for_each(next, &toplevel->link, link) {
|
||||
if (&next->link == &toplevel->server->toplevels)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
focus_toplevel(next);
|
||||
}
|
||||
|
||||
void focus_prev(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||
struct absinthe_toplevel *prev;
|
||||
wl_list_for_each_reverse(prev, &toplevel->link, link) {
|
||||
if (&prev->link == &toplevel->server->toplevels)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
focus_toplevel(prev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user