From ce12e0716380011a9d052a9cd40241fed24b3157 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 24 Jun 2020 16:36:51 +0200 Subject: [PATCH] Adding statusbutton patch ref. #33 --- README.md | 11 ++++++---- config.def.h | 10 +++++++++ dwm.c | 58 ++++++++++++++++++++++++++++++++++++++++++--------- patches.def.h | 5 +++++ 4 files changed, 70 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e16c2fa..a1c0367 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2020-06-24 - Added resizepoint patch +2020-06-24 - Added resizepoint and statusbutton patches 2020-06-21 - Added floatpos and bar_height patches @@ -394,15 +394,18 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [staticstatus](https://dwm.suckless.org/patches/staticstatus/) - allows the status text to be fixed to the bar on a specific monitor rather than being drawn on the focused monitor - - [statuscmd](https://dwm.suckless.org/patches/statuscmd/) - - adds the ability to execute shell commands based on the mouse button and position when clicking the status bar - - [status2d](https://dwm.suckless.org/patches/status2d/) - allows colors and rectangle drawing in the dwm status bar - [statusallmons](https://dwm.suckless.org/patches/statuspadding/) - this patch draws and updates the statusbar on all monitors + - [statusbutton](https://dwm.suckless.org/patches/statusbutton/) + - adds a clickable button to the left hand side of the statusbar + + - [statuscmd](https://dwm.suckless.org/patches/statuscmd/) + - adds the ability to execute shell commands based on the mouse button and position when clicking the status bar + - [statuscolors](https://dwm.suckless.org/patches/statuscolors/) - enables colored text in the status bar allowing multiple color combinations for use in the status script diff --git a/config.def.h b/config.def.h index 495864c..7fccd75 100644 --- a/config.def.h +++ b/config.def.h @@ -42,6 +42,9 @@ static const int vertpadbar = 0; /* vertical padding for statusba #if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH static const int statmonval = 0; #endif // STATICSTATUS_PATCH +#if STATUSBUTTON_PATCH +static const char buttonbar[] = ""; +#endif // STATUSBUTTON_PATCH #if SYSTRAY_PATCH static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayspacing = 2; /* systray spacing */ @@ -1134,9 +1137,16 @@ static Command commands[] = { #endif // KEYMODES_PATCH /* button definitions */ +#if STATUSBUTTON_PATCH +/* click can be ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +#else /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +#endif // static Button buttons[] = { /* click event mask button function argument */ + #if STATUSBUTTON_PATCH + { ClkButton, 0, Button1, spawn, {.v = dmenucmd } }, + #endif // STATUSBUTTON_PATCH { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, #if AWESOMEBAR_PATCH diff --git a/dwm.c b/dwm.c index 96aeedf..c41ba93 100644 --- a/dwm.c +++ b/dwm.c @@ -134,13 +134,29 @@ enum { NetClientList, NetLast }; /* EWMH atoms */ -#if WINDOWROLERULE_PATCH -enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMWindowRole, WMLast }; /* default atoms */ -#else -enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ -#endif // WINDOWROLERULE_PATCH -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ +enum { + WMProtocols, + WMDelete, + WMState, + WMTakeFocus, + #if WINDOWROLERULE_PATCH + WMWindowRole, + #endif // WINDOWROLERULE_PATCH + WMLast +}; /* default atoms */ + +enum { + #if STATUSBUTTON_PATCH + ClkButton, + #endif // STATUSBUTTON_PATCH + ClkTagBar, + ClkLtSymbol, + ClkStatusText, + ClkWinTitle, + ClkClientWin, + ClkRootWin, + ClkLast +}; /* clicks */ typedef union { int i; @@ -827,8 +843,17 @@ buttonpress(XEvent *e) x += blw; if (ev->x < x) { click = ClkLtSymbol; + #if STATUSBUTTON_PATCH + } else if (ev->x < (x += TEXTW(buttonbar))) { + click = ClkButton; + #endif // STATUSBUTTON_PATCH } else { - #endif // LEFTLAYOUT_PATCH + #elif STATUSBUTTON_PATCH + x += TEXTW(buttonbar); + if (ev->x < x) { + click = ClkButton; + } else { + #endif // LEFTLAYOUT_PATCH | STATUSBUTTON_PATCH #if HIDEVACANTTAGS_PATCH for (c = m->clients; c; c = c->next) occ |= c->tags == 255 ? 0 : c->tags; @@ -938,9 +963,9 @@ buttonpress(XEvent *e) else click = ClkWinTitle; #endif // AWESOMEBAR_PATCH - #if LEFTLAYOUT_PATCH + #if LEFTLAYOUT_PATCH || STATUSBUTTON_PATCH } - #endif // LEFTLAYOUT_PATCH + #endif // LEFTLAYOUT_PATCH | STATUSBUTTON_PATCH } else if ((c = wintoclient(ev->window))) { #if FOCUSONCLICK_PATCH if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) @@ -1594,6 +1619,19 @@ drawbar(Monitor *m) x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); #endif // PANGO_PATCH #endif // LEFTLAYOUT_PATCH + #if STATUSBUTTON_PATCH + w = TEXTW(buttonbar); + #if VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTagsNorm]); + #else + drw_setscheme(drw, scheme[SchemeNorm]); + #endif // VTCOLORS_PATCH + #if PANGO_PATCH + x = drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0, False); + #else + x = drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0); + #endif // PANGO_PATCH + #endif // STATUSBUTTON_PATCH #if TAGGRID_PATCH if (drawtagmask & DRAWCLASSICTAGS) #endif // TAGGRID_PATCH diff --git a/patches.def.h b/patches.def.h index eb354c7..2a54939 100644 --- a/patches.def.h +++ b/patches.def.h @@ -588,6 +588,11 @@ */ #define STATUSALLMONS_PATCH 0 +/* This patch adds a clickable button to the left hand side of the statusbar. + * https://dwm.suckless.org/patches/statusbutton/ + */ +#define STATUSBUTTON_PATCH 0 + /* This patch enables colored text in the status bar. It changes the way colors are defined * in config.h allowing multiple color combinations for use in the status script. * This patch is incompatible with and takes precedence over the status2d patch.