aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-12-30 11:51:45 +0100
committerJoe <rbo@gmx.us>2024-12-30 11:51:45 +0100
commitc4f95544c1f6d84ab489d49d96280e05f125adf7 (patch)
tree8daf3ccf65525376de598c2690dc4faa0deb8bab /dwm.c
parentapplied underline tags (diff)
downloaddwm-c4f95544c1f6d84ab489d49d96280e05f125adf7.tar.gz
dwm-c4f95544c1f6d84ab489d49d96280e05f125adf7.tar.bz2
dwm-c4f95544c1f6d84ab489d49d96280e05f125adf7.tar.xz
dwm-c4f95544c1f6d84ab489d49d96280e05f125adf7.tar.zst
dwm-c4f95544c1f6d84ab489d49d96280e05f125adf7.zip
its a start
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index 1218622..a477d6f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -85,7 +85,7 @@ enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+ NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */
enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText,
@@ -252,6 +252,7 @@ static void scan(void);
static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state);
+static void setclienttagprop(Client *c);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setgaps(const Arg *arg);
@@ -259,6 +260,8 @@ static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
static void seturgent(Client *c, int urg);
+static void shiftboth(const Arg *arg);
+static void shiftview(const Arg *arg);
static void showhide(Client *c);
static void sighup(int unused);
static void sigterm(int unused);
@@ -1626,6 +1629,26 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ {
+ int format;
+ unsigned long *data, n, extra;
+ Monitor *m;
+ Atom atom;
+ if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL,
+ &atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) {
+ c->tags = *data;
+ for (m = mons; m; m = m->next) {
+ if (m->num == *(data+1)) {
+ c->mon = m;
+ break;
+ }
+ }
+ }
+ if (n > 0)
+ XFree(data);
+ }
+ setclienttagprop(c);
+
c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
c->sfx = c->x;
@@ -2330,6 +2353,7 @@ sendmon(Client *c, Monitor *m)
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
attachBelow(c);
attachstack(c);
+ setclienttagprop(c);
focus(NULL);
arrange(NULL);
}
@@ -2508,6 +2532,7 @@ setup(void)
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+ netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False);
xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
@@ -2542,6 +2567,7 @@ setup(void)
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
PropModeReplace, (unsigned char *) netatom, NetLast);
XDeleteProperty(dpy, root, netatom[NetClientList]);
+ XDeleteProperty(dpy, root, netatom[NetClientInfo]);
/* select events */
wa.cursor = cursor[CurNormal]->cursor;
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
@@ -2567,6 +2593,33 @@ seturgent(Client *c, int urg)
}
void
+shiftboth(const Arg *arg)
+{
+ Arg shifted;
+ shifted.ui = selmon->tagset[selmon->seltags];
+
+ if (arg->i > 0) /* left circular shift */
+ shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)));
+ else /* right circular shift */
+ shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i)));
+ tag(&shifted);
+ view(&shifted);
+}
+
+void
+shiftview(const Arg *arg)
+{
+ Arg shifted;
+ shifted.ui = selmon->tagset[selmon->seltags];
+
+ if (arg->i > 0) /* left circular shift */
+ shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i));
+ else /* right circular shift */
+ shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << (LENGTH(tags) + arg->i));
+ view(&shifted);
+}
+
+void
showhide(Client *c)
{
if (!c)
@@ -2681,12 +2734,23 @@ spawn(const Arg *arg)
die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]);
}
}
+void
+setclienttagprop(Client *c)
+{
+ long data[] = { (long) c->tags, (long) c->mon->num };
+ XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *) data, 2);
+}
void
tag(const Arg *arg)
{
+ Client *c;
+
if (selmon->sel && arg->ui & TAGMASK) {
+ c = selmon->sel;
selmon->sel->tags = arg->ui & TAGMASK;
+ setclienttagprop(c);
focus(NULL);
arrange(selmon);
}
@@ -2725,6 +2789,7 @@ tagothermon(const Arg *arg, int dir)
sendmon(sel, newmon);
if (arg->ui & TAGMASK) {
sel->tags = arg->ui & TAGMASK;
+ setclienttagprop(selmon->sel);
focus(NULL);
arrange(newmon);
}
@@ -2866,6 +2931,7 @@ toggletag(const Arg *arg)
newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
if (newtags) {
selmon->sel->tags = newtags;
+ setclienttagprop(selmon->sel);
focus(NULL);
arrange(selmon);
}