[hackers] dwm-6.0-current_desktop.diff

From: R0B R0D <witchdoctor.mdf_AT_gmail.com>
Date: Wed, 19 Aug 2015 14:00:09 -0400

Hi, this is my first patch, I was helping someone on IRC and got it to work.

# wmctrl -d
Cannot get number of desktops properties. (_NET_NUMBER_OF_DESKTOPS or
_WIN_WORKSPACE_COUNT)

/*Output after patch */

# wmctrl -d
0 - DG: N/A VP: N/A WA: N/A N/A
1 * DG: N/A VP: N/A WA: N/A N/A
2 - DG: N/A VP: N/A WA: N/A N/A
3 - DG: N/A VP: N/A WA: N/A N/A
4 - DG: N/A VP: N/A WA: N/A N/A

-Roberto

--- dwm.c.orig 2011-12-19 10:02:46.000000000 -0500
+++ dwm.c 2015-08-19 13:04:05.843531007 -0400
_AT__AT_ -59,8 +59,10 @@
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
 enum { NetSupported, NetWMName, NetWMState,
- NetWMFullscreen, NetActiveWindow, NetWMWindowType,
+ NetWMFullscreen, NetNumberOfDesktops,
+ NetCurrentDesktop,NetActiveWindow, NetWMWindowType,
        NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */
+
 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /*
default atoms */
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
        ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
_AT__AT_ -220,6 +222,7 @@
 static void setfullscreen(Client *c, Bool fullscreen);
 static void setlayout(const Arg *arg);
 static void setmfact(const Arg *arg);
+static void setnumbdesktops(void);
 static void setup(void);
 static void showhide(Client *c);
 static void sigchld(int unused);
_AT__AT_ -235,6 +238,7 @@
 static void unfocus(Client *c, Bool setfocus);
 static void unmanage(Client *c, Bool destroyed);
 static void unmapnotify(XEvent *e);
+static void updatecurrenddesktop(void);
 static Bool updategeom(void);
 static void updatebarpos(Monitor *m);
 static void updatebars(void);
_AT__AT_ -1487,6 +1491,13 @@
 }

 void
+setcurrentdesktop(void){
+ long data[] = { 0 };
+ XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *)data, 1);
+}
+
+void
 setclientstate(Client *c, long state) {
         long data[] = { state, None };

_AT__AT_ -1581,6 +1592,13 @@
 }

 void
+setnumbdesktops(void){
+ long data[] = { TAGMASK };
+ XChangeProperty(dpy, root, netatom[NetNumberOfDesktops],
XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *)data, 1);
+}
+
+void
 setup(void) {
         XSetWindowAttributes wa;

_AT__AT_ -1607,6 +1625,10 @@
         netatom[NetWMFullscreen] = XInternAtom(dpy,
"_NET_WM_STATE_FULLSCREEN", False);
         netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
         netatom[NetWMWindowTypeDialog] = XInternAtom(dpy,
"_NET_WM_WINDOW_TYPE_DIALOG", False);
+ netatom[NetNumberOfDesktops] = XInternAtom(dpy,
"_NET_NUMBER_OF_DESKTOPS", False);
+ netatom[NetCurrentDesktop] = XInternAtom(dpy,
"_NET_CURRENT_DESKTOP", False);
+
+
         /* init cursors */
         cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
         cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
_AT__AT_ -1629,6 +1651,10 @@
         /* EWMH support per view */
         XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
                         PropModeReplace, (unsigned char *) netatom, NetLast);
+ /* set EWMH NUMBER_OF_DESKTOPS */
+ setnumbdesktops();
+ /* initialize EWMH CURRENT_DESKTOP */
+ setcurrentdesktop();
         /* select for events */
         wa.cursor = cursor[CurNormal];
         wa.event_mask =
SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask
_AT__AT_ -1769,6 +1795,7 @@
                 focus(NULL);
                 arrange(selmon);
         }
+ updatecurrenddesktop();
 }

 void
_AT__AT_ -1848,6 +1875,14 @@
                 m->by = -bh;
 }

+void
+updatecurrenddesktop(){
+ long data[] = { selmon->tagset[selmon->seltags] };
+
+ XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *)data, 1);
+}
+
 Bool
 updategeom(void) {
         Bool dirty = False;
_AT__AT_ -2050,6 +2085,7 @@
                 selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
         focus(NULL);
         arrange(selmon);
+ updatecurrenddesktop();
 }

 Client *
Received on Wed Aug 19 2015 - 20:00:09 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 19 2015 - 20:12:10 CEST