windo map patch
This commit is contained in:
parent
3fd2ae71f3
commit
cd218b417b
54
dwm.c
54
dwm.c
@ -274,6 +274,9 @@ static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
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 xerror(Display *dpy, XErrorEvent *ee);
|
||||
@ -2349,14 +2352,12 @@ showhide(Client *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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2934,6 +2935,51 @@ updatewmhints(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
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 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
|
||||
view(const Arg *arg)
|
||||
{
|
||||
|
83
patches/behavior/dwm-windowmap-20221026.diff
Normal file
83
patches/behavior/dwm-windowmap-20221026.diff
Normal file
@ -0,0 +1,83 @@
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index e5efb6a..eaf0333 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -228,6 +228,9 @@ static void updatetitle(Client *c);
|
||||
static void updatewindowtype(Client *c);
|
||||
static void updatewmhints(Client *c);
|
||||
static void view(const Arg *arg);
|
||||
+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 xerror(Display *dpy, XErrorEvent *ee);
|
||||
@@ -1617,14 +1620,12 @@ showhide(Client *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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2032,6 +2033,51 @@ updatewmhints(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
+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 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
|
||||
view(const Arg *arg)
|
||||
{
|
Loading…
Reference in New Issue
Block a user