mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-27 07:58:53 -04:00
fix: crash when focusmon to invalid monitor
This commit is contained in:
parent
814fd950e7
commit
481ccb534b
1 changed files with 5 additions and 3 deletions
|
|
@ -174,15 +174,17 @@ int toggle_trackpad_enable(const Arg *arg) {
|
||||||
int focusmon(const Arg *arg) {
|
int focusmon(const Arg *arg) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
Monitor *m = NULL;
|
Monitor *m = NULL;
|
||||||
|
Monitor *tm = NULL;
|
||||||
|
|
||||||
if (arg->i != UNDIR) {
|
if (arg->i != UNDIR) {
|
||||||
m = dirtomon(arg->i);
|
tm = dirtomon(arg->i);
|
||||||
} else if (arg->v) {
|
} else if (arg->v) {
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
if (!m->wlr_output->enabled) {
|
if (!m->wlr_output->enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (regex_match(arg->v, m->wlr_output->name)) {
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
tm = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -190,10 +192,10 @@ int focusmon(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m || !m->wlr_output->enabled || m == selmon)
|
if (!tm || !tm->wlr_output->enabled || tm == selmon)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
selmon = m;
|
selmon = tm;
|
||||||
if (warpcursor) {
|
if (warpcursor) {
|
||||||
warp_cursor_to_selmon(selmon);
|
warp_cursor_to_selmon(selmon);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue