mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-24 06:59:54 -05:00
fix: can't find center root_client when open two floating window
This commit is contained in:
parent
e619b76f5d
commit
e7a6e85569
1 changed files with 27 additions and 7 deletions
32
maomao.c
32
maomao.c
|
|
@ -1686,6 +1686,27 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Client *center_select(Monitor* m) {
|
||||||
|
Client *c = NULL;
|
||||||
|
Client *target_c = NULL;
|
||||||
|
long int mini_distance = -1;
|
||||||
|
int dirx,diry;
|
||||||
|
long int distance;
|
||||||
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
if (c && VISIBLEON(c, m) && client_surface(c)->mapped && !c->isfloating) {
|
||||||
|
dirx = c->geom.x + c->geom.width / 2 - (m->w.x + m->w.width / 2);
|
||||||
|
diry = c->geom.y + c->geom.height / 2 - (m->w.y + m->w.height / 2);
|
||||||
|
distance = dirx * dirx + diry * diry;
|
||||||
|
if (distance < mini_distance || mini_distance == -1) {
|
||||||
|
mini_distance = distance;
|
||||||
|
target_c = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return target_c;
|
||||||
|
}
|
||||||
|
|
||||||
Client *direction_select(const Arg *arg) {
|
Client *direction_select(const Arg *arg) {
|
||||||
Client *c;
|
Client *c;
|
||||||
Client **tempClients = NULL; // 初始化为 NULL
|
Client **tempClients = NULL; // 初始化为 NULL
|
||||||
|
|
@ -5931,13 +5952,12 @@ void scroller(Monitor *m, unsigned int gappo, unsigned int gappi) {
|
||||||
!m->prevsel->ismaxmizescreen && !m->prevsel->isfullscreen) {
|
!m->prevsel->ismaxmizescreen && !m->prevsel->isfullscreen) {
|
||||||
root_client = m->prevsel;
|
root_client = m->prevsel;
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(c, &clients, link) {
|
root_client = center_select(m);
|
||||||
if (c->iskilling)
|
|
||||||
continue;
|
|
||||||
if (c->tags == m->tagset[m->seltags] && !c->isfloating) {
|
|
||||||
root_client = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!root_client) {
|
||||||
|
free(tempClients); // 释放内存
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue