smart autofocus
This commit is contained in:
+26
-18
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "absinthe-toplevel.h"
|
||||
#include "focus.h"
|
||||
|
||||
void focus_toplevel(struct absinthe_toplevel *toplevel)
|
||||
{
|
||||
@@ -59,27 +60,22 @@ struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
|
||||
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;
|
||||
wl_list_for_each(toplevel, &output->server->focus_stack, flink) {
|
||||
if (toplevel->tiled && toplevel->output == output)
|
||||
return toplevel;
|
||||
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;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
focus_prev(toplevel->server, true);
|
||||
}
|
||||
|
||||
struct absinthe_toplevel *focus_get_last_tiled(struct absinthe_output *output)
|
||||
{
|
||||
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)
|
||||
void focus_next(struct absinthe_server *server, bool tiled)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||
if (!toplevel)
|
||||
@@ -89,12 +85,18 @@ void focus_next(struct absinthe_server *server)
|
||||
wl_list_for_each(next, &toplevel->link, link) {
|
||||
if (&next->link == &toplevel->server->toplevels)
|
||||
continue;
|
||||
if (tiled && !next->tiled)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (tiled && !next->tiled) {
|
||||
wlr_log(WLR_ERROR, "No tiled");
|
||||
return;
|
||||
}
|
||||
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);
|
||||
if (!toplevel)
|
||||
@@ -104,7 +106,13 @@ void focus_prev(struct absinthe_server *server)
|
||||
wl_list_for_each_reverse(prev, &toplevel->link, link) {
|
||||
if (&prev->link == &toplevel->server->toplevels)
|
||||
continue;
|
||||
if (tiled && !prev->tiled)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (tiled && !prev->tiled) {
|
||||
wlr_log(WLR_ERROR, "No tiled");
|
||||
return;
|
||||
}
|
||||
focus_toplevel(prev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user