simplier focus

This commit is contained in:
2026-04-28 22:50:00 +07:00
parent 66fc7d0bf5
commit f7367395f0
4 changed files with 7 additions and 39 deletions
+2 -4
View File
@@ -6,7 +6,5 @@ void focus_toplevel(struct absinthe_toplevel *toplevel);
struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server); struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server);
void focus_after_unmap(struct absinthe_toplevel *toplevel); void focus_next(struct absinthe_server *server);
void focus_prev(struct absinthe_server *server);
void focus_next(struct absinthe_server *server, bool tiled);
void focus_prev(struct absinthe_server *server, bool tiled);
+1 -3
View File
@@ -67,13 +67,11 @@ void absinthe_toplevel_unmap(struct wl_listener *listener, void *data)
toplevel->server->seat->keyboard_state.focused_surface = NULL; toplevel->server->seat->keyboard_state.focused_surface = NULL;
} }
if (toplevel->output == toplevel->server->focused_output && toplevel->tiled)
focus_after_unmap(toplevel);
wl_list_remove(&toplevel->link); wl_list_remove(&toplevel->link);
wl_list_remove(&toplevel->flink); wl_list_remove(&toplevel->flink);
layout_arrange(toplevel->output); layout_arrange(toplevel->output);
focus_toplevel(focus_get_topmost(toplevel->server));
wlr_scene_node_destroy(&toplevel->scene_tree->node); wlr_scene_node_destroy(&toplevel->scene_tree->node);
} }
+2 -30
View File
@@ -63,23 +63,7 @@ struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
return NULL; return NULL;
} }
void focus_after_unmap(struct absinthe_toplevel *toplevel) void focus_next(struct absinthe_server *server)
{
struct absinthe_toplevel *temp;
size_t i = 0;
wl_list_for_each(temp, &toplevel->server->toplevels, link)
{
if (toplevel == temp && i == 0) {
focus_next(toplevel->server, true);
return;
}
++i;
}
focus_prev(toplevel->server, true);
}
void focus_next(struct absinthe_server *server, bool tiled)
{ {
struct absinthe_toplevel *toplevel = focus_get_topmost(server); struct absinthe_toplevel *toplevel = focus_get_topmost(server);
if (!toplevel) if (!toplevel)
@@ -90,18 +74,12 @@ void focus_next(struct absinthe_server *server, bool tiled)
{ {
if (&next->link == &toplevel->server->toplevels) if (&next->link == &toplevel->server->toplevels)
continue; continue;
if (tiled && !next->tiled)
continue;
break; break;
} }
if (tiled && !next->tiled) {
wlr_log(WLR_ERROR, "No tiled");
return;
}
focus_toplevel(next); focus_toplevel(next);
} }
void focus_prev(struct absinthe_server *server, bool tiled) void focus_prev(struct absinthe_server *server)
{ {
struct absinthe_toplevel *toplevel = focus_get_topmost(server); struct absinthe_toplevel *toplevel = focus_get_topmost(server);
if (!toplevel) if (!toplevel)
@@ -112,13 +90,7 @@ void focus_prev(struct absinthe_server *server, bool tiled)
{ {
if (&prev->link == &toplevel->server->toplevels) if (&prev->link == &toplevel->server->toplevels)
continue; continue;
if (tiled && !prev->tiled)
continue;
break; break;
} }
if (tiled && !prev->tiled) {
wlr_log(WLR_ERROR, "No tiled");
return;
}
focus_toplevel(prev); focus_toplevel(prev);
} }
+2 -2
View File
@@ -39,10 +39,10 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
!server->focused_toplevel->fullscreen); !server->focused_toplevel->fullscreen);
break; break;
case XKB_KEY_j: case XKB_KEY_j:
focus_next(server, false); focus_next(server);
break; break;
case XKB_KEY_k: case XKB_KEY_k:
focus_prev(server, false); focus_prev(server);
break; break;
case XKB_KEY_h: case XKB_KEY_h:
if (server->focused_output && server->focused_output->main_stack_width > 0.15) { if (server->focused_output && server->focused_output->main_stack_width > 0.15) {