smart autofocus
This commit is contained in:
+3
-4
@@ -6,8 +6,7 @@ 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);
|
||||||
|
|
||||||
struct absinthe_toplevel *focus_get_first_tiled(struct absinthe_output *output);
|
void focus_logical_next(struct absinthe_toplevel *toplevel);
|
||||||
struct absinthe_toplevel *focus_get_last_tiled(struct absinthe_output *output);
|
|
||||||
|
|
||||||
void focus_next(struct absinthe_server *server);
|
void focus_next(struct absinthe_server *server, bool tiled);
|
||||||
void focus_prev(struct absinthe_server *server);
|
void focus_prev(struct absinthe_server *server, bool tiled);
|
||||||
|
|||||||
@@ -106,10 +106,12 @@ 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_logical_next(toplevel);
|
||||||
|
|
||||||
wl_list_remove(&toplevel->link);
|
wl_list_remove(&toplevel->link);
|
||||||
wl_list_remove(&toplevel->flink);
|
wl_list_remove(&toplevel->flink);
|
||||||
|
|
||||||
if (toplevel->output == toplevel->server->focused_output)
|
|
||||||
layout_arrange(toplevel->output);
|
layout_arrange(toplevel->output);
|
||||||
|
|
||||||
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
||||||
|
|||||||
+26
-18
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "absinthe-toplevel.h"
|
#include "absinthe-toplevel.h"
|
||||||
|
#include "focus.h"
|
||||||
|
|
||||||
void focus_toplevel(struct absinthe_toplevel *toplevel)
|
void focus_toplevel(struct absinthe_toplevel *toplevel)
|
||||||
{
|
{
|
||||||
@@ -59,27 +60,22 @@ struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct absinthe_toplevel *focus_get_first_tiled(struct absinthe_output *output)
|
void focus_logical_next(struct absinthe_toplevel *toplevel)
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel;
|
struct absinthe_toplevel *temp;
|
||||||
wl_list_for_each(toplevel, &output->server->focus_stack, flink) {
|
size_t i = 0;
|
||||||
if (toplevel->tiled && toplevel->output == output)
|
wl_list_for_each(temp, &toplevel->server->toplevels, link) {
|
||||||
return toplevel;
|
if (toplevel == temp && i == 0) {
|
||||||
|
focus_next(toplevel->server, true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return NULL;
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
focus_prev(toplevel->server, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct absinthe_toplevel *focus_get_last_tiled(struct absinthe_output *output)
|
void focus_next(struct absinthe_server *server, bool tiled)
|
||||||
{
|
|
||||||
struct absinthe_toplevel *toplevel;
|
|
||||||
wl_list_for_each_reverse(toplevel, &output->server->focus_stack, flink) {
|
|
||||||
if (toplevel->tiled && toplevel->output == output)
|
|
||||||
return toplevel;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void focus_next(struct absinthe_server *server)
|
|
||||||
{
|
{
|
||||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||||
if (!toplevel)
|
if (!toplevel)
|
||||||
@@ -89,12 +85,18 @@ void focus_next(struct absinthe_server *server)
|
|||||||
wl_list_for_each(next, &toplevel->link, link) {
|
wl_list_for_each(next, &toplevel->link, link) {
|
||||||
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)
|
void focus_prev(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)
|
||||||
@@ -104,7 +106,13 @@ void focus_prev(struct absinthe_server *server)
|
|||||||
wl_list_for_each_reverse(prev, &toplevel->link, link) {
|
wl_list_for_each_reverse(prev, &toplevel->link, link) {
|
||||||
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
@@ -39,10 +39,10 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
|
|||||||
absinthe_toplevel_set_fullscreen(server->focused_toplevel, !server->focused_toplevel->fullscreen);
|
absinthe_toplevel_set_fullscreen(server->focused_toplevel, !server->focused_toplevel->fullscreen);
|
||||||
break;
|
break;
|
||||||
case XKB_KEY_j:
|
case XKB_KEY_j:
|
||||||
focus_next(server);
|
focus_next(server, false);
|
||||||
break;
|
break;
|
||||||
case XKB_KEY_k:
|
case XKB_KEY_k:
|
||||||
focus_prev(server);
|
focus_prev(server, false);
|
||||||
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user