opt: optimize minimize logic

This commit is contained in:
DreamMaoMao 2025-09-07 14:52:30 +08:00
parent 74b887011d
commit 394e32dabd
2 changed files with 27 additions and 2 deletions

View file

@ -389,6 +389,7 @@ void resizewin(const Arg *arg) {
c->oldgeom = c->geom; c->oldgeom = c->geom;
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
void restore_minimized(const Arg *arg) { void restore_minimized(const Arg *arg) {
Client *c; Client *c;
if (selmon && selmon->sel && selmon->sel->is_in_scratchpad && if (selmon && selmon->sel && selmon->sel->is_in_scratchpad &&

View file

@ -3539,6 +3539,27 @@ maximizenotify(struct wl_listener *listener, void *data) {
setmaxmizescreen(c, 1); setmaxmizescreen(c, 1);
} }
void unminimize(Client *c) {
if (c && c->is_in_scratchpad && c->is_scratchpad_show) {
c->isminied = 0;
c->is_scratchpad_show = 0;
c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0;
setborder_color(c);
return;
}
if (c && c->isminied) {
show_hide_client(c);
c->is_scratchpad_show = 0;
c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0;
setborder_color(c);
arrange(c->mon, false);
return;
}
}
void set_minimized(Client *c) { void set_minimized(Client *c) {
if (!c || !c->mon) if (!c || !c->mon)
@ -3582,9 +3603,12 @@ minimizenotify(struct wl_listener *listener, void *data) {
return; return;
if (client_request_minimize(c, data) && !c->ignore_minimize) { if (client_request_minimize(c, data) && !c->ignore_minimize) {
if (!c->isminied)
set_minimized(c); set_minimized(c);
client_set_minimized(c, true); client_set_minimized(c, true);
} else { } else {
if (c->isminied)
unminimize(c);
client_set_minimized(c, false); client_set_minimized(c, false);
} }
} }
@ -5401,7 +5425,7 @@ void activatex11(struct wl_listener *listener, void *data) {
view(&(Arg){.ui = c->tags}, true); view(&(Arg){.ui = c->tags}, true);
wlr_xwayland_surface_activate(c->surface.xwayland, 1); wlr_xwayland_surface_activate(c->surface.xwayland, 1);
focusclient(c, 1); focusclient(c, 1);
need_arrange = false; need_arrange = true;
} else if (c != focustop(selmon)) { } else if (c != focustop(selmon)) {
c->isurgent = 1; c->isurgent = 1;
if (client_surface(c)->mapped) if (client_surface(c)->mapped)