mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-22 05:34:18 -04:00
feat: optimize focusdir to respect focusstack
This commit is contained in:
parent
57d7801df2
commit
0a03141602
3 changed files with 77 additions and 1 deletions
|
|
@ -129,6 +129,7 @@ int32_t exchange_stack_client(const Arg *arg) {
|
||||||
int32_t focusdir(const Arg *arg) {
|
int32_t focusdir(const Arg *arg) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
c = direction_select(arg);
|
c = direction_select(arg);
|
||||||
|
c = get_focused_stack_client(c);
|
||||||
if (c) {
|
if (c) {
|
||||||
focusclient(c, 1);
|
focusclient(c, 1);
|
||||||
if (warpcursor)
|
if (warpcursor)
|
||||||
|
|
|
||||||
|
|
@ -455,4 +455,77 @@ Client *get_scroll_stack_head(Client *c) {
|
||||||
scroller_stack_head = scroller_stack_head->prev_in_stack;
|
scroller_stack_head = scroller_stack_head->prev_in_stack;
|
||||||
}
|
}
|
||||||
return scroller_stack_head;
|
return scroller_stack_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc) {
|
||||||
|
if (!sc || !tc)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32_t id = sc->mon->pertag->ltidxs[sc->mon->pertag->curtag]->id;
|
||||||
|
|
||||||
|
if (id != SCROLLER && id != VERTICAL_SCROLLER && id != TILE &&
|
||||||
|
id != VERTICAL_TILE && id != DECK && id != VERTICAL_DECK &&
|
||||||
|
id != CENTER_TILE && id != RIGHT_TILE && id != TGMIX)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (id == SCROLLER || id == VERTICAL_SCROLLER) {
|
||||||
|
if (fc->prev_in_stack)
|
||||||
|
return false;
|
||||||
|
Client *source_stack_head = get_scroll_stack_head(sc);
|
||||||
|
Client *target_stack_head = get_scroll_stack_head(tc);
|
||||||
|
if (source_stack_head == target_stack_head)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == TILE || id == VERTICAL_TILE || id == DECK ||
|
||||||
|
id == VERTICAL_DECK || id == RIGHT_TILE) {
|
||||||
|
if (!fc->ismaster)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == TGMIX) {
|
||||||
|
if (!fc->ismaster)
|
||||||
|
return false;
|
||||||
|
if (sc->mon->visible_tiling_clients <= 3)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == CENTER_TILE) {
|
||||||
|
if (!fc->ismaster)
|
||||||
|
return false;
|
||||||
|
if (sc->geom.x == tc->geom.x)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *get_focused_stack_client(Client *sc) {
|
||||||
|
if (!sc || sc->isfloating)
|
||||||
|
return sc;
|
||||||
|
|
||||||
|
Client *tc = NULL;
|
||||||
|
Client *fc = focustop(sc->mon);
|
||||||
|
|
||||||
|
wl_list_for_each(tc, &fstack, flink) {
|
||||||
|
if (tc->iskilling || tc->isunglobal)
|
||||||
|
continue;
|
||||||
|
if (!VISIBLEON(tc, sc->mon))
|
||||||
|
continue;
|
||||||
|
if (tc == fc)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (client_is_in_same_stack(sc, tc, fc)) {
|
||||||
|
wlr_log(WLR_ERROR, "11");
|
||||||
|
return tc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wlr_log(WLR_ERROR, "22");
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -776,6 +776,8 @@ static Client *find_client_by_direction(Client *tc, const Arg *arg,
|
||||||
static void exit_scroller_stack(Client *c);
|
static void exit_scroller_stack(Client *c);
|
||||||
static Client *get_scroll_stack_head(Client *c);
|
static Client *get_scroll_stack_head(Client *c);
|
||||||
static bool client_only_in_one_tag(Client *c);
|
static bool client_only_in_one_tag(Client *c);
|
||||||
|
static Client *get_focused_stack_client(Client *sc);
|
||||||
|
static bool client_is_in_same_stack(Client *sc, Client *tc, Client *fc);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue