opt: optimize null check in get_next_stack_client
This commit is contained in:
@@ -340,21 +340,33 @@ Client *focustop(Monitor *m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client *get_next_stack_client(Client *c, bool reverse) {
|
Client *get_next_stack_client(Client *c, bool reverse) {
|
||||||
|
if (!c || !c->mon)
|
||||||
|
return NULL; // 添加输入检查
|
||||||
|
|
||||||
Client *next = NULL;
|
Client *next = NULL;
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
wl_list_for_each_reverse(next, &c->link, link) {
|
wl_list_for_each_reverse(next, &c->link, link) {
|
||||||
|
if (!next)
|
||||||
|
continue; // 安全检查
|
||||||
|
|
||||||
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
||||||
!next->isfullscreen)
|
!next->isfullscreen)
|
||||||
continue;
|
continue;
|
||||||
if (VISIBLEON(next, c->mon) && next != c)
|
|
||||||
|
// 添加更安全的 VISIBLEON 检查
|
||||||
|
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(next, &c->link, link) {
|
wl_list_for_each(next, &c->link, link) {
|
||||||
|
if (!next)
|
||||||
|
continue; // 安全检查
|
||||||
|
|
||||||
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
||||||
!next->isfullscreen)
|
!next->isfullscreen)
|
||||||
continue;
|
continue;
|
||||||
if (VISIBLEON(next, c->mon) && next != c)
|
|
||||||
|
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
||||||
!(A)->ismaximizescreen && !(A)->isfullscreen)
|
!(A)->ismaximizescreen && !(A)->isfullscreen)
|
||||||
#define VISIBLEON(C, M) \
|
#define VISIBLEON(C, M) \
|
||||||
((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define END(A) ((A) + LENGTH(A))
|
#define END(A) ((A) + LENGTH(A))
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user