dwm

dynamic window manager
git clone https://git.parazyd.org/dwm
Log | Files | Refs | README | LICENSE

commit b43bd229c3efda95d18e7025c355beaa357caf5c
parent 5f54f09a5723d628a88d42a6a7b290982cdf1dec
Author: parazyd <parazyd@dyne.org>
Date:   Sat, 23 Apr 2022 23:51:06 +0200

Window mapping.

Diffstat:
Mdwm.c | 46++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -1627,20 +1627,58 @@ seturgent(Client *c, int urg) } void +window_set_state(Display *dpy, Window win, long state) +{ + long data[] = { state, None }; + + XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32, + PropModeReplace, (unsigned char*)data, 2); +} + +void +window_map(Display *dpy, Client *c, int deiconify) +{ + Window win = c->win; + + if (deiconify) + window_set_state(dpy, win, NormalState); + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); + XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime); + XMapWindow(dpy, win); +} + +void +window_unmap(Display *dpy, Window win, Window root, int iconify) +{ + static XWindowAttributes ra, ca; + + XGrabServer(dpy); + XGetWindowAttributes(dpy, root, &ra); + XGetWindowAttributes(dpy, win, &ca); + /* Prevent UnmapNotify events */ + XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); + XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask); + XUnmapWindow(dpy, win); + if (iconify) + window_set_state(dpy, win, IconicState); + XSelectInput(dpy, root, ra.your_event_mask); + XSelectInput(dpy, win, ca.your_event_mask); + XUngrabServer(dpy); +} + +void showhide(Client *c) { if (!c) return; if (ISVISIBLE(c)) { /* show clients top down */ - XMoveWindow(dpy, c->win, c->x, c->y); - if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) - resize(c, c->x, c->y, c->w, c->h, 0); + window_map(dpy, c, 1); showhide(c->snext); } else { /* hide clients bottom up */ showhide(c->snext); - XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); + window_unmap(dpy, c->win, root, 1); } }