| dwm-sticky-6.5.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dwm-sticky-6.5.diff (5476B) | |
| --- | |
| 1 From 60f7034ca1573e10cf9e005e2ef5a44e6b76ea9b Mon Sep 17 00:00:00 2001 | |
| 2 From: elbachir-one <[email protected]> | |
| 3 Date: Fri, 27 Sep 2024 12:35:36 +0100 | |
| 4 Subject: [PATCH] Added the missing keybinding | |
| 5 | |
| 6 --- | |
| 7 config.def.h | 1 + | |
| 8 dwm.c | 43 ++++++++++++++++++++++++++++++++++++++++--- | |
| 9 2 files changed, 41 insertions(+), 3 deletions(-) | |
| 10 | |
| 11 diff --git a/config.def.h b/config.def.h | |
| 12 index 9efa774..55c0a6c 100644 | |
| 13 --- a/config.def.h | |
| 14 +++ b/config.def.h | |
| 15 @@ -95,6 +95,7 @@ static const Key keys[] = { | |
| 16 TAGKEYS( XK_8, 7) | |
| 17 TAGKEYS( XK_9, 8) | |
| 18 { MODKEY|ShiftMask, XK_q, quit, {0} … | |
| 19 + { MODKEY, XK_s, togglesticky, {0} … | |
| 20 }; | |
| 21 | |
| 22 /* button definitions */ | |
| 23 diff --git a/dwm.c b/dwm.c | |
| 24 index 67c6b2b..e8ed755 100644 | |
| 25 --- a/dwm.c | |
| 26 +++ b/dwm.c | |
| 27 @@ -49,7 +49,7 @@ | |
| 28 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (Shif… | |
| 29 #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - … | |
| 30 * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - … | |
| 31 -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->selt… | |
| 32 +#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->selt… | |
| 33 #define LENGTH(X) (sizeof X / sizeof X[0]) | |
| 34 #define MOUSEMASK (BUTTONMASK|PointerMotionMask) | |
| 35 #define WIDTH(X) ((X)->w + 2 * (X)->bw) | |
| 36 @@ -61,7 +61,7 @@ | |
| 37 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | |
| 38 enum { SchemeNorm, SchemeSel }; /* color schemes */ | |
| 39 enum { NetSupported, NetWMName, NetWMState, NetWMCheck, | |
| 40 - NetWMFullscreen, NetActiveWindow, NetWMWindowType, | |
| 41 + NetWMFullscreen, NetWMSticky, NetActiveWindow, NetWMWindowType, | |
| 42 NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ | |
| 43 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* defaul… | |
| 44 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, | |
| 45 @@ -92,7 +92,7 @@ struct Client { | |
| 46 int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvali… | |
| 47 int bw, oldbw; | |
| 48 unsigned int tags; | |
| 49 - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfull… | |
| 50 + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfull… | |
| 51 Client *next; | |
| 52 Client *snext; | |
| 53 Monitor *mon; | |
| 54 @@ -200,6 +200,7 @@ static void sendmon(Client *c, Monitor *m); | |
| 55 static void setclientstate(Client *c, long state); | |
| 56 static void setfocus(Client *c); | |
| 57 static void setfullscreen(Client *c, int fullscreen); | |
| 58 +static void setsticky(Client *c, int sticky); | |
| 59 static void setlayout(const Arg *arg); | |
| 60 static void setmfact(const Arg *arg); | |
| 61 static void setup(void); | |
| 62 @@ -211,6 +212,7 @@ static void tagmon(const Arg *arg); | |
| 63 static void tile(Monitor *m); | |
| 64 static void togglebar(const Arg *arg); | |
| 65 static void togglefloating(const Arg *arg); | |
| 66 +static void togglesticky(const Arg *arg); | |
| 67 static void toggletag(const Arg *arg); | |
| 68 static void toggleview(const Arg *arg); | |
| 69 static void unfocus(Client *c, int setfocus); | |
| 70 @@ -525,6 +527,10 @@ clientmessage(XEvent *e) | |
| 71 || cme->data.l[2] == netatom[NetWMFullscreen]) | |
| 72 setfullscreen(c, (cme->data.l[0] == 1 /* _NET_W… | |
| 73 || (cme->data.l[0] == 2 /* _NET_WM_STAT… | |
| 74 + | |
| 75 + if (cme->data.l[1] == netatom[NetWMSticky] | |
| 76 + || cme->data.l[2] == netatom[NetWMSticky]) | |
| 77 + setsticky(c, (cme->data.l[0] == 1 || (cme->data.l[0] == 2 &… | |
| 78 } else if (cme->message_type == netatom[NetActiveWindow]) { | |
| 79 if (c != selmon->sel && !c->isurgent) | |
| 80 seturgent(c, 1); | |
| 81 @@ -1507,6 +1513,23 @@ setfullscreen(Client *c, int fullscreen) | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 +void | |
| 86 + setsticky(Client *c, int sticky) | |
| 87 + { | |
| 88 + | |
| 89 + if(sticky && !c->issticky) { | |
| 90 + XChangeProperty(dpy, c->win, netatom[NetWMStat… | |
| 91 + PropModeReplace, (unsigned cha… | |
| 92 + c->issticky = 1; | |
| 93 + } else if(!sticky && c->issticky){ | |
| 94 + XChangeProperty(dpy, c->win, netatom[NetWMStat… | |
| 95 + PropModeReplace, (unsigned cha… | |
| 96 + c->issticky = 0; | |
| 97 + arrange(c->mon); | |
| 98 + } | |
| 99 + } | |
| 100 + | |
| 101 + | |
| 102 void | |
| 103 setlayout(const Arg *arg) | |
| 104 { | |
| 105 @@ -1576,6 +1599,7 @@ setup(void) | |
| 106 netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); | |
| 107 netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHEC… | |
| 108 netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULL… | |
| 109 + netatom[NetWMSticky] = XInternAtom(dpy, "_NET_WM_STATE_STICKY",… | |
| 110 netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYP… | |
| 111 netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WIND… | |
| 112 netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", F… | |
| 113 @@ -1735,6 +1759,15 @@ togglefloating(const Arg *arg) | |
| 114 arrange(selmon); | |
| 115 } | |
| 116 | |
| 117 +void | |
| 118 +togglesticky(const Arg *arg) | |
| 119 +{ | |
| 120 + if (!selmon->sel) | |
| 121 + return; | |
| 122 + setsticky(selmon->sel, !selmon->sel->issticky); | |
| 123 + arrange(selmon); | |
| 124 +} | |
| 125 + | |
| 126 void | |
| 127 toggletag(const Arg *arg) | |
| 128 { | |
| 129 @@ -2027,6 +2060,9 @@ updatewindowtype(Client *c) | |
| 130 | |
| 131 if (state == netatom[NetWMFullscreen]) | |
| 132 setfullscreen(c, 1); | |
| 133 + if (state == netatom[NetWMSticky]) { | |
| 134 + setsticky(c, 1); | |
| 135 + } | |
| 136 if (wtype == netatom[NetWMWindowTypeDialog]) | |
| 137 c->isfloating = 1; | |
| 138 } | |
| 139 @@ -2163,3 +2199,4 @@ main(int argc, char *argv[]) | |
| 140 XCloseDisplay(dpy); | |
| 141 return EXIT_SUCCESS; | |
| 142 } | |
| 143 + | |
| 144 -- | |
| 145 2.46.0 | |
| 146 |