windowmap (with awesomebar compatibility)
This commit is contained in:
parent
9894a8b31b
commit
481e9ca8f1
70
speedwm.c
70
speedwm.c
|
@ -209,6 +209,7 @@ struct Client {
|
|||
Client *next;
|
||||
Client *snext;
|
||||
Client *swallowing;
|
||||
Client *ishidden;
|
||||
Monitor *mon;
|
||||
Window win;
|
||||
#if USEIPC
|
||||
|
@ -738,6 +739,11 @@ static void viewtoright(const Arg *arg);
|
|||
static void viewtoleft_vacant(const Arg *arg);
|
||||
static void viewtoright_vacant(const Arg *arg);
|
||||
|
||||
/* window mapping */
|
||||
static void window_set_state(Display *dpy, Window win, long state);
|
||||
static void window_map(Display *dpy, Client *c, int deiconify);
|
||||
static void window_unmap(Display *dpy, Window win, Window root, int iconify);
|
||||
|
||||
static Client *wintoclient(Window w);
|
||||
static Monitor *wintomon(Window w);
|
||||
static int wmclasscontains(Window win, const char *class, const char *name);
|
||||
|
@ -3264,6 +3270,8 @@ hidewin(Client *c) {
|
|||
XSelectInput(dpy, root, ra.your_event_mask);
|
||||
XSelectInput(dpy, w, ca.your_event_mask);
|
||||
XUngrabServer(dpy);
|
||||
|
||||
c->ishidden = 1;
|
||||
}
|
||||
|
||||
#if USEIPC
|
||||
|
@ -3520,6 +3528,8 @@ showwin(Client *c)
|
|||
if (!c || !HIDDEN(c))
|
||||
return;
|
||||
|
||||
c->ishidden = 0;
|
||||
|
||||
XMapWindow(dpy, c->win);
|
||||
setclientstate(c, NormalState);
|
||||
arrange(c->mon);
|
||||
|
@ -3532,8 +3542,6 @@ showhide(Client *c)
|
|||
return;
|
||||
if (ISVISIBLE(c)) {
|
||||
/* show clients top down */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||
|
||||
if (c->needresize && autoresize) {
|
||||
c->needresize = 0;
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
|
@ -3542,13 +3550,13 @@ showhide(Client *c)
|
|||
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);
|
||||
showhide(c->snext);
|
||||
|
||||
window_map(dpy, c, 1);
|
||||
showhide(c->snext);
|
||||
} else {
|
||||
/* hide clients bottom up */
|
||||
showhide(c->snext);
|
||||
XMoveWindow(dpy, c->win, c->mon->wx + c->mon->ww / 2 - WIDTH(c) / 2, - (HEIGHT(c) * 3) / 2);
|
||||
window_unmap(dpy, c->win, root, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4131,6 +4139,56 @@ motionnotify(XEvent *e)
|
|||
mon = m;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* fix: hidden windows immediately get mapped */
|
||||
if (c->ishidden)
|
||||
return;
|
||||
|
||||
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 ca, ra;
|
||||
|
||||
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
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue