From 54297429dcf490511076ebc738c9688e113c7731 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 20 Jul 2020 11:48:07 +0200 Subject: [PATCH 2/2] Adding statusbutton module --- config.def.h | 5 ++++- dwm.c | 2 +- patch/bar_statusbutton.c | 21 +++++++++++++++++++++ patch/bar_statusbutton.h | 3 +++ patch/include.c | 3 ++- patch/include.h | 3 ++- 6 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 patch/bar_statusbutton.c create mode 100644 patch/bar_statusbutton.h diff --git a/config.def.h b/config.def.h index 2534eac..b70c552 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ +static const char buttonbar[] = ""; static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; @@ -45,6 +46,7 @@ static const Rule rules[] = { */ static const BarRule barrules[] = { /* monitor bar alignment widthfunc drawfunc clickfunc name */ + { -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, "statusbutton" }, { -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" }, { -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" }, { 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" }, @@ -117,9 +119,10 @@ static Key keys[] = { }; /* button definitions */ -/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +/* click can be ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { /* click event mask button function argument */ + { ClkButton, 0, Button1, spawn, {.v = dmenucmd } }, { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkWinTitle, 0, Button2, zoom, {0} }, diff --git a/dwm.c b/dwm.c index 03dccfb..048221b 100644 --- a/dwm.c +++ b/dwm.c @@ -65,7 +65,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, +enum { ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ enum { BAR_ALIGN_LEFT, diff --git a/patch/bar_statusbutton.c b/patch/bar_statusbutton.c new file mode 100644 index 0000000..f5c9c9d --- /dev/null +++ b/patch/bar_statusbutton.c @@ -0,0 +1,21 @@ +int +width_stbutton(Bar *bar, BarWidthArg *a) +{ + return TEXTW(buttonbar); +} + +int +draw_stbutton(Bar *bar, BarDrawArg *a) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0, False); + #else + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0); + #endif // BAR_PANGO_PATCH +} + +int +click_stbutton(Bar *bar, Arg *arg, BarClickArg *a) +{ + return ClkButton; +} diff --git a/patch/bar_statusbutton.h b/patch/bar_statusbutton.h new file mode 100644 index 0000000..8e9d6fe --- /dev/null +++ b/patch/bar_statusbutton.h @@ -0,0 +1,3 @@ +static int width_stbutton(Bar *bar, BarWidthArg *a); +static int draw_stbutton(Bar *bar, BarDrawArg *a); +static int click_stbutton(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index d422f56..b731f2e 100644 --- a/patch/include.c +++ b/patch/include.c @@ -2,4 +2,5 @@ #include "bar_ltsymbol.c" #include "bar_status.c" #include "bar_tags.c" -#include "bar_wintitle.c" \ No newline at end of file +#include "bar_wintitle.c" +#include "bar_statusbutton.c" \ No newline at end of file diff --git a/patch/include.h b/patch/include.h index 5f9a3fe..c2a1127 100644 --- a/patch/include.h +++ b/patch/include.h @@ -2,4 +2,5 @@ #include "bar_ltsymbol.h" #include "bar_status.h" #include "bar_tags.h" -#include "bar_wintitle.h" \ No newline at end of file +#include "bar_wintitle.h" +#include "bar_statusbutton.h" \ No newline at end of file -- 2.19.1