diff --git a/README.md b/README.md index 47106aa..e37f156 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2019-09-11 - Added monitor rules and combo patches +2019-09-11 - Added monitor rules, combo and ewmhtags patches 2019-09-10 - Minor tweaks to awesomebar patch (incl. alpha and systray compatibility). Added floatbordercolor patch. @@ -65,6 +65,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/) - lets you cycle through all your layouts + - [ewmhtags](https://dwm.suckless.org/patches/ewmhtags/) + - adds EWMH support for \_NET_NUMBER_OF_DESKTOPS, \_NET_CURRENT_DESKTOP, \_NET_DESKTOP_NAMES and \_NET_DESKTOP_VIEWPORT, which allows for compatibility with other bars and programs that request workspace information, e.g. polybar's xworkspaces module + - [fancybar](https://dwm.suckless.org/patches/fancybar/) - shows the titles of all visible windows in the status bar diff --git a/config.def.h b/config.def.h index 31ffa1a..871490d 100644 --- a/config.def.h +++ b/config.def.h @@ -62,7 +62,11 @@ static const char *colors[][3] = { #endif // FLOAT_BORDER_COLOR_PATCH /* tagging */ +#if EWMHTAGS_PATCH +static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +#else static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +#endif // EWMHTAGS_PATCH #if ALTERNATIVE_TAGS_PATCH static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; #endif // ALTERNATIVE_TAGS_PATCH diff --git a/dwm.c b/dwm.c index d32a077..555b818 100644 --- a/dwm.c +++ b/dwm.c @@ -73,15 +73,18 @@ enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */ #else enum { SchemeNorm, SchemeSel }; /* color schemes */ #endif // #if AWESOMEBAR_PATCH -#if SYSTRAY_PATCH -enum { NetSupported, NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayVisual, - NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDock, - NetSystemTrayOrientationHorz, NetWMWindowTypeDialog, NetClientList, NetWMCheck, NetLast }; /* EWMH atoms */ -#else enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ -#endif // SYSTRAY_PATCH + #if SYSTRAY_PATCH + NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, + NetSystemTrayVisual, NetWMWindowTypeDock, NetSystemTrayOrientationHorz, + #endif // SYSTRAY_PATCH + #if EWMHTAGS_PATCH + NetDesktopNames, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop, + #endif // EWMHTAGS_PATCH + NetWMWindowTypeDialog, NetClientList, NetLast +}; /* EWMH atoms */ + #if WINDOWROLERULE_PATCH enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMWindowRole, WMLast }; /* default atoms */ #else @@ -2220,6 +2223,12 @@ setup(void) xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False); xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False); #endif // SYSTRAY_PATCH + #if EWMHTAGS_PATCH + netatom[NetDesktopViewport] = XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False); + netatom[NetNumberOfDesktops] = XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False); + netatom[NetCurrentDesktop] = XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False); + netatom[NetDesktopNames] = XInternAtom(dpy, "_NET_DESKTOP_NAMES", False); + #endif // EWMHTAGS_PATCH netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); @@ -2263,6 +2272,12 @@ setup(void) /* EWMH support per view */ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); + #if EWMHTAGS_PATCH + setnumdesktops(); + setcurrentdesktop(); + setdesktopnames(); + setviewport(); + #endif // EWMHTAGS_PATCH XDeleteProperty(dpy, root, netatom[NetClientList]); /* select events */ wa.cursor = cursor[CurNormal]->cursor; @@ -2445,6 +2460,9 @@ toggletag(const Arg *arg) focus(NULL); arrange(selmon); } + #if EWMHTAGS_PATCH + updatecurrentdesktop(); + #endif // EWMHTAGS_PATCH } void @@ -2484,6 +2502,9 @@ toggleview(const Arg *arg) focus(NULL); arrange(selmon); } + #if EWMHTAGS_PATCH + updatecurrentdesktop(); + #endif // EWMHTAGS_PATCH } void @@ -2858,6 +2879,9 @@ view(const Arg *arg) #endif // PERTAG_PATCH focus(NULL); arrange(selmon); + #if EWMHTAGS_PATCH + updatecurrentdesktop(); + #endif // EWMHTAGS_PATCH } Client * diff --git a/patch/ewmhtags.c b/patch/ewmhtags.c new file mode 100644 index 0000000..682d900 --- /dev/null +++ b/patch/ewmhtags.c @@ -0,0 +1,40 @@ +void +setcurrentdesktop(void) +{ + long data[] = { 0 }; + XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1); +} + +void +setdesktopnames(void) +{ + XTextProperty text; + Xutf8TextListToTextProperty(dpy, tags, TAGSLENGTH, XUTF8StringStyle, &text); + XSetTextProperty(dpy, root, &text, netatom[NetDesktopNames]); +} + +void +setnumdesktops(void) +{ + long data[] = { TAGSLENGTH }; + XChangeProperty(dpy, root, netatom[NetNumberOfDesktops], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1); +} + +void +setviewport(void) +{ + long data[] = { 0, 0 }; + XChangeProperty(dpy, root, netatom[NetDesktopViewport], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 2); +} + +void +updatecurrentdesktop(void) +{ + long rawdata[] = { selmon->tagset[selmon->seltags] }; + int i = 0; + while (*rawdata >> (i + 1)) { + i++; + } + long data[] = { i }; + XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1); +} \ No newline at end of file diff --git a/patch/ewmhtags.h b/patch/ewmhtags.h new file mode 100644 index 0000000..2ec890e --- /dev/null +++ b/patch/ewmhtags.h @@ -0,0 +1,7 @@ +#define TAGSLENGTH (LENGTH(tags)) + +static void setcurrentdesktop(void); +static void setdesktopnames(void); +static void setnumdesktops(void); +static void setviewport(void); +static void updatecurrentdesktop(void); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 1ddc897..809a792 100644 --- a/patch/include.c +++ b/patch/include.c @@ -32,6 +32,10 @@ #include "cyclelayouts.c" #endif +#if EWMHTAGS_PATCH +#include "ewmhtags.c" +#endif + #if PERTAG_PATCH #include "pertag.c" #endif diff --git a/patch/include.h b/patch/include.h index 3e3027c..9226f4d 100644 --- a/patch/include.h +++ b/patch/include.h @@ -32,6 +32,10 @@ #include "cyclelayouts.h" #endif +#if EWMHTAGS_PATCH +#include "ewmhtags.h" +#endif + #if ROTATESTACK_PATCH #include "rotatestack.h" #endif diff --git a/patches.h b/patches.h index 05e6b4d..adb1a1d 100644 --- a/patches.h +++ b/patches.h @@ -85,6 +85,13 @@ */ #define CYCLELAYOUTS_PATCH 0 +/* Adds EWMH support for _NET_NUMBER_OF_DESKTOPS, _NET_CURRENT_DESKTOP, _NET_DESKTOP_NAMES + * and _NET_DESKTOP_VIEWPORT, which allows for compatibility with other bars and programs + * that request workspace information. For example polybar's xworkspaces module. + * https://dwm.suckless.org/patches/ewmhtags/ + */ +#define EWMHTAGS_PATCH 0 + /* This patch shows the titles of all visible windows in the status bar * (as opposed to showing only the selected one). * Awesomebar takes precedence over fancybar.