From 903b32ac8b4a69b37981874f23b15a9f65f2a20d Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 08:57:30 +0200 Subject: Major refactoring in preparation for bar modules --- README.md | 2 +- config.def.h | 182 ++-- config.mk | 4 +- drw.c | 84 +- drw.h | 46 +- dwm.c | 1461 ++++++++++----------------------- patch/alpha.c | 42 - patch/alpha.h | 3 - patch/alternativetags.c | 6 - patch/alternativetags.h | 1 - patch/awesomebar.c | 67 -- patch/awesomebar.h | 4 - patch/bar_alpha.c | 42 + patch/bar_alpha.h | 3 + patch/bar_alternativetags.c | 6 + patch/bar_alternativetags.h | 1 + patch/bar_awesomebar.c | 146 ++++ patch/bar_awesomebar.h | 8 + patch/bar_dwmblocks.c | 31 + patch/bar_dwmblocks.h | 2 + patch/bar_fancybar.c | 97 +++ patch/bar_fancybar.h | 3 + patch/bar_ltsymbol.c | 21 + patch/bar_ltsymbol.h | 3 + patch/bar_status.c | 25 + patch/bar_status.h | 3 + patch/bar_status2d.c | 182 ++++ patch/bar_status2d.h | 5 + patch/bar_status2d_eb.c | 11 + patch/bar_status2d_eb.h | 2 + patch/bar_statusbutton.c | 21 + patch/bar_statusbutton.h | 3 + patch/bar_statuscmd.c | 76 ++ patch/bar_statuscmd.h | 6 + patch/bar_systray.c | 194 +++++ patch/bar_systray.h | 41 + patch/bar_taggrid.c | 142 ++++ patch/bar_taggrid.h | 4 + patch/bar_tags.c | 123 +++ patch/bar_tags.h | 3 + patch/bar_wintitle.c | 89 ++ patch/bar_wintitle.h | 3 + patch/bstack.c | 74 -- patch/bstack.h | 1 - patch/bstackhoriz.c | 76 -- patch/bstackhoriz.h | 1 - patch/centeredfloatingmaster.c | 94 --- patch/centeredfloatingmaster.h | 1 - patch/centeredmaster.c | 159 ---- patch/centeredmaster.h | 1 - patch/columns.c | 73 -- patch/columns.h | 1 - patch/combo.c | 4 +- patch/combo.h | 4 +- patch/deck.c | 66 -- patch/deck.h | 1 - patch/dwmblocks.c | 31 - patch/dwmblocks.h | 2 - patch/fibonacci.c | 190 ----- patch/fibonacci.h | 7 - patch/flextile-deluxe.c | 770 ----------------- patch/flextile-deluxe.h | 117 --- patch/gapplessgrid.c | 98 --- patch/gapplessgrid.h | 1 - patch/grid.c | 60 -- patch/grid.h | 1 - patch/holdbar.c | 34 +- patch/horizgrid.c | 103 --- patch/horizgrid.h | 1 - patch/include.c | 106 ++- patch/include.h | 104 ++- patch/killunsel.c | 4 +- patch/layout_bstack.c | 74 ++ patch/layout_bstack.h | 1 + patch/layout_bstackhoriz.c | 76 ++ patch/layout_bstackhoriz.h | 1 + patch/layout_centeredfloatingmaster.c | 94 +++ patch/layout_centeredfloatingmaster.h | 1 + patch/layout_centeredmaster.c | 159 ++++ patch/layout_centeredmaster.h | 1 + patch/layout_columns.c | 73 ++ patch/layout_columns.h | 1 + patch/layout_deck.c | 66 ++ patch/layout_deck.h | 1 + patch/layout_fibonacci.c | 190 +++++ patch/layout_fibonacci.h | 7 + patch/layout_flextile-deluxe.c | 770 +++++++++++++++++ patch/layout_flextile-deluxe.h | 117 +++ patch/layout_gapplessgrid.c | 98 +++ patch/layout_gapplessgrid.h | 1 + patch/layout_grid.c | 60 ++ patch/layout_grid.h | 1 + patch/layout_horizgrid.c | 103 +++ patch/layout_horizgrid.h | 1 + patch/layout_monocle.c | 37 + patch/layout_monocle.h | 1 + patch/layout_nrowgrid.c | 103 +++ patch/layout_nrowgrid.h | 1 + patch/layout_tile.c | 73 ++ patch/layout_tile.h | 1 + patch/monocle.c | 37 - patch/monocle.h | 1 - patch/nrowgrid.c | 103 --- patch/nrowgrid.h | 1 - patch/status2d.c | 209 ----- patch/status2d.h | 2 - patch/statuscolors.c | 4 +- patch/systray.c | 206 ----- patch/systray.h | 37 - patch/tile.c | 73 -- patch/tile.h | 1 - patch/xrdb.c | 14 +- patches.def.h | 448 +++++----- 113 files changed, 4382 insertions(+), 4249 deletions(-) delete mode 100644 patch/alpha.c delete mode 100644 patch/alpha.h delete mode 100644 patch/alternativetags.c delete mode 100644 patch/alternativetags.h delete mode 100644 patch/awesomebar.c delete mode 100644 patch/awesomebar.h create mode 100644 patch/bar_alpha.c create mode 100644 patch/bar_alpha.h create mode 100644 patch/bar_alternativetags.c create mode 100644 patch/bar_alternativetags.h create mode 100644 patch/bar_awesomebar.c create mode 100644 patch/bar_awesomebar.h create mode 100644 patch/bar_dwmblocks.c create mode 100644 patch/bar_dwmblocks.h create mode 100644 patch/bar_fancybar.c create mode 100644 patch/bar_fancybar.h create mode 100644 patch/bar_ltsymbol.c create mode 100644 patch/bar_ltsymbol.h create mode 100644 patch/bar_status.c create mode 100644 patch/bar_status.h create mode 100644 patch/bar_status2d.c create mode 100644 patch/bar_status2d.h create mode 100644 patch/bar_status2d_eb.c create mode 100644 patch/bar_status2d_eb.h create mode 100644 patch/bar_statusbutton.c create mode 100644 patch/bar_statusbutton.h create mode 100644 patch/bar_statuscmd.c create mode 100644 patch/bar_statuscmd.h create mode 100644 patch/bar_systray.c create mode 100644 patch/bar_systray.h create mode 100644 patch/bar_taggrid.c create mode 100644 patch/bar_taggrid.h create mode 100644 patch/bar_tags.c create mode 100644 patch/bar_tags.h create mode 100644 patch/bar_wintitle.c create mode 100644 patch/bar_wintitle.h delete mode 100644 patch/bstack.c delete mode 100644 patch/bstack.h delete mode 100644 patch/bstackhoriz.c delete mode 100644 patch/bstackhoriz.h delete mode 100644 patch/centeredfloatingmaster.c delete mode 100644 patch/centeredfloatingmaster.h delete mode 100644 patch/centeredmaster.c delete mode 100644 patch/centeredmaster.h delete mode 100644 patch/columns.c delete mode 100644 patch/columns.h delete mode 100644 patch/deck.c delete mode 100644 patch/deck.h delete mode 100644 patch/dwmblocks.c delete mode 100644 patch/dwmblocks.h delete mode 100644 patch/fibonacci.c delete mode 100644 patch/fibonacci.h delete mode 100644 patch/flextile-deluxe.c delete mode 100644 patch/flextile-deluxe.h delete mode 100644 patch/gapplessgrid.c delete mode 100644 patch/gapplessgrid.h delete mode 100644 patch/grid.c delete mode 100644 patch/grid.h delete mode 100644 patch/horizgrid.c delete mode 100644 patch/horizgrid.h create mode 100644 patch/layout_bstack.c create mode 100644 patch/layout_bstack.h create mode 100644 patch/layout_bstackhoriz.c create mode 100644 patch/layout_bstackhoriz.h create mode 100644 patch/layout_centeredfloatingmaster.c create mode 100644 patch/layout_centeredfloatingmaster.h create mode 100644 patch/layout_centeredmaster.c create mode 100644 patch/layout_centeredmaster.h create mode 100644 patch/layout_columns.c create mode 100644 patch/layout_columns.h create mode 100644 patch/layout_deck.c create mode 100644 patch/layout_deck.h create mode 100644 patch/layout_fibonacci.c create mode 100644 patch/layout_fibonacci.h create mode 100644 patch/layout_flextile-deluxe.c create mode 100644 patch/layout_flextile-deluxe.h create mode 100644 patch/layout_gapplessgrid.c create mode 100644 patch/layout_gapplessgrid.h create mode 100644 patch/layout_grid.c create mode 100644 patch/layout_grid.h create mode 100644 patch/layout_horizgrid.c create mode 100644 patch/layout_horizgrid.h create mode 100644 patch/layout_monocle.c create mode 100644 patch/layout_monocle.h create mode 100644 patch/layout_nrowgrid.c create mode 100644 patch/layout_nrowgrid.h create mode 100644 patch/layout_tile.c create mode 100644 patch/layout_tile.h delete mode 100644 patch/monocle.c delete mode 100644 patch/monocle.h delete mode 100644 patch/nrowgrid.c delete mode 100644 patch/nrowgrid.h delete mode 100644 patch/status2d.c delete mode 100644 patch/status2d.h delete mode 100644 patch/systray.c delete mode 100644 patch/systray.h delete mode 100644 patch/tile.c delete mode 100644 patch/tile.h diff --git a/README.md b/README.md index c2dd33f..f1e32c2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This dwm 6.2 (aaad5f, 2020-07-08) side project has a different take on dwm patch For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h): ```c -#define ALPHA_PATCH 1 +#define BAR_ALPHA_PATCH 1 ``` So if you have ever been curious about trying out dwm, but have been discouraged by manual patching, then this may be a good starting point to see what a "fully fledged" dwm can look like. Want to try out the `pertag` patch? Just flip a config and recompile. Once you have found out what works for you and what doesn't then you should be in a better position to choose patches should you want to start patching from scratch. diff --git a/config.def.h b/config.def.h index 190ab12..7e91c43 100644 --- a/config.def.h +++ b/config.def.h @@ -15,19 +15,19 @@ static const unsigned int gappoh = 10; /* horiz outer gap between windo static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ #endif // VANITYGAPS_PATCH -#if HOLDBAR_PATCH +#if BAR_HOLDBAR_PATCH static const int showbar = 0; /* 0 means no bar */ #else static const int showbar = 1; /* 0 means no bar */ -#endif // HOLDBAR_PATCH +#endif // BAR_HOLDBAR_PATCH static const int topbar = 1; /* 0 means bottom bar */ #if BAR_HEIGHT_PATCH static const int bar_height = 0; /* 0 means derive from font, >= 1 explicit height */ #endif // BAR_HEIGHT_PATCH -#if BARPADDING_PATCH +#if BAR_PADDING_PATCH static const int vertpad = 10; /* vertical padding of bar */ static const int sidepad = 10; /* horizontal padding of bar */ -#endif // BARPADDING_PATCH +#endif // BAR_PADDING_PATCH #if FOCUSONCLICK_PATCH static const int focusonwheel = 0; #endif // FOCUSONCLICK_PATCH @@ -35,73 +35,71 @@ static const int focusonwheel = 0; static int floatposgrid_x = 5; /* float grid columns */ static int floatposgrid_y = 5; /* float grid rows */ #endif // FLOATPOS_PATCH -#if STATUSPADDING_PATCH +#if BAR_STATUSPADDING_PATCH static const int horizpadbar = 2; /* horizontal padding for statusbar */ static const int vertpadbar = 0; /* vertical padding for statusbar */ -#endif // STATUSPADDING_PATCH -#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH +#endif // BAR_STATUSPADDING_PATCH +#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH static const int statmonval = 0; -#endif // STATICSTATUS_PATCH +#endif // BAR_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 */ -static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ static const int showsystray = 1; /* 0 means no systray */ #endif // SYSTRAY_PATCH #if ONLYQUITONEMPTY_PATCH static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */ #endif // ONLYQUITONEMPTY_PATCH -#if EXTRABAR_PATCH +#if BAR_EXTRABAR_PATCH static const char statussep = ';'; /* separator between status bars */ static const int ebalign = 0; /* extrabar alignment: 0 - left, 1 - right, 2 - center */ -#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH +#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH static const int statebmonval = statmonval; -#endif // STATICSTATUS_PATCH -#endif // EXTRABAR_PATCH -#if PANGO_PATCH +#endif // BAR_STATICSTATUS_PATCH +#endif // BAR_EXTRABAR_PATCH +#if BAR_PANGO_PATCH static const char font[] = "monospace 10"; #else static const char *fonts[] = { "monospace:size=10" }; -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH static const char dmenufont[] = "monospace:size=10"; static char normfgcolor[] = "#bbbbbb"; static char normbgcolor[] = "#222222"; -#if !VTCOLORS_PATCH +#if !BAR_VTCOLORS_PATCH static char normbordercolor[] = "#444444"; #if FLOAT_BORDER_COLOR_PATCH static char normfloatcolor[] = "#db8fd9"; #endif // FLOAT_BORDER_COLOR_PATCH -#endif // !VTCOLORS_PATCH +#endif // !BAR_VTCOLORS_PATCH static char selfgcolor[] = "#eeeeee"; static char selbgcolor[] = "#005577"; -#if !VTCOLORS_PATCH +#if !BAR_VTCOLORS_PATCH static char selbordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH static char selfloatcolor[] = "#005577"; #endif // FLOAT_BORDER_COLOR_PATCH -#if STATUSCOLORS_PATCH +#if BAR_STATUSCOLORS_PATCH static char warnfgcolor[] = "#000000"; static char warnbgcolor[] = "#ffff00"; static char warnbordercolor[] = "#ff0000"; #if FLOAT_BORDER_COLOR_PATCH static char warnfloatcolor[] = "#ffffff"; #endif // FLOAT_BORDER_COLOR_PATCH -#endif // STATUSCOLORS_PATCH +#endif // BAR_STATUSCOLORS_PATCH -#if URGENTBORDER_PATCH || STATUSCOLORS_PATCH +#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH static char urgfgcolor[] = "#000000"; static char urgbgcolor[] = "#000000"; static char urgbordercolor[] = "#ff0000"; // NB: patch only works with border color for now #if FLOAT_BORDER_COLOR_PATCH static char urgfloatcolor[] = "#000000"; #endif // FLOAT_BORDER_COLOR_PATCH -#endif // URGENTBORDER_PATCH // STATUSCOLORS_PATCH +#endif // URGENTBORDER_PATCH // BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH static char hidfgcolor[] = "#005577"; @@ -112,56 +110,56 @@ static char hidfloatcolor[] = "#f76e0c"; #endif // FLOAT_BORDER_COLOR_PATCH #endif // AWESOMEBAR_PATCH -#if TITLECOLOR_PATCH +#if BAR_TITLECOLOR_PATCH static char titlefgcolor[] = "#eeeeee"; static char titlebgcolor[] = "#005577"; static char titlebordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH static char titlefloatcolor[] = "#005577"; #endif // FLOAT_BORDER_COLOR_PATCH -#endif // TITLECOLOR_PATCH -#endif // VTCOLORS_PATCH +#endif // BAR_TITLECOLOR_PATCH +#endif // BAR_VTCOLORS_PATCH -#if ALPHA_PATCH +#if BAR_ALPHA_PATCH static const unsigned int baralpha = 0xd0; static const unsigned int borderalpha = OPAQUE; static const unsigned int alphas[][3] = { /* fg bg border */ [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, [SchemeSel] = { OPAQUE, baralpha, borderalpha }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { OPAQUE, baralpha, borderalpha }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { OPAQUE, baralpha, borderalpha }, - #endif // URGENTBORDER_PATCH / STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { OPAQUE, baralpha, borderalpha }, #endif // AWESOMEBAR_PATCH - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH [SchemeTagsNorm] = { OPAQUE, baralpha, borderalpha }, [SchemeTagsSel] = { OPAQUE, baralpha, borderalpha }, [SchemeTitleNorm] = { OPAQUE, baralpha, borderalpha }, [SchemeTitleSel] = { OPAQUE, baralpha, borderalpha }, [SchemeStatus] = { OPAQUE, baralpha, borderalpha }, - #elif TITLECOLOR_PATCH + #elif BAR_TITLECOLOR_PATCH [SchemeTitle] = { OPAQUE, baralpha, borderalpha }, - #endif // VTCOLORS_PATCH / TITLECOLOR_PATCH + #endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH }; -#endif // ALPHA_PATCH -#if VTCOLORS_PATCH && FLOAT_BORDER_COLOR_PATCH +#endif // BAR_ALPHA_PATCH +#if BAR_VTCOLORS_PATCH && FLOAT_BORDER_COLOR_PATCH static const char title_bg_dark[] = "#303030"; static const char title_bg_light[] = "#fdfdfd"; static const int color_ptrs[][ColCount] = { /* fg bg border float */ [SchemeNorm] = { -1, -1, 5, 12 }, [SchemeSel] = { -1, -1, 11, 13 }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { -1, 1, 1, 14 }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { 7, 9, 9, 15 }, - #endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { 5, 0, 0, -1 }, #endif // AWESOMEBAR_PATCH @@ -175,12 +173,12 @@ static char colors[][ColCount][8] = { /* fg bg border float */ [SchemeNorm] = { "#000000", "#000000", "#000000", "#000000" }, [SchemeSel] = { "#000000", "#000000", "#000000", "#000000" }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { "#000000", "#000000", "#000000", "#000000" }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { "#000000", "#000000", "#000000", "#000000" }, - #endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { "#000000", "#000000", "#000000", "#000000" }, #endif // AWESOMEBAR_PATCH @@ -190,19 +188,19 @@ static char colors[][ColCount][8] = { [SchemeTitleSel] = { "#000000", "#000000", "#000000", "#000000" }, [SchemeStatus] = { "#000000", "#000000", "#000000", "#000000" }, }; -#elif VTCOLORS_PATCH +#elif BAR_VTCOLORS_PATCH static const char title_bg_dark[] = "#303030"; static const char title_bg_light[] = "#fdfdfd"; static const int color_ptrs[][ColCount] = { /* fg bg border */ [SchemeNorm] = { -1, -1, 5 }, [SchemeSel] = { -1, -1, 11 }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { -1, 1, 1 }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { 7, 9, 9 }, - #endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { 5, 0, 0 }, #endif // AWESOMEBAR_PATCH @@ -216,12 +214,12 @@ static char colors[][ColCount][8] = { /* fg bg border */ [SchemeNorm] = { "#000000", "#000000", "#000000" }, [SchemeSel] = { "#000000", "#000000", "#000000" }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { "#000000", "#000000", "#000000" }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { "#000000", "#000000", "#000000" }, - #endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { "#000000", "#000000", "#000000" }, #endif // AWESOMEBAR_PATCH @@ -240,20 +238,20 @@ char *colors[][ColCount] = { /* fg bg border float */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor, normfloatcolor }, [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor, selfloatcolor }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { warnfgcolor, warnbgcolor, warnbordercolor, warnfloatcolor }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor, urgfloatcolor }, - #endif // URGENTBORDER_PATCH / STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidfloatcolor }, #endif // AWESOMEBAR_PATCH - #if TITLECOLOR_PATCH + #if BAR_TITLECOLOR_PATCH [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titlefloatcolor }, - #endif // TITLECOLOR_PATCH + #endif // BAR_TITLECOLOR_PATCH }; -#else // !VTCOLORS_PATCH && !FLOAT_BORDER_COLOR_PATCH +#else // !BAR_VTCOLORS_PATCH && !FLOAT_BORDER_COLOR_PATCH static #if !XRDB_PATCH const @@ -262,20 +260,20 @@ char *colors[][ColCount] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH [SchemeWarn] = { warnfgcolor, warnbgcolor, warnbordercolor }, - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor }, - #endif // URGENTBORDER_PATCH / STATUSCOLORS_PATCH + #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH #if AWESOMEBAR_PATCH [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor }, #endif // AWESOMEBAR_PATCH - #if TITLECOLOR_PATCH + #if BAR_TITLECOLOR_PATCH [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor }, - #endif // TITLECOLOR_PATCH + #endif // BAR_TITLECOLOR_PATCH }; -#endif // VTCOLORS_PATCH / FLOAT_BORDER_COLOR_PATCH +#endif // BAR_VTCOLORS_PATCH / FLOAT_BORDER_COLOR_PATCH #if SCRATCHPADS_PATCH const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL }; @@ -290,14 +288,14 @@ static Sp scratchpads[] = { #endif // SCRATCHPADS_PATCH /* tagging */ -#if EWMHTAGS_PATCH +#if BAR_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 +#endif // BAR_EWMHTAGS_PATCH +#if BAR_ALTERNATIVE_TAGS_PATCH static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; -#endif // ALTERNATIVE_TAGS_PATCH +#endif // BAR_ALTERNATIVE_TAGS_PATCH #if TAGGRID_PATCH /* grid of tags */ @@ -495,9 +493,9 @@ static Signal signals[] = { #if TAGSWAPMON_PATCH { "tagswapmon", tagswapmon}, #endif // TAGSWAPMON_PATCH - #if ALTERNATIVE_TAGS_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH { "togglealttag", togglealttag }, - #endif // ALTERNATIVE_TAGS_PATCH + #endif // BAR_ALTERNATIVE_TAGS_PATCH #if TOGGLEFULLSCREEN_PATCH { "togglefullscreen", togglefullscreen }, #endif // TOGGLEFULLSCREEN_PATCH @@ -522,7 +520,7 @@ static Signal signals[] = { #if WINVIEW_PATCH { "winview", winview }, #endif // WINVIEW_PATCH - #if XRDB_PATCH && !VTCOLORS_PATCH + #if XRDB_PATCH && !BAR_VTCOLORS_PATCH { "xrdb", xrdb }, #endif // XRDB_PATCH #if TAGOTHERMONITOR_PATCH @@ -746,9 +744,9 @@ static const Layout layouts[] = { { MOD, XK_z, ACTION##stack, {.i = -1 } }, #endif // STACKER_PATCH -#if HOLDBAR_PATCH +#if BAR_HOLDBAR_PATCH #define HOLDKEY 0 // replace 0 with the keysym to activate holdbar -#endif // HOLDBAR_PATCH +#endif // BAR_HOLDBAR_PATCH /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -767,18 +765,18 @@ static const char *dmenucmd[] = { "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, - #if DMENUMATCHTOP_PATCH + #if BAR_DMENUMATCHTOP_PATCH topbar ? NULL : "-b", - #endif // DMENUMATCHTOP_PATCH + #endif // BAR_DMENUMATCHTOP_PATCH NULL }; static const char *termcmd[] = { "st", NULL }; -#if STATUSCMD_PATCH && !DWMBLOCKS_PATCH +#if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH /* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */ static const char *statuscmds[] = { "notify-send Mouse$BUTTON" }; static char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL }; -#endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH +#endif // BAR_STATUSCMD_PATCH | DWMBLOCKS_PATCH static Key keys[] = { /* modifier key function argument */ @@ -891,13 +889,13 @@ static Key keys[] = { #if FOCUSURGENT_PATCH { MODKEY, XK_u, focusurgent, {0} }, #endif // FOCUSURGENT_PATCH - #if HOLDBAR_PATCH + #if BAR_HOLDBAR_PATCH { 0, HOLDKEY, holdbar, {0} }, - #endif // HOLDBAR_PATCH + #endif // BAR_HOLDBAR_PATCH #if WINVIEW_PATCH { MODKEY, XK_o, winview, {0} }, #endif // WINVIEW_PATCH - #if XRDB_PATCH && !VTCOLORS_PATCH + #if XRDB_PATCH && !BAR_VTCOLORS_PATCH { MODKEY|ShiftMask, XK_F5, xrdb, {.v = NULL } }, #endif // XRDB_PATCH { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, @@ -995,9 +993,9 @@ static Key keys[] = { { MODKEY|Mod4Mask|ControlMask, XK_comma, tagswapmon, {.i = +1 } }, { MODKEY|Mod4Mask|ControlMask, XK_period, tagswapmon, {.i = -1 } }, #endif // TAGSWAPMON_PATCH - #if ALTERNATIVE_TAGS_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH { MODKEY, XK_n, togglealttag, {0} }, - #endif // ALTERNATIVE_TAGS_PATCH + #endif // BAR_ALTERNATIVE_TAGS_PATCH #if TAGGRID_PATCH { MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } }, { MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } }, @@ -1148,27 +1146,27 @@ static Command commands[] = { #endif // static Button buttons[] = { /* click event mask button function argument */ - #if STATUSBUTTON_PATCH + #if BAR_STATUSBUTTON_PATCH { ClkButton, 0, Button1, spawn, {.v = dmenucmd } }, - #endif // STATUSBUTTON_PATCH + #endif // BAR_STATUSBUTTON_PATCH { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH { ClkWinTitle, 0, Button1, togglewin, {0} }, { ClkWinTitle, 0, Button3, showhideclient, {0} }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH { ClkWinTitle, 0, Button2, zoom, {0} }, - #if STATUSCMD_PATCH && DWMBLOCKS_PATCH + #if BAR_STATUSCMD_PATCH && BAR_DWMBLOCKS_PATCH { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } }, { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2 } }, { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3 } }, - #elif STATUSCMD_PATCH + #elif BAR_STATUSCMD_PATCH { ClkStatusText, 0, Button1, spawn, {.v = statuscmd } }, { ClkStatusText, 0, Button2, spawn, {.v = statuscmd } }, { ClkStatusText, 0, Button3, spawn, {.v = statuscmd } }, #else { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - #endif // STATUSCMD_PATCH + #endif // BAR_STATUSCMD_PATCH { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, diff --git a/config.mk b/config.mk index 49e5263..e92e380 100644 --- a/config.mk +++ b/config.mk @@ -20,13 +20,13 @@ FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) #FREETYPEINC = ${X11INC}/freetype2 -# Uncomment this for the alpha patch / ALPHA_PATCH +# Uncomment this for the alpha patch / BAR_ALPHA_PATCH #XRENDER = -lXrender # Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH #MPDCLIENT = -lmpdclient -# Uncomment for the pango patch / PANGO_PATCH +# Uncomment for the pango patch / BAR_PANGO_PATCH #PANGOINC = `pkg-config --cflags xft pango pangoxft` #PANGOLIB = `pkg-config --libs xft pango pangoxft` diff --git a/drw.c b/drw.c index bfc66be..99dc6da 100644 --- a/drw.c +++ b/drw.c @@ -61,14 +61,14 @@ utf8decode(const char *c, long *u, size_t clen) return len; } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH Drw * -#if ALPHA_PATCH +#if BAR_ALPHA_PATCH drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) #else drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) -#endif // ALPHA_PATCH +#endif // BAR_ALPHA_PATCH { Drw *drw = ecalloc(1, sizeof(Drw)); @@ -78,7 +78,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h drw->w = w; drw->h = h; - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH drw->visual = visual; drw->depth = depth; drw->cmap = cmap; @@ -87,7 +87,7 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h #else drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); drw->gc = XCreateGC(dpy, root, 0, NULL); - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); return drw; @@ -103,11 +103,11 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) drw->h = h; if (drw->drawable) XFreePixmap(drw->dpy, drw->drawable); - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); #else drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH } void @@ -115,15 +115,15 @@ drw_free(Drw *drw) { XFreePixmap(drw->dpy, drw->drawable); XFreeGC(drw->dpy, drw->gc); - #if PANGO_PATCH + #if BAR_PANGO_PATCH drw_font_free(drw->font); #else drw_fontset_free(drw->fonts); - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH free(drw); } -#if PANGO_PATCH +#if BAR_PANGO_PATCH /* This function is an implementation detail. Library users should use * drw_font_create instead. */ @@ -192,7 +192,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) die("no font specified."); } - #if !COLOR_EMOJI_PATCH + #if !BAR_COLOR_EMOJI_PATCH /* Do not allow using color fonts. This is a workaround for a BadLength * error from Xft with color glyphs. Modelled on the Xterm workaround. See * https://bugzilla.redhat.com/show_bug.cgi?id=1498269 @@ -205,7 +205,7 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) XftFontClose(drw->dpy, xfont); return NULL; } - #endif // COLOR_EMOJI_PATCH + #endif // BAR_COLOR_EMOJI_PATCH font = ecalloc(1, sizeof(Fnt)); font->xfont = xfont; @@ -215,25 +215,25 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) return font; } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH static void xfont_free(Fnt *font) { if (!font) return; - #if PANGO_PATCH + #if BAR_PANGO_PATCH if (font->layout) g_object_unref(font->layout); #else if (font->pattern) FcPatternDestroy(font->pattern); XftFontClose(font->dpy, font->xfont); - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH free(font); } -#if PANGO_PATCH +#if BAR_PANGO_PATCH Fnt* drw_font_create(Drw* drw, const char font[]) { @@ -264,9 +264,9 @@ drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount) } return (drw->fonts = ret); } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH -#if PANGO_PATCH +#if BAR_PANGO_PATCH void drw_font_free(Fnt *font) { @@ -282,25 +282,25 @@ drw_fontset_free(Fnt *font) xfont_free(font); } } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH void drw_clr_create( Drw *drw, Clr *dest, - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH const char clrname[] #else const char *clrname - #endif // VTCOLORS_PATCH - #if ALPHA_PATCH + #endif // BAR_VTCOLORS_PATCH + #if BAR_ALPHA_PATCH , unsigned int alpha - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH ) { if (!drw || !dest || !clrname) return; - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, clrname, dest)) die("error, cannot allocate color '%s'", clrname); @@ -315,7 +315,7 @@ drw_clr_create( #if NO_TRANSPARENT_BORDERS_PATCH dest->pixel |= 0xff << 24; #endif // NO_TRANSPARENT_BORDERS_PATCH - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH } /* Wrapper to create color schemes. The caller has to call free(3) on the @@ -323,16 +323,16 @@ drw_clr_create( Clr * drw_scm_create( Drw *drw, - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH char clrnames[][8], #elif XRDB_PATCH char *clrnames[], #else const char *clrnames[], - #endif // VTCOLORS_PATCH / XRDB_PATCH - #if ALPHA_PATCH + #endif // BAR_VTCOLORS_PATCH / XRDB_PATCH + #if BAR_ALPHA_PATCH const unsigned int alphas[], - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH size_t clrcount ) { size_t i; @@ -343,11 +343,11 @@ drw_scm_create( return NULL; for (i = 0; i < clrcount; i++) - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); #else drw_clr_create(drw, &ret[i], clrnames[i]); - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH return ret; } @@ -358,7 +358,7 @@ drw_setfontset(Drw *drw, Fnt *set) if (drw) drw->fonts = set; } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH void drw_setscheme(Drw *drw, Clr *scm) @@ -379,7 +379,7 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); } -#if PANGO_PATCH +#if BAR_PANGO_PATCH int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup) { @@ -398,13 +398,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); #else d = XftDrawCreate(drw->dpy, drw->drawable, DefaultVisual(drw->dpy, drw->screen), DefaultColormap(drw->dpy, drw->screen)); - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH x += lpad; w -= lpad; } @@ -471,13 +471,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); #else d = XftDrawCreate(drw->dpy, drw->drawable, DefaultVisual(drw->dpy, drw->screen), DefaultColormap(drw->dpy, drw->screen)); - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH x += lpad; w -= lpad; } @@ -579,7 +579,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp return x + (render ? w : 0); } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) @@ -591,7 +591,7 @@ drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) XSync(drw->dpy, False); } -#if PANGO_PATCH +#if BAR_PANGO_PATCH unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) { @@ -607,9 +607,9 @@ drw_fontset_getwidth(Drw *drw, const char *text) return 0; return drw_text(drw, 0, 0, 0, 0, 0, text, 0); } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH -#if PANGO_PATCH +#if BAR_PANGO_PATCH void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) { @@ -644,7 +644,7 @@ drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, if (h) *h = font->h; } -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH Cur * drw_cur_create(Drw *drw, int shape) diff --git a/drw.h b/drw.h index ae46f9a..8a1812f 100644 --- a/drw.h +++ b/drw.h @@ -1,9 +1,9 @@ /* See LICENSE file for copyright and license details. */ -#if PANGO_PATCH +#if BAR_PANGO_PATCH #include #include -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH typedef struct { Cursor cursor; @@ -12,13 +12,13 @@ typedef struct { typedef struct Fnt { Display *dpy; unsigned int h; - #if PANGO_PATCH + #if BAR_PANGO_PATCH PangoLayout *layout; #else XftFont *xfont; FcPattern *pattern; struct Fnt *next; - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH } Fnt; #if FLOAT_BORDER_COLOR_PATCH @@ -33,32 +33,32 @@ typedef struct { Display *dpy; int screen; Window root; - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH Visual *visual; unsigned int depth; Colormap cmap; - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH Drawable drawable; GC gc; Clr *scheme; - #if PANGO_PATCH + #if BAR_PANGO_PATCH Fnt *font; #else Fnt *fonts; - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH } Drw; /* Drawable abstraction */ -#if ALPHA_PATCH +#if BAR_ALPHA_PATCH Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap); #else Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); -#endif // ALPHA_PATCH +#endif // BAR_ALPHA_PATCH void drw_resize(Drw *drw, unsigned int w, unsigned int h); void drw_free(Drw *drw); /* Fnt abstraction */ -#if PANGO_PATCH +#if BAR_PANGO_PATCH Fnt *drw_font_create(Drw* drw, const char font[]); void drw_font_free(Fnt* set); unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup); @@ -68,33 +68,33 @@ Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); void drw_fontset_free(Fnt* set); unsigned int drw_fontset_getwidth(Drw *drw, const char *text); void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH /* Colorscheme abstraction */ void drw_clr_create( Drw *drw, Clr *dest, - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH const char clrname[] #else const char *clrname - #endif // VTCOLORS_PATCH - #if ALPHA_PATCH + #endif // BAR_VTCOLORS_PATCH + #if BAR_ALPHA_PATCH , unsigned int alpha - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH ); Clr *drw_scm_create( Drw *drw, - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH char clrnames[][8], #elif XRDB_PATCH char *clrnames[], #else const char *clrnames[], - #endif // VTCOLORS_PATCH / XRDB_PATCH - #if ALPHA_PATCH + #endif // BAR_VTCOLORS_PATCH / XRDB_PATCH + #if BAR_ALPHA_PATCH const unsigned int alphas[], - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH size_t clrcount ); @@ -105,16 +105,16 @@ void drw_cur_free(Drw *drw, Cur *cursor); /* Drawing context manipulation */ #if !PANGO_PATCH void drw_setfontset(Drw *drw, Fnt *set); -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH void drw_setscheme(Drw *drw, Clr *scm); /* Drawing functions */ void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); -#if PANGO_PATCH +#if BAR_PANGO_PATCH int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup); #else int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH /* Map functions */ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/dwm.c b/dwm.c index c3bb411..eca9c91 100644 --- a/dwm.c +++ b/dwm.c @@ -45,9 +45,9 @@ #include "drw.h" #include "util.h" -#if PANGO_PATCH +#if BAR_PANGO_PATCH #include -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH #if SPAWNCMD_PATCH #include @@ -57,6 +57,7 @@ #endif // SPAWNCMD_PATCH /* macros */ +#define BARRULES 20 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ @@ -72,9 +73,9 @@ #else #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #endif // ATTACHASIDE_PATCH -#if AWESOMEBAR_PATCH +#if BAR_AWESOMEBAR_PATCH #define HIDDEN(C) ((getstate(C->win) == IconicState)) -#endif // AWESOMEBAR_PATCH +#endif // BAR_AWESOMEBAR_PATCH #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define WIDTH(X) ((X)->w + 2 * (X)->bw) @@ -88,12 +89,12 @@ #else #define TAGMASK ((1 << LENGTH(tags)) - 1) #endif // SCRATCHPADS_PATCH -#if PANGO_PATCH +#if BAR_PANGO_PATCH #define TEXTW(X) (drw_font_getwidth(drw, (X), False) + lrpad) #define TEXTWM(X) (drw_font_getwidth(drw, (X), True) + lrpad) #else #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#endif // PANGO_PATCH +#endif // BAR_PANGO_PATCH /* enums */ enum { @@ -119,36 +120,36 @@ enum { enum { SchemeNorm ,SchemeSel - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH ,SchemeWarn - #endif // STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH ,SchemeUrg - #endif // URGENTBORDER_PATCH || STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH + #if BAR_AWESOMEBAR_PATCH ,SchemeHid - #endif // AWESOMEBAR_PATCH - #if VTCOLORS_PATCH + #endif // BAR_AWESOMEBAR_PATCH + #if BAR_VTCOLORS_PATCH ,SchemeTagsNorm ,SchemeTagsSel ,SchemeTitleNorm ,SchemeTitleSel ,SchemeStatus - #elif TITLECOLOR_PATCH + #elif BAR_TITLECOLOR_PATCH ,SchemeTitle - #endif // VTCOLORS_PATCH + #endif // BAR_VTCOLORS_PATCH }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayVisual, NetWMWindowTypeDock, NetSystemTrayOrientationHorz, - #endif // SYSTRAY_PATCH - #if EWMHTAGS_PATCH + #endif // BAR_SYSTRAY_PATCH + #if BAR_EWMHTAGS_PATCH NetDesktopNames, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop, - #endif // EWMHTAGS_PATCH + #endif // BAR_EWMHTAGS_PATCH NetClientList, NetLast }; /* EWMH atoms */ @@ -164,11 +165,15 @@ enum { }; /* default atoms */ enum { - #if STATUSBUTTON_PATCH + #if BAR_STATUSBUTTON_PATCH ClkButton, - #endif // STATUSBUTTON_PATCH + #endif // BAR_STATUSBUTTON_PATCH + #if BAR_TAGS_PATCH ClkTagBar, + #endif // BAR_TAGS_PATCH + #if BAR_LTSYMBOL_PATCH ClkLtSymbol, + #endif // BAR_LTSYMBOL_PATCH ClkStatusText, ClkWinTitle, ClkClientWin, @@ -176,6 +181,20 @@ enum { ClkLast }; /* clicks */ +enum { + BAR_ALIGN_LEFT, + BAR_ALIGN_CENTER, + BAR_ALIGN_RIGHT, + BAR_ALIGN_LEFT_LEFT, + BAR_ALIGN_LEFT_RIGHT, + BAR_ALIGN_LEFT_CENTER, + BAR_ALIGN_NONE, + BAR_ALIGN_RIGHT_LEFT, + BAR_ALIGN_RIGHT_RIGHT, + BAR_ALIGN_RIGHT_CENTER, + BAR_ALIGN_LAST +}; /* bar alignment */ + typedef union { int i; unsigned int ui; @@ -183,6 +202,26 @@ typedef union { const void *v; } Arg; +typedef struct Bar Bar; +struct Bar { + Window win; + int bx, by, bw, bh; /* bar geometry */ + int w[BARRULES]; // width, array length == barrules, then use r index for lookup purposes + int x[BARRULES]; // x position, array length == ^ +}; + +typedef struct Monitor Monitor; +typedef struct { + int monitor; + int bar; + int alignment; // see bar alignment enum + int (*widthfunc)(Monitor *m, int max_width); + int (*drawfunc)(Monitor *m, int x, int w); + int (*clickfunc)(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); + char *name; // for debugging + int x, w; // position, width for internal use +} BarRule; + typedef struct { unsigned int click; unsigned int mask; @@ -191,7 +230,6 @@ typedef struct { const Arg arg; } Button; -typedef struct Monitor Monitor; typedef struct Client Client; struct Client { char name[256]; @@ -288,18 +326,6 @@ struct Monitor { #endif // FLEXTILE_DELUXE_LAYOUT int nmaster; int num; - int by; /* bar geometry */ - int tw; /* bar text width */ - #if EXTRABAR_PATCH - int eby; /* extra bar geometry */ - #if STATUSCMD_PATCH - int etw; /* extra bar text width */ - #endif // STATUSCMD_PATCH - #endif // EXTRABAR_PATCH - #if AWESOMEBAR_PATCH - int btw; /* width of tasks portion of bar */ - int bt; /* number of tasks */ - #endif // AWESOMEBAR_PATCH int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ #if VANITYGAPS_PATCH @@ -320,14 +346,15 @@ struct Monitor { Client *sel; Client *stack; Monitor *next; - Window barwin; - #if EXTRABAR_PATCH - Window extrabarwin; - #endif // EXTRABAR_PATCH + #if BAR_EXTRABAR_PATCH + Bar *bars[2]; + #else + Bar *bars[1]; + #endif // BAR_EXTRABAR_PATCH const Layout *lt[2]; - #if ALTERNATIVE_TAGS_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH unsigned int alttag; - #endif // ALTERNATIVE_TAGS_PATCH + #endif // BAR_ALTERNATIVE_TAGS_PATCH #if PERTAG_PATCH Pertag *pertag; #endif // PERTAG_PATCH @@ -472,11 +499,11 @@ static void resizemouse(const Arg *arg); static void restack(Monitor *m); static void run(void); static void scan(void); -#if SYSTRAY_PATCH +#if BAR_SYSTRAY_PATCH static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4); #else static int sendevent(Client *c, Atom proto); -#endif // SYSTRAY_PATCH +#endif // BAR_SYSTRAY_PATCH static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); @@ -514,48 +541,46 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); +/* bar functions */ + #include "patch/include.h" /* variables */ static const char broken[] = "broken"; -#if PANGO_PATCH || STATUS2D_PATCH && !STATUSCOLORS_PATCH +#if BAR_PANGO_PATCH || BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH static char stext[1024]; #else static char stext[512]; -#endif // STATUS2D_PATCH -#if STATUS2D_PATCH +#endif // BAR_STATUS2D_PATCH +#if BAR_STATUS2D_PATCH static char rawstext[1024]; #else static char rawstext[512]; -#endif // STATUS2D_PATCH -#if EXTRABAR_PATCH -#if STATUS2D_PATCH && !STATUSCOLORS_PATCH +#endif // BAR_STATUS2D_PATCH +#if BAR_EXTRABAR_PATCH +#if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH static char estext[1024]; #else static char estext[512]; -#endif // STATUS2D_PATCH -#if STATUSCMD_PATCH +#endif // BAR_STATUS2D_PATCH +#if BAR_STATUSCMD_PATCH static char rawestext[1024]; #else static char rawestext[512]; -#endif // STATUSCMD_PATCH -#endif // EXTRABAR_PATCH +#endif // BAR_STATUSCMD_PATCH +#endif // BAR_EXTRABAR_PATCH static int screen; static int sw, sh; /* X display screen geometry width, height */ -static int bh, blw = 0; /* bar geometry */ +static int bh; /* bar geometry */ static int lrpad; /* sum of left and right padding for text */ -#if BARPADDING_PATCH -static int vp; /* vertical padding for bar */ -static int sp; /* side padding for bar */ -#endif // BARPADDING_PATCH static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, - #if COMBO_PATCH || HOLDBAR_PATCH + #if COMBO_PATCH || BAR_HOLDBAR_PATCH [ButtonRelease] = keyrelease, - #endif // COMBO_PATCH / HOLDBAR_PATCH + #endif // COMBO_PATCH / BAR_HOLDBAR_PATCH [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, @@ -566,37 +591,37 @@ static void (*handler[LASTEvent]) (XEvent *) = { [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, - #if COMBO_PATCH || HOLDBAR_PATCH + #if COMBO_PATCH || BAR_HOLDBAR_PATCH [KeyRelease] = keyrelease, - #endif // COMBO_PATCH / HOLDBAR_PATCH + #endif // COMBO_PATCH / BAR_HOLDBAR_PATCH [MappingNotify] = mappingnotify, [MapRequest] = maprequest, #if !FOCUSONCLICK_PATCH [MotionNotify] = motionnotify, #endif // FOCUSONCLICK_PATCH [PropertyNotify] = propertynotify, - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH [ResizeRequest] = resizerequest, - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH [UnmapNotify] = unmapnotify }; -#if SYSTRAY_PATCH +#if BAR_SYSTRAY_PATCH static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast]; #else static Atom wmatom[WMLast], netatom[NetLast]; -#endif // SYSTRAY_PATCH +#endif // BAR_SYSTRAY_PATCH static int running = 1; static Cur *cursor[CurLast]; static Clr **scheme; static Display *dpy; static Drw *drw; static Monitor *mons, *selmon; -#if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH +#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH static Monitor *statmon; -#if EXTRABAR_PATCH +#if BAR_EXTRABAR_PATCH static Monitor *statebmon; -#endif // EXTRABAR_PATCH -#endif // STATICSTATUS_PATCH +#endif // BAR_EXTRABAR_PATCH +#endif // BAR_STATICSTATUS_PATCH static Window root, wmcheckwin; /* configuration, allows nested code to access above variables */ @@ -842,30 +867,13 @@ attachstack(Client *c) void buttonpress(XEvent *e) { - unsigned int i, x, click; - int padding = 0; - #if STATUSCMD_PATCH - unsigned int xc; - #endif // STATUSCMD_PATCH - #if TAGGRID_PATCH - unsigned int columns; - #endif // TAGGRID_PATCH - #if HIDEVACANTTAGS_PATCH - unsigned int occ = 0; - #endif // HIDEVACANTTAGS_PATCH + int click, i, b, r, mi; Arg arg = {0}; Client *c; Monitor *m; XButtonPressedEvent *ev = &e->xbutton; - #if STATUSCMD_PATCH && !DWMBLOCKS_PATCH - lastbutton = ev->button; - #endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH - #if BARPADDING_PATCH - padding -= sp * 2; - #endif // BARPADDING_PATCH - #if TAGGRID_PATCH - columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - #endif // TAGGRID_PATCH + const BarRule *br; + click = ClkRootWin; /* focus monitor if necessary */ if ((m = wintomon(ev->window)) && m != selmon @@ -877,203 +885,26 @@ buttonpress(XEvent *e) selmon = m; focus(NULL); } - #if SYSTRAY_PATCH - if (showsystray && selmon == systraytomon(selmon)) - padding -= getsystraywidth(); - #endif // SYSTRAY_PATCH - if (ev->window == selmon->barwin) { - i = x = 0; - #if LEFTLAYOUT_PATCH - x += blw; - if (ev->x < x) { - click = ClkLtSymbol; - #if STATUSBUTTON_PATCH - } else if (ev->x < (x += TEXTW(buttonbar))) { - click = ClkButton; - #endif // STATUSBUTTON_PATCH - } else { - #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; - #endif // HIDEVACANTTAGS_PATCH - #if TAGGRID_PATCH - if (drawtagmask & DRAWCLASSICTAGS) - #endif // TAGGRID_PATCH - do { - #if HIDEVACANTTAGS_PATCH - /* do not reserve space for vacant tags */ - if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) - continue; - #endif // HIDEVACANTTAGS_PATCH - x += TEXTW(tags[i]); - } while (ev->x >= x && ++i < LENGTH(tags)); - if (i < LENGTH(tags) - #if TAGGRID_PATCH - && (drawtagmask & DRAWCLASSICTAGS) - #endif - ) { - click = ClkTagBar; - arg.ui = 1 << i; - #if TAGGRID_PATCH - } else if (ev->x < x + columns * bh / tagrows && (drawtagmask & DRAWTAGGRID)) { - click = ClkTagBar; - i = (ev->x - x) / (bh / tagrows); - i = i + columns * (ev->y / (bh / tagrows)); - if (i >= LENGTH(tags)) { - i = LENGTH(tags) - 1; - } - arg.ui = 1 << i; - } - else if (ev->x < x + blw + columns * bh / tagrows) - click = ClkLtSymbol; - #else // TAGGRID_PATCH - } else if (ev->x < x + blw) - click = ClkLtSymbol; - #endif // TAGGRID_PATCH - else if (ev->x > selmon->ww - selmon->tw + padding) - #if !STATUSCMD_PATCH - click = ClkStatusText; - #else - { - click = ClkStatusText; - xc = selmon->ww - selmon->tw + padding; - #if STATUSPADDING_PATCH - xc += lrpad / 2; - #endif // STATUSPADDING_PATCH - char *text = rawstext; - int i = -1; - char ch; - #if DWMBLOCKS_PATCH - dwmblockssig = -1; - #else - statuscmdn = 0; - #endif // DWMBLOCKS_PATCH - while (text[++i]) { - if ((unsigned char)text[i] < ' ') { - ch = text[i]; - text[i] = '\0'; - #if STATUS2D_PATCH && !STATUSCOLORS_PATCH - xc += status2dtextlength(text); - #elif PANGO_PATCH - xc += TEXTWM(text) - lrpad; - #else - xc += TEXTW(text) - lrpad; - #endif // STATUS2D_PATCH - text[i] = ch; - text += i+1; - i = -1; - #if DWMBLOCKS_PATCH - if (xc >= ev->x && dwmblockssig != -1) - break; - dwmblockssig = ch; - #else - if (xc >= ev->x) - break; - if (ch <= LENGTH(statuscmds)) - statuscmdn = ch - 1; - #endif // DWMBLOCKS_PATCH - } - } - #if DWMBLOCKS_PATCH - if (dwmblockssig == -1) - dwmblockssig = 0; - #endif // DWMBLOCKS_PATCH - } - #endif // STATUSCMD_PATCH - #if AWESOMEBAR_PATCH - else { - x += blw; - c = m->clients; - - do { - if (!c || !ISVISIBLE(c)) - continue; - else - x += (1.0 / (double)m->bt) * m->btw; - } while (c && ev->x > x && (c = c->next)); - if (c) { - click = ClkWinTitle; - arg.v = c; - } - } - #else - else - click = ClkWinTitle; - #endif // AWESOMEBAR_PATCH - #if LEFTLAYOUT_PATCH || STATUSBUTTON_PATCH - } - #endif // LEFTLAYOUT_PATCH | STATUSBUTTON_PATCH - #if EXTRABAR_PATCH && STATUSCMD_PATCH - } else if (ev->window == selmon->extrabarwin) { - i = x = 0; - padding = 0; - #if BARPADDING_PATCH - padding -= sp * 2; - #endif // BARPADDING_PATCH - if ( - (ebalign == 0 && ev->x >= 0 && ev->x < selmon->etw) || - (ebalign == 1 && ev->x > selmon->ww - selmon->etw + padding) || - (ebalign == 2 && ev->x > (selmon->ww / 2 - selmon->etw / 2 + padding) - && ev->x < (selmon->ww / 2 + selmon->etw / 2 - padding)) - ) { - click = ClkStatusText; - if (ebalign == 0) - xc = 0; // left - else if (ebalign == 1) - xc = selmon->ww - selmon->etw + padding; // right - else - xc = selmon->ww / 2 - selmon->etw / 2 + padding; // center - #if STATUSPADDING_PATCH - xc += lrpad / 2; - #endif // STATUSPADDING_PATCH - char *text = rawestext; - int i = -1; - char ch; - #if DWMBLOCKS_PATCH - dwmblockssig = -1; - #else - statuscmdn = 0; - #endif // DWMBLOCKS_PATCH - while (text[++i]) { - if ((unsigned char)text[i] < ' ') { - ch = text[i]; - text[i] = '\0'; - #if STATUS2D_PATCH && !STATUSCOLORS_PATCH - xc += status2dtextlength(text); - #elif PANGO_PATCH - xc += TEXTWM(text) - lrpad; - #else - xc += TEXTW(text) - lrpad; - #endif // STATUS2D_PATCH - text[i] = ch; - text += i+1; - i = -1; - #if DWMBLOCKS_PATCH - if (xc >= ev->x && dwmblockssig != -1) - break; - dwmblockssig = ch; - #else - if (xc >= ev->x) - break; - if (ch <= LENGTH(statuscmds)) - statuscmdn = ch - 1; - #endif // DWMBLOCKS_PATCH + for (mi = 0, m = mons; m && m != selmon; m = m->next, mi++); // get the monitor index + for (b = 0; b < LENGTH(selmon->bars); b++) { + if (ev->window == selmon->bars[b]->win) { + fprintf(stderr, "buttonpress on bar, mi = %d\n", mi); + for (r = 0; r < LENGTH(barrules); r++) { + br = &barrules[r]; + if (br->bar != b || (br->monitor == 'A' && m != selmon) || (br->monitor != -1 && br->monitor != mi) || br->clickfunc == NULL) + continue; + if (selmon->bars[b]->x[r] <= ev->x && ev->x <= selmon->bars[b]->x[r] + selmon->bars[b]->w[r]) { + click = br->clickfunc(m, &arg, ev->x - selmon->bars[b]->x[r], ev->y, selmon->bars[b]->w[r], bh); + break; } } - #if DWMBLOCKS_PATCH - if (dwmblockssig == -1) - dwmblockssig = 0; - #endif // DWMBLOCKS_PATCH + break; } - #endif // EXTRABAR_PATCH - } else if ((c = wintoclient(ev->window))) { + + } + + if (click == ClkRootWin && (c = wintoclient(ev->window))) { #if FOCUSONCLICK_PATCH if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) focus(c); @@ -1084,14 +915,17 @@ buttonpress(XEvent *e) XAllowEvents(dpy, ReplayPointer, CurrentTime); click = ClkClientWin; } + fprintf(stderr, "click = %d, dwmblockssig = %d, ev->button = %d, mi = %d\n", click, dwmblockssig, ev->button, mi); for (i = 0; i < LENGTH(buttons); i++) if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button - && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) - #if AWESOMEBAR_PATCH + && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) { + fprintf(stderr, "found click, b.button (%d) == ev->button (%d)\n", buttons[i].button, ev->button); + #if BAR_AWESOMEBAR_PATCH buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); #else buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); #endif + } } void @@ -1121,28 +955,28 @@ cleanup(void) XUngrabKey(dpy, AnyKey, AnyModifier, root); while (mons) cleanupmon(mons); - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (showsystray) { XUnmapWindow(dpy, systray->win); XDestroyWindow(dpy, systray->win); free(systray); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH for (i = 0; i < CurLast; i++) drw_cur_free(drw, cursor[i]); - #if STATUS2D_PATCH && !STATUSCOLORS_PATCH + #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH for (i = 0; i < LENGTH(colors) + 1; i++) #else for (i = 0; i < LENGTH(colors); i++) - #endif // STATUS2D_PATCH + #endif // BAR_STATUS2D_PATCH free(scheme[i]); free(scheme); XDestroyWindow(dpy, wmcheckwin); - #if PANGO_PATCH + #if BAR_PANGO_PATCH drw_font_free(drw->font); #else drw_fontset_free(drw->fonts); - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH drw_free(drw); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); @@ -1153,6 +987,7 @@ void cleanupmon(Monitor *mon) { Monitor *m; + int b; if (mon == mons) mons = mons->next; @@ -1160,31 +995,30 @@ cleanupmon(Monitor *mon) for (m = mons; m && m->next != mon; m = m->next); m->next = mon->next; } - XUnmapWindow(dpy, mon->barwin); - XDestroyWindow(dpy, mon->barwin); - #if EXTRABAR_PATCH - if (mon->extrabarwin) { - XUnmapWindow(dpy, mon->extrabarwin); - XDestroyWindow(dpy, mon->extrabarwin); + for (b = 0; b < LENGTH(mon->bars); b++) { + if (mon->bars[b]) { + XUnmapWindow(dpy, mon->bars[b]->win); + XDestroyWindow(dpy, mon->bars[b]->win); + } + free(mon->bars[b]); } - #endif // EXTRABAR_PATCH free(mon); } void clientmessage(XEvent *e) { - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH XWindowAttributes wa; XSetWindowAttributes swa; - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); #if FOCUSONNETACTIVE_PATCH unsigned int i; #endif // FOCUSONNETACTIVE_PATCH - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) { /* add systray icons */ if (cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) { @@ -1195,11 +1029,7 @@ clientmessage(XEvent *e) return; } - /* Clear status bar to avoid artifacts beneath systray icons */ - drw_rect(drw, 0, 0, selmon->ww, bh, 1, 1); - drw_map(drw, selmon->barwin, 0, 0, selmon->ww, bh); - - c->mon = selmon; + c->mon = systray->mon; c->next = systray->icons; systray->icons = c; XGetWindowAttributes(dpy, c->win, &wa); @@ -1222,12 +1052,10 @@ clientmessage(XEvent *e) sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION); XSync(dpy, False); setclientstate(c, NormalState); - drawbar(selmon); - updatesystray(); } return; } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH if (!c) return; @@ -1303,6 +1131,7 @@ configurenotify(XEvent *e) #endif // !FAKEFULLSCREEN_PATCH XConfigureEvent *ev = &e->xconfigure; int dirty; + int b; /* TODO: updategeom handling sucks, needs to be simplified */ if (ev->window == root) { @@ -1322,19 +1151,9 @@ configurenotify(XEvent *e) #endif // FAKEFULLSCREEN_CLIENT_PATCH resizeclient(c, m->mx, m->my, m->mw, m->mh); #endif // !FAKEFULLSCREEN_PATCH - #if BARPADDING_PATCH - XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); - #endif // BARPADDING_PATCH - #if EXTRABAR_PATCH - if (m->extrabarwin) - #if BARPADDING_PATCH - XMoveResizeWindow(dpy, m->extrabarwin, m->wx + sp, m->eby - vp, m->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, m->extrabarwin, m->wx, m->eby, m->ww, bh); - #endif // BARPADDING_PATCH - #endif // EXTRABAR_PATCH + for (b = 0; b < LENGTH(m->bars); b++) + if (m->bars[b]) + XMoveResizeWindow(dpy, m->bars[b]->win, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh); } focus(NULL); arrange(NULL); @@ -1402,9 +1221,7 @@ Monitor * createmon(void) { Monitor *m; - #if PERTAG_PATCH int i; - #endif // PERTAG_PATCH #if MONITOR_RULES_PATCH int mc, j; Monitor *mi; @@ -1433,6 +1250,12 @@ createmon(void) m->gappoh = gappoh; m->gappov = gappov; #endif // VANITYGAPS_PATCH + for (i = 0; i < LENGTH(m->bars); i++) + m->bars[i] = ecalloc(1, sizeof(Bar)); + // for (r = 0; r < LENGTH(barrules); r++) { + + // for (b = 0; b < LENGTH(selmon->bars); b++) { + #if MONITOR_RULES_PATCH for (mc = 0, mi = mons; mi; mi = mi->next, mc++); for (j = 0; j < LENGTH(monrules); j++) { @@ -1550,12 +1373,12 @@ destroynotify(XEvent *e) else if ((c = swallowingclient(ev->window))) unmanage(c->swallowing, 1); #endif // SWALLOW_PATCH - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH else if (showsystray && (c = wintosystrayicon(ev->window))) { removesystrayicon(c); updatesystray(); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH } void @@ -1599,471 +1422,128 @@ dirtomon(int dir) void drawbar(Monitor *m) { - int x, w, stw = 0, stp = 0, invert; - #if ALTERNATIVE_TAGS_PATCH - int wdelta; - #endif // ALTERNATIVE_TAGS_PATCH - #if AWESOMEBAR_PATCH - int n = 0, scm, remainder, tabw; - #elif FANCYBAR_PATCH - int ftw, mw, ew = 0; - int n = 0; - #endif // FANCYBAR_PATCH, AWESOMEBAR_PATCH - #if BARPADDING_PATCH - stw = 2 * sp; - #endif // BARPADDING_PATCH - #if STATUSPADDING_PATCH - stp = lrpad / 2; - #endif // STATUSPADDING_PATCH - #if !HIDEVACANTTAGS_PATCH - #if !ACTIVETAGINDICATORBAR_PATCH && !ACTIVETAGINDICATORBAR_ALT1_PATCH - #if PANGO_PATCH - int boxs = drw->font->h / 9; - #else - int boxs = drw->fonts->h / 9; - #endif // PANGO_PATCH - #endif // ACTIVETAGINDICATORBAR_PATCH | ACTIVETAGINDICATORBAR_ALT1_PATCH - #if PANGO_PATCH - int boxw = drw->font->h / 6 + 2; - #else - int boxw = drw->fonts->h / 6 + 2; - #endif // PANGO_PATCH - #endif // HIDEVACANTTAGS_PATCH - unsigned int i, occ = 0, urg = 0; - #if STATUSCOLORS_PATCH - char *ts = stext; - char *tp = stext; - int tx = 0; - char ctmp; - #endif // STATUSCOLORS_PATCH - Client *c; + Monitor *mon; + int b, r, mi; + int ret_x, w; + int rx, lx, rw, lw; // bar size, split between left and right if a center module is added + const BarRule *br; + Bar *bar; + + for (mi = 0, mon = mons; mon && mon != m; mon = mon->next, mi++); // get the monitor index + for (b = LENGTH(m->bars) - 1; b >= 0; b--) { + fprintf(stderr, "drawbar, monitor m = %ld, mi = %d, b = %d\n", m, mi, b); + bar = m->bars[b]; + if (!bar->win) { + fprintf(stderr, "%s\n", "bar->win does not exist"); + continue; + } - #if SYSTRAY_PATCH - if (showsystray && m == systraytomon(m)) - stw += getsystraywidth(); - #endif // SYSTRAY_PATCH + rw = lw = bar->bw; + rx = lx = 0; + fprintf(stderr, "lx = %d, lw = %d\n", lx, lw); - /* draw status first so it can be overdrawn by tags later */ - #if !STATUSALLMONS_PATCH - #if STATICSTATUS_PATCH - if (m == statmon) - #else - if (m == selmon) - #endif // STATICSTATUS_PATCH - { /* status is only drawn on selected monitor */ - #endif // STATUSALLMONS_PATCH - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeStatus]); + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTagsNorm]); #else drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - #if STATUSCOLORS_PATCH - #if STATUSPADDING_PATCH - m->tw = textw_wosc(stext) + lrpad + 2; - #else - m->tw = textw_wosc(stext) + 2; - #endif // STATUSPADDING_PATCH - while (1) { - if ((unsigned int)*ts > LENGTH(colors)) { - ts++; + #endif // BAR_VTCOLORS_PATCH + drw_rect(drw, lx, 0, lw, bh, 1, 1); + for (r = 0; r < LENGTH(barrules); r++) { + br = &barrules[r]; + if (br->bar != b || (br->monitor == 'A' && m != selmon) || (br->monitor != -1 && br->monitor != mi) || br->drawfunc == NULL) continue; - } - ctmp = *ts; - *ts = '\0'; - #if PANGO_PATCH - drw_text(drw, m->ww - m->tw - stw + tx, 0, m->tw - tx, bh, stp, tp, 0, True); - tx += TEXTWM(tp) - lrpad; - #else - drw_text(drw, m->ww - m->tw - stw + tx, 0, m->tw - tx, bh, stp, tp, 0); - tx += TEXTW(tp) - lrpad; - #endif // PANGO_PATCH - if (ctmp == '\0') - break; - drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); - *ts = ctmp; - tp = ++ts; - } - #elif STATUS2D_PATCH - m->tw = drawstatusbar(m, bh, stext, stw, stp, 1); - #else // STATUSCOLORS_PATCH - #if STATUSPADDING_PATCH && PANGO_PATCH - m->tw = TEXTWM(stext); - #elif STATUSPADDING_PATCH - m->tw = TEXTW(stext); - #elif PANGO_PATCH - m->tw = TEXTWM(stext) - lrpad + 2; /* 2px right padding */ - #else - m->tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - #endif // STATUSPADDING_PATCH | PANGO_PATCH - #if PANGO_PATCH - drw_text(drw, m->ww - m->tw - stw, 0, m->tw, bh, stp, stext, 0, True); - #else - drw_text(drw, m->ww - m->tw - stw, 0, m->tw, bh, stp, stext, 0); - #endif // PANGO_PATCH - #endif // STATUSCOLORS_PATCH | STATUS2D_PATCH - #if !STATUSALLMONS_PATCH - } - #endif // STATUSALLMONS_PATCH - - for (c = m->clients; c; c = c->next) { - #if AWESOMEBAR_PATCH || FANCYBAR_PATCH - if (ISVISIBLE(c)) - n++; - #endif // FANCYBAR_PATCH - #if HIDEVACANTTAGS_PATCH - occ |= c->tags == 255 ? 0 : c->tags; - #else - occ |= c->tags; - #endif // HIDEVACANTTAGS_PATCH - if (c->isurgent) - urg |= c->tags; - } - x = 0; - #if LEFTLAYOUT_PATCH - w = blw = TEXTW(m->ltsymbol); - #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, m->ltsymbol, 0, False); - #else - 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 - for (i = 0; i < LENGTH(tags); i++) { - #if URGENTBORDER_PATCH - invert = 0; - #else - invert = urg & 1 << i; - #endif // URGENTBORDER_PATCH - #if HIDEVACANTTAGS_PATCH - /* do not draw vacant tags */ - if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) - continue; - #endif // HIDEVACANTTAGS_PATCH - w = TEXTW(tags[i]); - #if ALTERNATIVE_TAGS_PATCH - wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0; - #endif // ALTERNATIVE_TAGS_PATCH - #if URGENTBORDER_PATCH - if (m->tagset[m->seltags] & 1 << i) - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTagsSel]); - #else - drw_setscheme(drw, scheme[SchemeSel]); - #endif // VTCOLORS_PATCH - else - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeTagsNorm]); - #else - drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeNorm]); - #endif // VTCOLORS_PATCH - #elif VTCOLORS_PATCH - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]); - #else // URGENTBORDER_PATCH - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - #endif // URGENTBORDER_PATCH - #if ALTERNATIVE_TAGS_PATCH && PANGO_PATCH - drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert, False); - #elif ALTERNATIVE_TAGS_PATCH - drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert); - #elif PANGO_PATCH - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False); - #else - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert); - #endif // ALTERNATIVE_TAGS_PATCH - #if !HIDEVACANTTAGS_PATCH - if (occ & 1 << i) - #if ACTIVETAGINDICATORBAR_PATCH - drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, - #elif ACTIVETAGINDICATORBAR_ALT1_PATCH - drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, - #else - drw_rect(drw, x + boxs, boxs, boxw, boxw, - #endif // ACTIVETAGINDICATORBAR_PATCH - m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); - #endif // HIDEVACANTTAGS_PATCH - x += w; - } - #if TAGGRID_PATCH - if (drawtagmask & DRAWTAGGRID) { - drawtaggrid(m,&x,occ); - } - #endif // TAGGRID_PATCH - #if !LEFTLAYOUT_PATCH - w = blw = TEXTW(m->ltsymbol); - #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, m->ltsymbol, 0, False); - #else - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); - #endif // PANGO_PATCH - #endif // LEFTLAYOUT_PATCH - - if ((w = m->ww - m->tw - stw - x) > bh) - { - #if AWESOMEBAR_PATCH - if (n > 0) { - remainder = w % n; - tabw = w / n; - for (i = 0, c = m->clients; c; c = c->next, i++) { - if (!ISVISIBLE(c)) - continue; - if (m->sel == c) - #if VTCOLORS_PATCH - scm = SchemeTitleSel; - #elif TITLECOLOR_PATCH - scm = SchemeTitle; - #else - scm = SchemeSel; - #endif // VTCOLORS_PATCH / TITLECOLOR_PATCH - else if (HIDDEN(c)) - scm = SchemeHid; - else - #if VTCOLORS_PATCH - scm = SchemeTitleNorm; - #else - scm = SchemeNorm; - #endif // VTCOLORS_PATCH - - drw_setscheme(drw, scheme[scm]); - #if PANGO_PATCH - drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False); - #else - drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0); - #endif // PANGO_PATCH - x += tabw; - } - } else { - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTagsNorm]); #else drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - drw_rect(drw, x, 0, w, bh, 1, 1); - } - #elif FANCYBAR_PATCH - if (n > 0) { - ftw = TEXTW(m->sel->name) + lrpad; - mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1); - - i = 0; - for (c = m->clients; c; c = c->next) { - if (!ISVISIBLE(c) || c == m->sel) - continue; - ftw = TEXTW(c->name); - if (ftw < mw) - ew += (mw - ftw); - else - i++; + #endif // BAR_VTCOLORS_PATCH + if (br->alignment < BAR_ALIGN_RIGHT_LEFT) { + w = br->widthfunc(m, lw); + w = MIN(lw, w); + } else { + w = br->widthfunc(m, rw); + w = MIN(rw, w); } - if (i > 0) - mw += ew / i; - - for (c = m->clients; c; c = c->next) { - if (!ISVISIBLE(c)) - continue; - ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name)); - - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]); - #elif TITLECOLOR_PATCH - drw_setscheme(drw, scheme[m->sel == c ? SchemeTitle : SchemeNorm]); - #else - drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]); - #endif // VTCOLORS_PATCH / TITLECOLOR_PATCH - if (ftw > 0) /* trap special handling of 0 in drw_text */ - #if PANGO_PATCH - drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0, False); - #else - drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0); - #endif // PANGO_PATCH - #if !HIDEVACANTTAGS_PATCH - if (c->isfloating) - #if ACTIVETAGINDICATORBAR_PATCH - drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, c->isfixed, 0); - #elif ACTIVETAGINDICATORBAR_ALT1_PATCH - drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, - #else - drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0); - #endif // ACTIVETAGINDICATORBAR_PATCH - #endif // HIDEVACANTTAGS_PATCH - x += ftw; - w -= ftw; + switch(br->alignment) { + default: + case BAR_ALIGN_NONE: + case BAR_ALIGN_LEFT_LEFT: + case BAR_ALIGN_LEFT: + bar->x[r] = lx; + bar->w[r] = w; + if (lx == rx) { + rx += w; + rw -= w; + } + lx += w; + lw -= w; + break; + case BAR_ALIGN_LEFT_RIGHT: + case BAR_ALIGN_RIGHT: + bar->x[r] = lx + lw - w; + bar->w[r] = w; + if (lx == rx) + rw -= w; + lw -= w; + break; + case BAR_ALIGN_LEFT_CENTER: + case BAR_ALIGN_CENTER: + bar->x[r] = lx + lw / 2 - w / 2; + bar->w[r] = w; + if (lx == rx) { + rw = rx + rw - bar->x[r] - bar->w[r]; + rx = bar->x[r] + bar->w[r]; + } + lw = bar->x[r] - lx; + break; + case BAR_ALIGN_RIGHT_LEFT: + bar->x[r] = rx; + bar->w[r] = w; + if (lx == rx) { + lx += w; + lw -= w; + } + rx += w; + rw -= w; + break; + case BAR_ALIGN_RIGHT_RIGHT: + bar->x[r] = rx + rw - w; + bar->w[r] = w; + if (lx == rx) + lw -= w; + rw -= w; + break; + case BAR_ALIGN_RIGHT_CENTER: + bar->x[r] = rx + rw / 2 - w / 2; + bar->w[r] = w; + if (lx == rx) { + lw = lx + lw - bar->x[r] + bar->w[r]; + lx = bar->x[r] + bar->w[r]; + } + rw = bar->x[r] - rx; + break; + } + ret_x = br->drawfunc(m, bar->x[r], bar->w[r]); + if (ret_x != bar->x[r] + bar->w[r]) + fprintf(stderr, "%s - %d alignment, expected these to be the same: %d vs %d, w = %d, bx = %d\n", br->name, br->alignment, ret_x, bar->x[r] + bar->w[r], bar->w[r], bar->x[r]); + + if (lw <= 0) { // if left is exhausted, switch to right side + lw = rw; + lx = rx; + rw = 0; + rx = 0; } } - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - drw_rect(drw, x, 0, w, bh, 1, 1); - #else - if (m->sel) { - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]); - #elif TITLECOLOR_PATCH - drw_setscheme(drw, scheme[m == selmon ? SchemeTitle : SchemeNorm]); - #else - drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - #endif // VTCOLORS_PATCH / TITLECOLOR_PATCH - #if IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH - XSetErrorHandler(xerrordummy); - #endif // IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH - #if CENTEREDWINDOWNAME_PATCH - int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x; - #if BARPADDING_PATCH && PANGO_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0, False); - #elif BARPADDING_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0); - #elif PANGO_PATCH - drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False); - #else - drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0); - #endif // BARPADDING_PATCH - #else - #if BARPADDING_PATCH && PANGO_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0, False); - #elif BARPADDING_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0); - #elif PANGO_PATCH - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False); - #else - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - #endif // BARPADDING_PATCH - #endif // CENTEREDWINDOWNAME_PATCH - #if IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH - XSync(dpy, False); - XSetErrorHandler(xerror); - #endif // IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH - #if !HIDEVACANTTAGS_PATCH - if (m->sel->isfloating) - #if ACTIVETAGINDICATORBAR_PATCH - drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, m->sel->isfixed, 0); - #elif ACTIVETAGINDICATORBAR_ALT1_PATCH - drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, - #else - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); - #endif // ACTIVETAGINDICATORBAR_PATCH - #endif // HIDEVACANTTAGS_PATCH - } else { - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - #if BARPADDING_PATCH - drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); - #else - drw_rect(drw, x, 0, w, bh, 1, 1); - #endif // BARPADDING_PATCH - } - #endif // FANCYBAR_PATCH, AWESOMEBAR_PATCH + drw_map(drw, bar->win, 0, 0, bar->bw, bar->bh); } - - #if AWESOMEBAR_PATCH - m->bt = n; - m->btw = w; - #endif // AWESOMEBAR_PATCH - drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh); - - #if EXTRABAR_PATCH - #if STATICSTATUS_PATCH - if (m == statebmon && m->extrabarwin) - #else - if (m == selmon && m->extrabarwin) - #endif // STATICSTATUS_PATCH - { /* extra status is only drawn on selected monitor */ - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - drw_rect(drw, 0, 0, m->ww, bh, 1, 1); - - #if !STATUS2D_PATCH - #if PANGO_PATCH - w = TEXTWM(estext) - lrpad; - #else - w = TEXTW(estext) - lrpad; - #endif // PANGO_PATCH - if (ebalign == 0) - x = 0; // left - else if (ebalign == 1) - x = m->ww - w; // right - else - x = m->ww / 2 - w / 2; // center - - #if PANGO_PATCH - drw_text(drw, x, 0, mons->ww, bh, 0, estext, 0, True); - #else - drw_text(drw, x, 0, mons->ww, bh, 0, estext, 0); - #endif // PANGO_PATCH - #else - w = drawstatusbar(m, bh, estext, 0, 0, ebalign); - #endif // STATUS2D_PATCH - #if STATUSCMD_PATCH - m->etw = w; - #endif // STATUSCMD_PATCH - drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh); - } - #if !STATICSTATUS_PATCH - else { /* clear status on other monitors */ - #if VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // VTCOLORS_PATCH - drw_rect(drw, 0, 0, m->ww, bh, 1, 1); - drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh); - } - #endif // STATICSTATUS_PATCH - #endif // EXTRABAR_PATCH } void drawbars(void) { Monitor *m; - - #if SYSTRAY_PATCH - if (showsystray && systraypinning == 0) { - /* Clear status bar to avoid artifacts beneath systray icons */ - drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, 0, 0, selmon->ww, bh, 1, 1); - drw_map(drw, selmon->barwin, 0, 0, selmon->ww, bh); - } - #endif // SYSTRAY_PATCH - for (m = mons; m; m = m->next) drawbar(m); - - #if SYSTRAY_PATCH - if (showsystray) - updatesystray(); - #endif // SYSTRAY_PATCH } #if !FOCUSONCLICK_PATCH @@ -2093,25 +1573,20 @@ expose(XEvent *e) Monitor *m; XExposeEvent *ev = &e->xexpose; - if (ev->count == 0 && (m = wintomon(ev->window))) { + if (ev->count == 0 && (m = wintomon(ev->window))) drawbar(m); - #if SYSTRAY_PATCH - if (showsystray && m == selmon) - updatesystray(); - #endif // SYSTRAY_PATCH - } } void focus(Client *c) { - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH if (!c || !ISVISIBLE(c) || HIDDEN(c)) for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext); #else if (!c || !ISVISIBLE(c)) for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH if (selmon->sel && selmon->sel != c) unfocus(selmon->sel, 0); if (c) { @@ -2206,7 +1681,7 @@ getatomprop(Client *c, Atom prop) unsigned char *p = NULL; Atom da, atom = None; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH /* FIXME getatomprop should return the number of items and a pointer to * the stored data instead of this workaround */ Atom req = XA_ATOM; @@ -2226,7 +1701,7 @@ getatomprop(Client *c, Atom prop) atom = *(Atom *)p; XFree(p); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH return atom; } @@ -2378,11 +1853,11 @@ killclient(const Arg *arg) if (!selmon->sel) #endif // ISPERMANENT_PATCH return; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) { #else if (!sendevent(selmon->sel, wmatom[WMDelete])) { - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH XGrabServer(dpy); XSetErrorHandler(xerrordummy); XSetCloseDownMode(dpy, DestroyAll); @@ -2460,7 +1935,7 @@ manage(Window w, XWindowAttributes *wa) c->y = c->mon->my + c->mon->mh - HEIGHT(c); c->x = MAX(c->x, c->mon->mx); /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) + c->y = MAX(c->y, ((c->mon->bars[0]->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); #if !FLOATPOS_PATCH #if SETBORDERPX_PATCH @@ -2527,22 +2002,22 @@ manage(Window w, XWindowAttributes *wa) (unsigned char *) &(c->win), 1); XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH if (!HIDDEN(c)) setclientstate(c, NormalState); #else setclientstate(c, NormalState); - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH if (c->mon == selmon) unfocus(selmon->sel, 0); c->mon->sel = c; arrange(c->mon); - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH if (!HIDDEN(c)) XMapWindow(dpy, c->win); #else XMapWindow(dpy, c->win); - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH #if SWALLOW_PATCH if (term) swallow(term, c); @@ -2566,13 +2041,13 @@ maprequest(XEvent *e) static XWindowAttributes wa; XMapRequestEvent *ev = &e->xmaprequest; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH Client *i; if (showsystray && (i = wintosystrayicon(ev->window))) { sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION); updatesystray(); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH if (!XGetWindowAttributes(dpy, ev->window, &wa)) return; @@ -2685,11 +2160,11 @@ movemouse(const Arg *arg) Client * nexttiled(Client *c) { - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next); #else for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH return c; } @@ -2711,7 +2186,7 @@ propertynotify(XEvent *e) Window trans; XPropertyEvent *ev = &e->xproperty; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (showsystray && (c = wintosystrayicon(ev->window))) { if (ev->atom == XA_WM_NORMAL_HINTS) { updatesizehints(c); @@ -2721,7 +2196,7 @@ propertynotify(XEvent *e) updatesystrayiconstate(c, ev); updatesystray(); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH if ((ev->window == root) && (ev->atom == XA_WM_NAME)) { #if DWMC_PATCH || FSIGNAL_PATCH @@ -2987,7 +2462,7 @@ restack(Monitor *m) XRaiseWindow(dpy, m->sel->win); if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; - wc.sibling = m->barwin; + wc.sibling = m->bars[0]->win; for (c = m->stack; c; c = c->snext) if (!c->isfloating && ISVISIBLE(c)) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); @@ -3101,21 +2576,21 @@ setclientstate(Client *c, long state) } int -#if SYSTRAY_PATCH +#if BAR_SYSTRAY_PATCH sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4) #else sendevent(Client *c, Atom proto) -#endif // SYSTRAY_PATCH +#endif // BAR_SYSTRAY_PATCH { int n; Atom *protocols; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH Atom mt; - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH int exists = 0; XEvent ev; - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (proto == wmatom[WMTakeFocus] || proto == wmatom[WMDelete]) { mt = wmatom[WMProtocols]; if (XGetWMProtocols(dpy, w, &protocols, &n)) { @@ -3133,10 +2608,10 @@ sendevent(Client *c, Atom proto) exists = protocols[n] == proto; XFree(protocols); } - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH if (exists) { - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH ev.type = ClientMessage; ev.xclient.window = w; ev.xclient.message_type = mt; @@ -3155,7 +2630,7 @@ sendevent(Client *c, Atom proto) ev.xclient.data.l[0] = proto; ev.xclient.data.l[1] = CurrentTime; XSendEvent(dpy, c->win, False, NoEventMask, &ev); - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH } return exists; } @@ -3169,11 +2644,11 @@ setfocus(Client *c) XA_WINDOW, 32, PropModeReplace, (unsigned char *) &(c->win), 1); } - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0); #else sendevent(c, wmatom[WMTakeFocus]); - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH } void @@ -3314,25 +2789,25 @@ setup(void) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); root = RootWindow(dpy, screen); - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH xinitvisual(); drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap); #else drw = drw_create(dpy, screen, root, sw, sh); - #endif // ALPHA_PATCH - #if PANGO_PATCH + #endif // BAR_ALPHA_PATCH + #if BAR_PANGO_PATCH if (!drw_font_create(drw, font)) #else if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH die("no fonts could be loaded."); - #if STATUSPADDING_PATCH && PANGO_PATCH + #if BAR_STATUSPADDING_PATCH && BAR_PANGO_PATCH lrpad = drw->font->h + horizpadbar; bh = drw->font->h + vertpadbar; - #elif STATUSPADDING_PATCH + #elif BAR_STATUSPADDING_PATCH lrpad = drw->fonts->h + horizpadbar; bh = drw->fonts->h + vertpadbar; - #elif PANGO_PATCH + #elif BAR_PANGO_PATCH lrpad = drw->font->h; bh = drw->font->h + 2; #else @@ -3342,12 +2817,8 @@ setup(void) #else bh = drw->fonts->h + 2; #endif // BAR_HEIGHT_PATCH - #endif // STATUSPADDING_PATCH + #endif // BAR_STATUSPADDING_PATCH updategeom(); - #if BARPADDING_PATCH - sp = sidepad; - vp = (topbar == 1) ? vertpad : - vertpad; - #endif // BARPADDING_PATCH /* init atoms */ utf8string = XInternAtom(dpy, "UTF8_STRING", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); @@ -3359,7 +2830,7 @@ setup(void) #endif // WINDOWROLERULE_PATCH netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH netatom[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False); netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False); netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False); @@ -3369,13 +2840,13 @@ setup(void) xatom[Manager] = XInternAtom(dpy, "MANAGER", False); xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False); xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False); - #endif // SYSTRAY_PATCH - #if EWMHTAGS_PATCH + #endif // BAR_SYSTRAY_PATCH + #if BAR_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 + #endif // BAR_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); @@ -3400,7 +2871,7 @@ setup(void) #endif // DRAGCFACT_PATCH cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ - #if VTCOLORS_PATCH + #if BAR_VTCOLORS_PATCH get_vt_colors(); if (get_luminance(colors[SchemeTagsNorm][ColBg]) > 50) { strcpy(colors[SchemeTitleNorm][ColBg], title_bg_light); @@ -3409,34 +2880,43 @@ setup(void) strcpy(colors[SchemeTitleNorm][ColBg], title_bg_dark); strcpy(colors[SchemeTitleSel][ColBg], title_bg_dark); } - #endif // VTCOLORS_PATCH - #if STATUS2D_PATCH && !STATUSCOLORS_PATCH + #endif // BAR_VTCOLORS_PATCH + #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], alphas[0], ColCount); #else scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], ColCount); - #endif // ALPHA_PATCH | FLOAT_BORDER_COLOR_PATCH + #endif // BAR_ALPHA_PATCH | FLOAT_BORDER_COLOR_PATCH #else scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); - #endif // STATUS2D_PATCH + #endif // BAR_STATUS2D_PATCH for (i = 0; i < LENGTH(colors); i++) - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH scheme[i] = drw_scm_create(drw, colors[i], alphas[i], ColCount); #else scheme[i] = drw_scm_create(drw, colors[i], ColCount); - #endif // ALPHA_PATCH - #if SYSTRAY_PATCH - /* init system tray */ - if (showsystray) - updatesystray(); - #endif // SYSTRAY_PATCH + #endif // BAR_ALPHA_PATCH + // #if BAR_SYSTRAY_PATCH + // /* init system tray */ + // if (showsystray) + // updatesystray(); + // #endif // BAR_SYSTRAY_PATCH /* init bars */ + // Monitor *m; + // for (m = mons; m; m = m->next) { + // fprintf(stderr, "updating bar pos\n"); + // updatebarpos(m); + // } updatebars(); updatestatus(); - #if BARPADDING_PATCH - updatebarpos(selmon); - #endif // BARPADDING_PATCH + + // Monitor *m; + // for (m = mons; m; m = m->next) + // updatebarpos(m); + // for () + // updatebarpos(selmon); + /* supporting window for NetWMCheck */ wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, @@ -3448,12 +2928,12 @@ setup(void) /* EWMH support per view */ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); - #if EWMHTAGS_PATCH + #if BAR_EWMHTAGS_PATCH setnumdesktops(); setcurrentdesktop(); setdesktopnames(); setviewport(); - #endif // EWMHTAGS_PATCH + #endif // BAR_EWMHTAGS_PATCH XDeleteProperty(dpy, root, netatom[NetClientList]); /* select events */ wa.cursor = cursor[CurNormal]->cursor; @@ -3536,14 +3016,14 @@ sigchld(int unused) void spawn(const Arg *arg) { - #if STATUSCMD_PATCH && !DWMBLOCKS_PATCH + #if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH char *cmd = NULL; - #endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH + #endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH #if !NODMENU_PATCH if (arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; #endif // NODMENU_PATCH - #if STATUSCMD_PATCH && !DWMBLOCKS_PATCH + #if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH #if !NODMENU_PATCH else if (arg->v == statuscmd) #else @@ -3558,7 +3038,7 @@ spawn(const Arg *arg) cmd[LENGTH(statusexport)-3] = '0' + lastbutton; statuscmd[2] = cmd; } - #endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH + #endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH if (fork() == 0) { if (dpy) @@ -3603,9 +3083,9 @@ spawn(const Arg *arg) perror(" failed"); exit(EXIT_SUCCESS); } - #if STATUSCMD_PATCH && !DWMBLOCKS_PATCH + #if BAR_STATUSCMD_PATCH && !BAR_DWMBLOCKS_PATCH free(cmd); - #endif // STATUSCMD_PATCH | DWMBLOCKS_PATCH + #endif // BAR_STATUSCMD_PATCH | BAR_DWMBLOCKS_PATCH } void @@ -3667,42 +3147,20 @@ tagmon(const Arg *arg) void togglebar(const Arg *arg) { - #if HOLDBAR_PATCH && PERTAG_PATCH && PERTAGBAR_PATCH + int b; + #if BAR_HOLDBAR_PATCH && PERTAG_PATCH && PERTAGBAR_PATCH selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = (selmon->showbar == 2 ? 1 : !selmon->showbar); - #elif HOLDBAR_PATCH + #elif BAR_HOLDBAR_PATCH selmon->showbar = (selmon->showbar == 2 ? 1 : !selmon->showbar); #elif PERTAG_PATCH && PERTAGBAR_PATCH selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; #else selmon->showbar = !selmon->showbar; - #endif // HOLDBAR_PATCH | PERTAG_PATCH + #endif // BAR_HOLDBAR_PATCH | PERTAG_PATCH updatebarpos(selmon); - #if BARPADDING_PATCH - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2*sp, bh); - #else - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BARPADDING_PATCH - #if EXTRABAR_PATCH - if (selmon->extrabarwin) - #if BARPADDING_PATCH - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2*sp, bh); - #else - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BARPADDING_PATCH - #endif // EXTRABAR_PATCH - #if SYSTRAY_PATCH - if (showsystray && selmon == systraytomon(selmon) ) { - XWindowChanges wc; - if (!selmon->showbar) - wc.y = -bh; - else if (selmon->showbar) { - wc.y = 0; - if (!selmon->topbar) - wc.y = selmon->mh - bh; - } - XConfigureWindow(dpy, systray->win, CWY, &wc); - } - #endif // SYSTRAY_PATCH + for (b = 0; b < LENGTH(selmon->bars); b++) + if (selmon->bars[b]->win) + XMoveResizeWindow(dpy, selmon->bars[b]->win, selmon->bars[b]->bx, selmon->bars[b]->by, selmon->bars[b]->bw, selmon->bars[b]->bh); arrange(selmon); } @@ -3772,9 +3230,9 @@ toggletag(const Arg *arg) #endif // SWAPFOCUS_PATCH arrange(selmon); } - #if EWMHTAGS_PATCH + #if BAR_EWMHTAGS_PATCH updatecurrentdesktop(); - #endif // EWMHTAGS_PATCH + #endif // BAR_EWMHTAGS_PATCH } void @@ -3851,9 +3309,9 @@ toggleview(const Arg *arg) #if !EMPTYVIEW_PATCH } #endif // EMPTYVIEW_PATCH - #if EWMHTAGS_PATCH + #if BAR_EWMHTAGS_PATCH updatecurrentdesktop(); - #endif // EWMHTAGS_PATCH + #endif // BAR_EWMHTAGS_PATCH } void @@ -3951,102 +3409,52 @@ unmapnotify(XEvent *e) setclientstate(c, WithdrawnState); else unmanage(c, 0); - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH } else if (showsystray && (c = wintosystrayicon(ev->window))) { /* KLUDGE! sometimes icons occasionally unmap their windows, but do * _not_ destroy them. We map those windows back */ XMapRaised(dpy, c->win); removesystrayicon(c); updatesystray(); - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH } } void updatebars(void) { - unsigned int w; + int b; Monitor *m; XSetWindowAttributes wa = { .override_redirect = True, - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH .background_pixel = 0, .border_pixel = 0, .colormap = cmap, #else .background_pixmap = ParentRelative, - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH .event_mask = ButtonPressMask|ExposureMask }; XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { - if (!m->barwin) { - w = m->ww; - #if SYSTRAY_PATCH - if (showsystray && m == systraytomon(m)) - w -= getsystraywidth(); - #endif // SYSTRAY_PATCH - #if ALPHA_PATCH - #if BARPADDING_PATCH - m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w - 2*sp, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); - #else - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); - #endif // BARPADDING_PATCH - #else - #if BARPADDING_PATCH - m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, w - 2*sp, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - #else - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - #endif // BARPADDING_PATCH - #endif // ALPHA_PATCH - XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); - #if SYSTRAY_PATCH - if (showsystray && m == systraytomon(m)) - XMapRaised(dpy, systray->win); - #endif // SYSTRAY_PATCH - XMapRaised(dpy, m->barwin); - XSetClassHint(dpy, m->barwin, &ch); - } - #if EXTRABAR_PATCH - #if STATICSTATUS_PATCH - if (m == statebmon && !m->extrabarwin) - #else - if (!m->extrabarwin) - #endif // STATICSTATUS_PATCH - { - #if ALPHA_PATCH - #if BARPADDING_PATCH - m->extrabarwin = XCreateWindow(dpy, root, m->wx + sp, m->eby - vp, m->ww - 2*sp, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); - #else - m->extrabarwin = XCreateWindow(dpy, root, m->wx, m->eby, m->ww, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); - #endif // BARPADDING_PATCH - #elif BARPADDING_PATCH - m->extrabarwin = XCreateWindow(dpy, root, m->wx + sp, m->eby - vp, m->ww - 2*sp, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - #else - m->extrabarwin = XCreateWindow(dpy, root, m->wx, m->eby, m->ww, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - #endif // ALPHA_PATCH - XDefineCursor(dpy, m->extrabarwin, cursor[CurNormal]->cursor); - XMapRaised(dpy, m->extrabarwin); - XSetClassHint(dpy, m->extrabarwin, &ch); + for (b = 0; b < LENGTH(m->bars); b++) { + if (!m->bars[b]->win) { // TODO add static status controls to not create / show extra bar? + fprintf(stderr, "creating bar %d at pos x = %d, y = %d, w = %d, h = %d\n", b, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh); + #if BAR_ALPHA_PATCH + m->bars[b]->win = XCreateWindow(dpy, root, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, 0, depth, + InputOutput, visual, + CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); + #else + m->bars[b]->win = XCreateWindow(dpy, root, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, 0, DefaultDepth(dpy, screen), + CopyFromParent, DefaultVisual(dpy, screen), + CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); + #endif // BAR_ALPHA_PATCH + XDefineCursor(dpy, m->bars[b]->win, cursor[CurNormal]->cursor); + XMapRaised(dpy, m->bars[b]->win); + XSetClassHint(dpy, m->bars[b]->win, &ch); + } } - #endif // EXTRABAR_PATCH - } } @@ -4055,54 +3463,36 @@ updatebarpos(Monitor *m) { m->wy = m->my; m->wh = m->mh; - #if EXTRABAR_PATCH - int num_bars; - #if STATICSTATUS_PATCH - int has_extrabar = (m == statebmon); - #else - int has_extrabar = 1; - #endif // STATICSTATUS_PATCH - num_bars = m->showbar * (1 + has_extrabar); - #if BARPADDING_PATCH - m->wh = m->wh - vertpad * num_bars - bh * num_bars; - m->wy = m->showbar ? m->wy + bh + vertpad: m->wy; - if (m->showbar) { - m->by = m->topbar ? m->wy - bh - vertpad: m->wy + m->wh + vertpad; - if (has_extrabar) - m->eby = m->topbar ? m->wy + m->wh + vertpad: m->wy - bh - vertpad; - } else { - m->by = -bh - vertpad; - if (has_extrabar) - m->eby = -bh - vertpad; - } + int num_bars, b; + #if BAR_PADDING_PATCH + int y_pad = vertpad; + int x_pad = sidepad; #else - m->wh = m->wh - bh * num_bars; - m->wy = m->showbar ? m->wy + bh : m->wy; + int y_pad = 0; + int x_pad = 0; + #endif // BAR_PADDING_PATCH + + // for (num_bars = 0; num_bars < LENGTH(m->bars) && m->bars[num_bars]->win; num_bars++); + num_bars = LENGTH(m->bars); + fprintf(stderr, "num_bars = %d\n", num_bars); if (m->showbar) { - m->by = m->topbar ? m->wy - bh : m->wy + m->wh; - if (has_extrabar) - m->eby = m->topbar ? m->wy + m->wh : m->wy - bh; - } else { - m->by = -bh; - if (has_extrabar) - m->eby = -bh; + m->wh = m->wh - y_pad * num_bars - bh * num_bars; + m->wy = m->wy + bh + y_pad; + } + + for (b = 0; b < num_bars; b++) { + fprintf(stderr, "setting bx to xpad %d, b = %d\n", m->mx + x_pad, b); + m->bars[b]->bx = m->mx + x_pad; + m->bars[b]->bw = m->ww - 2 * x_pad; + m->bars[b]->bh = bh; + if (m->showbar) { + fprintf(stderr, "eh? %d, b = %d\n", topbar == b, b); + m->bars[b]->by = m->topbar == b ? m->wy + m->wh : m->wy - bh; + } else { + m->bars[b]->by = -bh - y_pad; + } + fprintf(stderr, "finished with bar, bx = %d, by = %d, bw = %d, bh = %d, m = %ld\n", m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, m); } - #endif // BARPADDING_PATCH - #elif BARPADDING_PATCH - if (m->showbar) { - m->wh = m->wh - vertpad - bh; - m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; - m->wy = m->topbar ? m->wy + bh + vp : m->wy; - } else - m->by = -bh - vp; - #else - if (m->showbar) { - m->wh -= bh; - m->by = m->topbar ? m->wy : m->wy + m->wh; - m->wy = m->topbar ? m->wy + bh : m->wy; - } else - m->by = -bh; - #endif // EXTRABAR_PATCH } void @@ -4152,14 +3542,14 @@ updategeom(void) mons = createmon(); } for (i = 0, m = mons; i < nn && m; m = m->next, i++) { - #if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH + #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH if (i == statmonval) statmon = m; - #if EXTRABAR_PATCH + #if BAR_EXTRABAR_PATCH if (i == statebmonval) statebmon = m; - #endif // EXTRABAR_PATCH - #endif // STATICSTATUS_PATCH + #endif // BAR_EXTRABAR_PATCH + #endif // BAR_STATICSTATUS_PATCH if (i >= n || unique[i].x_org != m->mx || unique[i].y_org != m->my || unique[i].width != m->mw || unique[i].height != m->mh) @@ -4186,14 +3576,14 @@ updategeom(void) } if (m == selmon) selmon = mons; - #if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH + #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH if (m == statmon) statmon = mons; - #if EXTRABAR_PATCH + #if BAR_EXTRABAR_PATCH if (m == statebmon) statebmon = mons; - #endif // EXTRABAR_PATCH - #endif // STATICSTATUS_PATCH + #endif // BAR_EXTRABAR_PATCH + #endif // BAR_STATICSTATUS_PATCH cleanupmon(m); } } @@ -4210,14 +3600,14 @@ updategeom(void) updatebarpos(mons); } } - #if STATICSTATUS_PATCH && !STATUSALLMONS_PATCH + #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH if (!statmon) statmon = mons; - #if EXTRABAR_PATCH + #if BAR_EXTRABAR_PATCH if (!statebmon) statebmon = mons; - #endif // EXTRABAR_PATCH - #endif // STATICSTATUS_PATCH + #endif // BAR_EXTRABAR_PATCH + #endif // BAR_STATICSTATUS_PATCH if (dirty) { selmon = mons; selmon = wintomon(root); @@ -4301,10 +3691,10 @@ updatesizehints(Client *c) void updatestatus(void) { - #if STATUSALLMONS_PATCH + #if BAR_STATUSALLMONS_PATCH Monitor* m; - #endif // STATUSALLMONS_PATCH - #if EXTRABAR_PATCH + #endif // BAR_STATUSALLMONS_PATCH + #if BAR_EXTRABAR_PATCH if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) { strcpy(stext, "dwm-"VERSION); estext[0] = '\0'; @@ -4312,22 +3702,22 @@ updatestatus(void) char *e = strchr(rawstext, statussep); if (e) { *e = '\0'; e++; - #if STATUSCMD_PATCH + #if BAR_STATUSCMD_PATCH strncpy(rawestext, e, sizeof(estext) - 1); copyvalidchars(estext, rawestext); #else strncpy(estext, e, sizeof(estext) - 1); - #endif // STATUSCMD_PATCH + #endif // BAR_STATUSCMD_PATCH } else { estext[0] = '\0'; } - #if STATUSCMD_PATCH + #if BAR_STATUSCMD_PATCH copyvalidchars(stext, rawstext); #else strncpy(stext, rawstext, sizeof(stext) - 1); - #endif // STATUSCMD_PATCH + #endif // BAR_STATUSCMD_PATCH } - #elif STATUSCMD_PATCH + #elif BAR_STATUSCMD_PATCH if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) strcpy(stext, "dwm-"VERSION); else @@ -4335,23 +3725,19 @@ updatestatus(void) #else if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-"VERSION); - #endif // EXTRABAR_PATCH - #if STATUSALLMONS_PATCH + #endif // BAR_EXTRABAR_PATCH + #if BAR_STATUSALLMONS_PATCH for (m = mons; m; m = m->next) drawbar(m); - #elif STATICSTATUS_PATCH + #elif BAR_STATICSTATUS_PATCH drawbar(statmon); - #if EXTRABAR_PATCH + #if BAR_EXTRABAR_PATCH if (statmon != statebmon) drawbar(statebmon); - #endif // EXTRABAR_PATCH + #endif // BAR_EXTRABAR_PATCH #else drawbar(selmon); - #endif // STATUSALLMONS_PATCH | STATICSTATUS_PATCH - #if SYSTRAY_PATCH - if (showsystray) - updatesystray(); - #endif // SYSTRAY_PATCH + #endif // BAR_STATUSALLMONS_PATCH | BAR_STATICSTATUS_PATCH } void @@ -4417,9 +3803,9 @@ view(const Arg *arg) selmon->pertag->prevclient[selmon->pertag->curtag] = unmodified; #endif // SWAPFOCUS_PATCH arrange(selmon); - #if EWMHTAGS_PATCH + #if BAR_EWMHTAGS_PATCH updatecurrentdesktop(); - #endif // EWMHTAGS_PATCH + #endif // BAR_EWMHTAGS_PATCH } Client * @@ -4438,19 +3824,16 @@ wintoclient(Window w) Monitor * wintomon(Window w) { - int x, y; + int x, y, b; Client *c; Monitor *m; if (w == root && getrootptr(&x, &y)) return recttomon(x, y, 1, 1); for (m = mons; m; m = m->next) - #if EXTRABAR_PATCH - if (w == m->barwin || w == m->extrabarwin) - #else - if (w == m->barwin) - #endif // EXTRABAR_PATCH - return m; + for (b = 0; b < LENGTH(m->bars); b++) + if (w == m->bars[b]->win) + return m; if ((c = wintoclient(w))) return c->mon; return selmon; @@ -4584,12 +3967,12 @@ main(int argc, char *argv[]) else if (!strcmp("-h", argv[i]) || !strcmp("--help", argv[i])) die(help()); else if (!strcmp("-fn", argv[i])) /* font set */ - #if PANGO_PATCH + #if BAR_PANGO_PATCH strcpy(font, argv[++i]); #else fonts[0] = argv[++i]; - #endif // PANGO_PATCH - #if !VTCOLORS_PATCH + #endif // BAR_PANGO_PATCH + #if !BAR_VTCOLORS_PATCH else if (!strcmp("-nb", argv[i])) /* normal background color */ colors[SchemeNorm][1] = argv[++i]; else if (!strcmp("-nf", argv[i])) /* normal foreground color */ @@ -4598,7 +3981,7 @@ main(int argc, char *argv[]) colors[SchemeSel][1] = argv[++i]; else if (!strcmp("-sf", argv[i])) /* selected foreground color */ colors[SchemeSel][0] = argv[++i]; - #endif // !VTCOLORS_PATCH + #endif // !BAR_VTCOLORS_PATCH #if NODMENU_PATCH else if (!strcmp("-df", argv[i])) /* dmenu font */ dmenucmd[2] = argv[++i]; @@ -4638,10 +4021,10 @@ main(int argc, char *argv[]) die("dwm: cannot get xcb connection\n"); #endif // SWALLOW_PATCH checkotherwm(); - #if XRDB_PATCH && !VTCOLORS_PATCH + #if XRDB_PATCH && !BAR_VTCOLORS_PATCH XrmInitialize(); loadxrdb(); - #endif // XRDB_PATCH && !VTCOLORS_PATCH + #endif // XRDB_PATCH && !BAR_VTCOLORS_PATCH setup(); #ifdef __OpenBSD__ diff --git a/patch/alpha.c b/patch/alpha.c deleted file mode 100644 index 7da7215..0000000 --- a/patch/alpha.c +++ /dev/null @@ -1,42 +0,0 @@ - -static int useargb = 0; -static Visual *visual; -static int depth; -static Colormap cmap; - -void -xinitvisual() -{ - XVisualInfo *infos; - XRenderPictFormat *fmt; - int nitems; - int i; - - XVisualInfo tpl = { - .screen = screen, - .depth = 32, - .class = TrueColor - }; - long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; - - infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); - visual = NULL; - for (i = 0; i < nitems; i ++) { - fmt = XRenderFindVisualFormat(dpy, infos[i].visual); - if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { - visual = infos[i].visual; - depth = infos[i].depth; - cmap = XCreateColormap(dpy, root, visual, AllocNone); - useargb = 1; - break; - } - } - - XFree(infos); - - if (! visual) { - visual = DefaultVisual(dpy, screen); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); - } -} diff --git a/patch/alpha.h b/patch/alpha.h deleted file mode 100644 index 3c81522..0000000 --- a/patch/alpha.h +++ /dev/null @@ -1,3 +0,0 @@ -#define OPAQUE 0xffU - -static void xinitvisual(); diff --git a/patch/alternativetags.c b/patch/alternativetags.c deleted file mode 100644 index 3c329bc..0000000 --- a/patch/alternativetags.c +++ /dev/null @@ -1,6 +0,0 @@ -void -togglealttag() -{ - selmon->alttag = !selmon->alttag; - drawbar(selmon); -} \ No newline at end of file diff --git a/patch/alternativetags.h b/patch/alternativetags.h deleted file mode 100644 index 2c130f3..0000000 --- a/patch/alternativetags.h +++ /dev/null @@ -1 +0,0 @@ -static void togglealttag(); \ No newline at end of file diff --git a/patch/awesomebar.c b/patch/awesomebar.c deleted file mode 100644 index e21f4f1..0000000 --- a/patch/awesomebar.c +++ /dev/null @@ -1,67 +0,0 @@ -void -hide(Client *c) { - - if (!c || HIDDEN(c)) - return; - - Window w = c->win; - static XWindowAttributes ra, ca; - - // more or less taken directly from blackbox's hide() function - XGrabServer(dpy); - XGetWindowAttributes(dpy, root, &ra); - XGetWindowAttributes(dpy, w, &ca); - // prevent UnmapNotify events - XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); - XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); - XUnmapWindow(dpy, w); - setclientstate(c, IconicState); - XSelectInput(dpy, root, ra.your_event_mask); - XSelectInput(dpy, w, ca.your_event_mask); - XUngrabServer(dpy); - - focus(c->snext); - arrange(c->mon); -} - -void -show(Client *c) -{ - if (!c || !HIDDEN(c)) - return; - - XMapWindow(dpy, c->win); - setclientstate(c, NormalState); - arrange(c->mon); -} - -void -togglewin(const Arg *arg) -{ - Client *c = (Client*)arg->v; - if (c == selmon->sel) - hide(c); - else { - if (HIDDEN(c)) - show(c); - focus(c); - restack(selmon); - } -} - -void -showhideclient(const Arg *arg) -{ - Client *c = (Client*)arg->v; - if (!c) - c = selmon->sel; - if (!c) - return; - - if (HIDDEN(c)) { - show(c); - restack(selmon); - } else { - hide(c); - } -} \ No newline at end of file diff --git a/patch/awesomebar.h b/patch/awesomebar.h deleted file mode 100644 index 8cf46f4..0000000 --- a/patch/awesomebar.h +++ /dev/null @@ -1,4 +0,0 @@ -static void hide(Client *c); -static void show(Client *c); -static void togglewin(const Arg *arg); -static void showhideclient(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_alpha.c b/patch/bar_alpha.c new file mode 100644 index 0000000..7da7215 --- /dev/null +++ b/patch/bar_alpha.c @@ -0,0 +1,42 @@ + +static int useargb = 0; +static Visual *visual; +static int depth; +static Colormap cmap; + +void +xinitvisual() +{ + XVisualInfo *infos; + XRenderPictFormat *fmt; + int nitems; + int i; + + XVisualInfo tpl = { + .screen = screen, + .depth = 32, + .class = TrueColor + }; + long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; + + infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); + visual = NULL; + for (i = 0; i < nitems; i ++) { + fmt = XRenderFindVisualFormat(dpy, infos[i].visual); + if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { + visual = infos[i].visual; + depth = infos[i].depth; + cmap = XCreateColormap(dpy, root, visual, AllocNone); + useargb = 1; + break; + } + } + + XFree(infos); + + if (! visual) { + visual = DefaultVisual(dpy, screen); + depth = DefaultDepth(dpy, screen); + cmap = DefaultColormap(dpy, screen); + } +} diff --git a/patch/bar_alpha.h b/patch/bar_alpha.h new file mode 100644 index 0000000..3c81522 --- /dev/null +++ b/patch/bar_alpha.h @@ -0,0 +1,3 @@ +#define OPAQUE 0xffU + +static void xinitvisual(); diff --git a/patch/bar_alternativetags.c b/patch/bar_alternativetags.c new file mode 100644 index 0000000..3c329bc --- /dev/null +++ b/patch/bar_alternativetags.c @@ -0,0 +1,6 @@ +void +togglealttag() +{ + selmon->alttag = !selmon->alttag; + drawbar(selmon); +} \ No newline at end of file diff --git a/patch/bar_alternativetags.h b/patch/bar_alternativetags.h new file mode 100644 index 0000000..2c130f3 --- /dev/null +++ b/patch/bar_alternativetags.h @@ -0,0 +1 @@ +static void togglealttag(); \ No newline at end of file diff --git a/patch/bar_awesomebar.c b/patch/bar_awesomebar.c new file mode 100644 index 0000000..85ec003 --- /dev/null +++ b/patch/bar_awesomebar.c @@ -0,0 +1,146 @@ +int +width_awesomebar(Monitor *m, int max_width) +{ + return max_width; +} + +int +draw_awesomebar(Monitor *m, int x_orig, int w) +{ + int n = 0, scm, remainder = 0, tabw; + unsigned int i, x = x_orig; + Client *c; + for (c = m->clients; c; c = c->next) + if (ISVISIBLE(c)) + n++; + + if (n > 0) { + remainder = w % n; + tabw = w / n; + for (i = 0, c = m->clients; c; c = c->next, i++) { + if (!ISVISIBLE(c)) + continue; + if (m->sel == c) + #if BAR_VTCOLORS_PATCH + scm = SchemeTitleSel; + #elif BAR_TITLECOLOR_PATCH + scm = SchemeTitle; + #else + scm = SchemeSel; + #endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH + else if (HIDDEN(c)) + scm = SchemeHid; + else + #if BAR_VTCOLORS_PATCH + scm = SchemeTitleNorm; + #else + scm = SchemeNorm; + #endif // BAR_VTCOLORS_PATCH + + drw_setscheme(drw, scheme[scm]); + #if BAR_PANGO_PATCH + drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False); + #else + drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0); + #endif // BAR_PANGO_PATCH + x += tabw; + } + } + return x_orig + w; +} + +int +click_awesomebar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + int x = 0, n = 0; + Client *c; + + for (c = m->clients; c; c = c->next) + if (ISVISIBLE(c)) + n++; + + c = m->clients; + + do { + if (!c || !ISVISIBLE(c)) + continue; + else + x += (1.0 / (double)n) * rel_w; + } while (c && rel_x > x && (c = c->next)); + + if (c) { + arg->v = c; + return ClkWinTitle; + } + return -1; +} + +void +hide(Client *c) { + + if (!c || HIDDEN(c)) + return; + + Window w = c->win; + static XWindowAttributes ra, ca; + + // more or less taken directly from blackbox's hide() function + XGrabServer(dpy); + XGetWindowAttributes(dpy, root, &ra); + XGetWindowAttributes(dpy, w, &ca); + // prevent UnmapNotify events + XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); + XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); + XUnmapWindow(dpy, w); + setclientstate(c, IconicState); + XSelectInput(dpy, root, ra.your_event_mask); + XSelectInput(dpy, w, ca.your_event_mask); + XUngrabServer(dpy); + + focus(c->snext); + arrange(c->mon); +} + +void +show(Client *c) +{ + if (!c || !HIDDEN(c)) + return; + + XMapWindow(dpy, c->win); + setclientstate(c, NormalState); + arrange(c->mon); +} + +void +togglewin(const Arg *arg) +{ + Client *c = (Client*)arg->v; + if (!c) + return; + if (c == selmon->sel) + hide(c); + else { + if (HIDDEN(c)) + show(c); + focus(c); + restack(selmon); + } +} + +void +showhideclient(const Arg *arg) +{ + Client *c = (Client*)arg->v; + if (!c) + c = selmon->sel; + if (!c) + return; + + if (HIDDEN(c)) { + show(c); + restack(selmon); + } else { + hide(c); + } +} \ No newline at end of file diff --git a/patch/bar_awesomebar.h b/patch/bar_awesomebar.h new file mode 100644 index 0000000..84c8505 --- /dev/null +++ b/patch/bar_awesomebar.h @@ -0,0 +1,8 @@ +static int width_awesomebar(Monitor *m, int max_width); +static int draw_awesomebar(Monitor *m, int x, int w); +static int click_awesomebar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); + +static void hide(Client *c); +static void show(Client *c); +static void togglewin(const Arg *arg); +static void showhideclient(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_dwmblocks.c b/patch/bar_dwmblocks.c new file mode 100644 index 0000000..442b0bc --- /dev/null +++ b/patch/bar_dwmblocks.c @@ -0,0 +1,31 @@ +static int dwmblockssig; +pid_t dwmblockspid = 0; + +int +getdwmblockspid() +{ + char buf[16]; + FILE *fp = popen("pidof -s dwmblocks", "r"); + if (fgets(buf, sizeof(buf), fp)); + pid_t pid = strtoul(buf, NULL, 10); + pclose(fp); + dwmblockspid = pid; + return pid != 0 ? 0 : -1; +} + +void +sigdwmblocks(const Arg *arg) +{ + union sigval sv; + sv.sival_int = (dwmblockssig << 8) | arg->i; + if (!dwmblockspid) + if (getdwmblockspid() == -1) + return; + + if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) { + if (errno == ESRCH) { + if (!getdwmblockspid()) + sigqueue(dwmblockspid, SIGUSR1, sv); + } + } +} \ No newline at end of file diff --git a/patch/bar_dwmblocks.h b/patch/bar_dwmblocks.h new file mode 100644 index 0000000..f08f1d5 --- /dev/null +++ b/patch/bar_dwmblocks.h @@ -0,0 +1,2 @@ +static int getdwmblockspid(); +static void sigdwmblocks(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_fancybar.c b/patch/bar_fancybar.c new file mode 100644 index 0000000..b6f5363 --- /dev/null +++ b/patch/bar_fancybar.c @@ -0,0 +1,97 @@ +int +width_fancybar(Monitor *m, int max_width) +{ + return max_width; +} + +int +draw_fancybar(Monitor *m, int x, int w) +{ + int ftw, mw, ew = 0, n = 0; + unsigned int i; + Client *c; + #if !BAR_HIDEVACANTTAGS_PATCH + #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxs = drw->font->h / 9; + #else + int boxs = drw->fonts->h / 9; + #endif // BAR_PANGO_PATCH + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxw = drw->font->h / 6 + 2; + #else + int boxw = drw->fonts->h / 6 + 2; + #endif // BAR_PANGO_PATCH + #endif // BAR_HIDEVACANTTAGS_PATCH + + for (c = m->clients; c; c = c->next) { + if (ISVISIBLE(c)) + n++; + } + + if (n > 0) { + ftw = TEXTW(m->sel->name) + lrpad; + mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1); + + i = 0; + for (c = m->clients; c; c = c->next) { + if (!ISVISIBLE(c) || c == m->sel) + continue; + ftw = TEXTW(c->name); + if (ftw < mw) + ew += (mw - ftw); + else + i++; + } + if (i > 0) + mw += ew / i; + + for (c = m->clients; c; c = c->next) { + if (!ISVISIBLE(c)) + continue; + ftw = MIN(m->sel == c ? w : mw, TEXTW(c->name)); + + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[m->sel == c ? SchemeTitleSel : SchemeTitleNorm]); + #elif BAR_TITLECOLOR_PATCH + drw_setscheme(drw, scheme[m->sel == c ? SchemeTitle : SchemeNorm]); + #else + drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH + if (ftw > 0) /* trap special handling of 0 in drw_text */ + #if BAR_PANGO_PATCH + drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0, False); + #else + drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0); + #endif // BAR_PANGO_PATCH + #if !BAR_HIDEVACANTTAGS_PATCH + if (c->isfloating) + #if BAR_ACTIVETAGINDICATORBAR_PATCH + drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, c->isfixed, 0); + #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, + #else + drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0); + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH + #endif // BAR_HIDEVACANTTAGS_PATCH + x += ftw; + w -= ftw; + } + } + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTitleNorm]); + #else + drw_setscheme(drw, scheme[SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH + drw_rect(drw, x, 0, w, bh, 1, 1); + return x + w; +} + +int +click_fancybar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkWinTitle; +} + + diff --git a/patch/bar_fancybar.h b/patch/bar_fancybar.h new file mode 100644 index 0000000..24336d9 --- /dev/null +++ b/patch/bar_fancybar.h @@ -0,0 +1,3 @@ +static int width_fancybar(Monitor *m, int max_width); +static int draw_fancybar(Monitor *m, int x, int w); +static int click_fancybar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file diff --git a/patch/bar_ltsymbol.c b/patch/bar_ltsymbol.c new file mode 100644 index 0000000..f4417f1 --- /dev/null +++ b/patch/bar_ltsymbol.c @@ -0,0 +1,21 @@ +int +width_ltsymbol(Monitor *m, int max_width) +{ + return TEXTW(m->ltsymbol); +} + +int +draw_ltsymbol(Monitor *m, int x, int w) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0, False); + #else + return drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); + #endif // BAR_PANGO_PATCH +} + +int +click_ltsymbol(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkLtSymbol; +} \ No newline at end of file diff --git a/patch/bar_ltsymbol.h b/patch/bar_ltsymbol.h new file mode 100644 index 0000000..5471496 --- /dev/null +++ b/patch/bar_ltsymbol.h @@ -0,0 +1,3 @@ +static int width_ltsymbol(Monitor *m, int max_width); +static int draw_ltsymbol(Monitor *m, int x, int w); +static int click_ltsymbol(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); diff --git a/patch/bar_status.c b/patch/bar_status.c new file mode 100644 index 0000000..fdf72de --- /dev/null +++ b/patch/bar_status.c @@ -0,0 +1,25 @@ +int +width_status(Monitor *m, int max_width) +{ + #if BAR_PANGO_PATCH + return TEXTWM(stext) - lrpad + 2; /* 2px right padding */ + #else + return TEXTW(stext) - lrpad + 2; /* 2px right padding */ + #endif // BAR_PANGO_PATCH +} + +int +draw_status(Monitor *m, int x, int w) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, x, 0, w, bh, 0, stext, 0, True); + #else + return drw_text(drw, x, 0, w, bh, 0, stext, 0); + #endif // BAR_PANGO_PATCH +} + +int +click_status(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkStatusText; +} diff --git a/patch/bar_status.h b/patch/bar_status.h new file mode 100644 index 0000000..3b6c924 --- /dev/null +++ b/patch/bar_status.h @@ -0,0 +1,3 @@ +static int width_status(Monitor *m, int max_width); +static int draw_status(Monitor *m, int x, int w); +static int click_status(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c new file mode 100644 index 0000000..8b3b3e5 --- /dev/null +++ b/patch/bar_status2d.c @@ -0,0 +1,182 @@ +int +width_status2d(Monitor *m, int max_width) +{ + return status2dtextlength(rawstext); +} + +int +draw_status2d(Monitor *m, int x, int w) +{ + return drawstatusbar(m, x, w, rawstext); +} + +int +click_status2d(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkStatusText; +} + +int +drawstatusbar(Monitor *m, int x, int ow, char* stext) +{ + int i, w, len; + short isCode = 0; + char *text; + char *p; + + len = strlen(stext) + 1; + if (!(text = (char*) malloc(sizeof(char)*len))) + die("malloc"); + p = text; + #if BAR_STATUSCMD_PATCH + copyvalidchars(text, stext); + #else + memcpy(text, stext, len); + #endif // BAR_STATUSCMD_PATCH + + /* process status text */ + i = -1; + while (text[++i]) { + if (text[i] == '^' && !isCode) { + isCode = 1; + + text[i] = '\0'; + #if BAR_PANGO_PATCH + w = TEXTWM(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0, True); + #else + w = TEXTW(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0); + #endif // BAR_PANGO_PATCH + + x += w; + + /* process code */ + while (text[++i] != '^') { + if (text[i] == 'c') { + char buf[8]; + if (i + 7 > len) { + i += 7; + break; + } + memcpy(buf, (char*)text+i+1, 7); + buf[7] = '\0'; + #if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColFg], buf, 0xff); + #elif BAR_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColFg], buf, alphas[SchemeNorm][ColFg]); + #else + drw_clr_create(drw, &drw->scheme[ColFg], buf); + #endif // BAR_ALPHA_PATCH + i += 7; + } else if (text[i] == 'b') { + char buf[8]; + if (i + 7 > len) { + i += 7; + break; + } + memcpy(buf, (char*)text+i+1, 7); + buf[7] = '\0'; + #if BAR_ALPHA_PATCH && BAR_STATUS2D_NO_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColBg], buf, 0xff); + #elif BAR_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColBg], buf, alphas[SchemeNorm][ColBg]); + #else + drw_clr_create(drw, &drw->scheme[ColBg], buf); + #endif // BAR_ALPHA_PATCH + i += 7; + } else if (text[i] == 'd') { + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; + } else if (text[i] == 'r') { + int rx = atoi(text + ++i); + while (text[++i] != ','); + int ry = atoi(text + ++i); + while (text[++i] != ','); + int rw = atoi(text + ++i); + while (text[++i] != ','); + int rh = atoi(text + ++i); + + if (ry < 0) + ry = 0; + if (rx < 0) + rx = 0; + + drw_rect(drw, rx + x, ry, rw, rh, 1, 0); + } else if (text[i] == 'f') { + x += atoi(text + ++i); + } + } + + text = text + i + 1; + i=-1; + isCode = 0; + } + } + if (!isCode) { + #if BAR_PANGO_PATCH + w = TEXTWM(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0, True); + #else + w = TEXTW(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0); + #endif // BAR_PANGO_PATCH + x += w; + } + free(p); + + drw_setscheme(drw, scheme[SchemeNorm]); + + return x; +} + +int +status2dtextlength(char* stext) +{ + int i, w, len; + short isCode = 0; + char *text; + char *p; + + len = strlen(stext) + 1; + if (!(text = (char*) malloc(sizeof(char)*len))) + die("malloc"); + p = text; + #if BAR_STATUSCMD_PATCH + copyvalidchars(text, stext); + #else + memcpy(text, stext, len); + #endif // BAR_STATUSCMD_PATCH + + /* compute width of the status text */ + w = 0; + i = -1; + while (text[++i]) { + if (text[i] == '^') { + if (!isCode) { + isCode = 1; + text[i] = '\0'; + #if BAR_PANGO_PATCH + w += TEXTWM(text) - lrpad; + #else + w += TEXTW(text) - lrpad; + #endif // BAR_PANGO_PATCH + text[i] = '^'; + if (text[++i] == 'f') + w += atoi(text + ++i); + } else { + isCode = 0; + text = text + i + 1; + i = -1; + } + } + } + if (!isCode) + #if BAR_PANGO_PATCH + w += TEXTWM(text) - lrpad; + #else + w += TEXTW(text) - lrpad; + #endif // BAR_PANGO_PATCH + free(p); + return w; +} \ No newline at end of file diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h new file mode 100644 index 0000000..3f1a346 --- /dev/null +++ b/patch/bar_status2d.h @@ -0,0 +1,5 @@ +static int width_status2d(Monitor *m, int max_width); +static int draw_status2d(Monitor *m, int x, int w); +static int click_status2d(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int drawstatusbar(Monitor *m, int x, int w, char* text); +static int status2dtextlength(char* stext); \ No newline at end of file diff --git a/patch/bar_status2d_eb.c b/patch/bar_status2d_eb.c new file mode 100644 index 0000000..adce774 --- /dev/null +++ b/patch/bar_status2d_eb.c @@ -0,0 +1,11 @@ +int +width_status2d_eb(Monitor *m, int max_width) +{ + return status2dtextlength(rawestext); +} + +int +draw_status2d_eb(Monitor *m, int x, int w) +{ + return drawstatusbar(m, x, w, rawestext); +} \ No newline at end of file diff --git a/patch/bar_status2d_eb.h b/patch/bar_status2d_eb.h new file mode 100644 index 0000000..87b41fb --- /dev/null +++ b/patch/bar_status2d_eb.h @@ -0,0 +1,2 @@ +static int width_status2d_eb(Monitor *m, int max_width); +static int draw_status2d_eb(Monitor *m, int x, int w); \ No newline at end of file diff --git a/patch/bar_statusbutton.c b/patch/bar_statusbutton.c new file mode 100644 index 0000000..130ef62 --- /dev/null +++ b/patch/bar_statusbutton.c @@ -0,0 +1,21 @@ +int +width_stbutton(Monitor *m, int max_width) +{ + return TEXTW(buttonbar); +} + +int +draw_stbutton(Monitor *m, int x, int w) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0, False); + #else + return drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0); + #endif // BAR_PANGO_PATCH +} + +int +click_stbutton(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkButton; +} diff --git a/patch/bar_statusbutton.h b/patch/bar_statusbutton.h new file mode 100644 index 0000000..84ac2c5 --- /dev/null +++ b/patch/bar_statusbutton.h @@ -0,0 +1,3 @@ +static int width_stbutton(Monitor *m, int max_width); +static int draw_stbutton(Monitor *m, int x, int w); +static int click_stbutton(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c new file mode 100644 index 0000000..f6166c3 --- /dev/null +++ b/patch/bar_statuscmd.c @@ -0,0 +1,76 @@ +#if !BAR_DWMBLOCKS_PATCH +static const char statusexport[] = "export BUTTON=-;"; +static int statuscmdn; +static int lastbutton; +#endif // BAR_DWMBLOCKS_PATCH + +int +click_statuscmd(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return click_statuscmd_text(m, arg, rel_x, rel_y, rawstext); +} + +#if BAR_EXTRABAR_PATCH +int +click_statuscmd_eb(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return click_statuscmd_text(m, arg, rel_x, rel_y, rawestext); +} +#endif // BAR_EXTRABAR_PATCH + +int +click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, int rel_y, char *text) +{ + int i = -1; + int x = 0; + char ch; + #if BAR_DWMBLOCKS_PATCH + dwmblockssig = -1; + #else + statuscmdn = 0; + #endif // BAR_DWMBLOCKS_PATCH + while (text[++i]) { + if ((unsigned char)text[i] < ' ') { + ch = text[i]; + text[i] = '\0'; + #if BAR_STATUS2D_PATCH && !BAR_BAR_STATUSCOLORS_PATCH + x += status2dtextlength(text); + #elif BAR_PANGO_PATCH + x += TEXTWM(text) - lrpad; + #else + x += TEXTW(text) - lrpad; + #endif // STATUS2D_PATCH + text[i] = ch; + text += i+1; + i = -1; + #if BAR_DWMBLOCKS_PATCH + if (x >= rel_x && dwmblockssig != -1) + break; + dwmblockssig = ch; + #else + if (x >= rel_x) + break; + if (ch <= LENGTH(statuscmds)) + statuscmdn = ch - 1; + #endif // BAR_DWMBLOCKS_PATCH + } + } + #if BAR_DWMBLOCKS_PATCH + if (dwmblockssig == -1) + dwmblockssig = 0; + #endif // BAR_DWMBLOCKS_PATCH + return ClkStatusText; +} + +void +copyvalidchars(char *text, char *rawtext) +{ + int i = -1, j = 0; + + while (rawtext[++i]) { + if ((unsigned char)rawtext[i] >= ' ') { + text[j++] = rawtext[i]; + } + } + text[j] = '\0'; +} diff --git a/patch/bar_statuscmd.h b/patch/bar_statuscmd.h new file mode 100644 index 0000000..92ed7e1 --- /dev/null +++ b/patch/bar_statuscmd.h @@ -0,0 +1,6 @@ +static int click_statuscmd(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +#if BAR_EXTRABAR_PATCH +static int click_statuscmd_eb(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +#endif // BAR_EXTRABAR_PATCH +static int click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, int rel_y, char *text); +static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file diff --git a/patch/bar_systray.c b/patch/bar_systray.c new file mode 100644 index 0000000..9938543 --- /dev/null +++ b/patch/bar_systray.c @@ -0,0 +1,194 @@ +static Systray *systray = NULL; +static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ; +static int systraybaridx = -1; +static int systraybarrule = -1; +static int systrayxpos = 0; + +int +width_systray(Monitor *m, int max_width) +{ + unsigned int w = 0; + Client *i; + if (!systray) + return 1; + if (showsystray) + for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); + return w ? w + systrayspacing : 0; +} + +int +draw_systray(Monitor *m, int x_pos, int w) +{ + systrayxpos = x_pos; + updatesystray(); + return systrayxpos + w; +} + +int +click_systray(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return -1; +} + +void +removesystrayicon(Client *i) +{ + Client **ii; + + if (!showsystray || !i) + return; + for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next); + if (ii) + *ii = i->next; + free(i); +} + +void +resizerequest(XEvent *e) +{ + XResizeRequestEvent *ev = &e->xresizerequest; + Client *i; + + if ((i = wintosystrayicon(ev->window))) { + updatesystrayicongeom(i, ev->width, ev->height); + updatesystray(); + } +} + +void +updatesystray(void) +{ + if (!showsystray) + return; + XSetWindowAttributes wa; + Client *i; + Monitor *m; + unsigned int w = 1, r, mi; + const BarRule *br; + + if (!systray) { + /* init systray */ + if (!(systray = (Systray *)calloc(1, sizeof(Systray)))) + die("fatal: could not malloc() %u bytes\n", sizeof(Systray)); + + /* Work out which bar the systray is to be displayed on */ + for (r = 0; r < LENGTH(barrules); r++) { + br = &barrules[r]; + if (br->drawfunc == &draw_systray) { + systraybaridx = br->bar; + systraybarrule = r; + if (br->monitor == -1 || br->monitor == 'A') + m = selmon; + else + for (m = mons, mi = 0; m && mi < br->monitor && m->next; m = m->next, mi++); + systray->win = m->bars[systraybaridx]->win; + systray->mon = m; + + break; + } + } + if (systraybaridx == -1) { + fprintf(stderr, "dwm: unable to obtain system tray, no draw_systray in bar rules.\n"); + free(systray); + systray = NULL; + return; + } + + XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)&systrayorientation, 1); + #if BAR_ALPHA_PATCH + XChangeProperty(dpy, systray->win, netatom[NetSystemTrayVisual], XA_VISUALID, 32, + PropModeReplace, (unsigned char *)&visual->visualid, 1); + #endif // BAR_ALPHA_PATCH + XChangeProperty(dpy, systray->win, netatom[NetWMWindowType], XA_ATOM, 32, + PropModeReplace, (unsigned char *)&netatom[NetWMWindowTypeDock], 1); + XMapRaised(dpy, systray->win); + XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime); + if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) { + sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0); + XSync(dpy, False); + } else { + fprintf(stderr, "dwm: unable to obtain system tray.\n"); + free(systray); + systray = NULL; + return; + } + } + + for (w = 0, i = systray->icons; i; i = i->next) { + /* make sure the background color stays the same */ + wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa); + XMapRaised(dpy, i->win); + w += systrayspacing; + i->x = systrayxpos + w; + XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h); + w += i->w; + if (i->mon != systray->mon) + i->mon = systray->mon; + } +} + +void +updatesystrayicongeom(Client *i, int w, int h) +{ + if (i) { + i->h = bh; + if (w == h) + i->w = bh; + else if (h == bh) + i->w = w; + else + i->w = (int) ((float)bh * ((float)w / (float)h)); + applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False); + /* force icons into the systray dimensions if they don't want to */ + if (i->h > bh) { + if (i->w == i->h) + i->w = bh; + else + i->w = (int) ((float)bh * ((float)i->w / (float)i->h)); + i->h = bh; + } + if (i->w > 2*bh) + i->w = bh; + } +} + +void +updatesystrayiconstate(Client *i, XPropertyEvent *ev) +{ + long flags; + int code = 0; + + if (!showsystray || !i || ev->atom != xatom[XembedInfo] || + !(flags = getatomprop(i, xatom[XembedInfo]))) + return; + + if (flags & XEMBED_MAPPED && !i->tags) { + i->tags = 1; + code = XEMBED_WINDOW_ACTIVATE; + XMapRaised(dpy, i->win); + setclientstate(i, NormalState); + } + else if (!(flags & XEMBED_MAPPED) && i->tags) { + i->tags = 0; + code = XEMBED_WINDOW_DEACTIVATE; + XUnmapWindow(dpy, i->win); + setclientstate(i, WithdrawnState); + } + else + return; + sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0, + systray->win, XEMBED_EMBEDDED_VERSION); +} + +Client * +wintosystrayicon(Window w) +{ + Client *i = NULL; + + if (!showsystray || !w) + return i; + for (i = systray->icons; i && i->win != w; i = i->next); + return i; +} \ No newline at end of file diff --git a/patch/bar_systray.h b/patch/bar_systray.h new file mode 100644 index 0000000..de588d1 --- /dev/null +++ b/patch/bar_systray.h @@ -0,0 +1,41 @@ +#define SYSTEM_TRAY_REQUEST_DOCK 0 +#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0 + +/* XEMBED messages */ +#define XEMBED_EMBEDDED_NOTIFY 0 +#define XEMBED_WINDOW_ACTIVATE 1 +#define XEMBED_FOCUS_IN 4 +#define XEMBED_MODALITY_ON 10 + +#define XEMBED_MAPPED (1 << 0) +#define XEMBED_WINDOW_ACTIVATE 1 +#define XEMBED_WINDOW_DEACTIVATE 2 + +#define VERSION_MAJOR 0 +#define VERSION_MINOR 0 +#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR + +/* enums */ +enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */ + +typedef struct Systray Systray; +struct Systray { + Window win; + Client *icons; + Monitor *mon; +}; + +/* bar integration */ +static int width_systray(Monitor *m, int max_width); +static int draw_systray(Monitor *m, int x_pos, int w); +static int click_systray(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); + +/* function declarations */ +static Atom getatomprop(Client *c, Atom prop); +static void removesystrayicon(Client *i); +static void resizerequest(XEvent *e); +static void updatesystray(void); +static void updatesystrayicongeom(Client *i, int w, int h); +static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); +static Client *wintosystrayicon(Window w); + diff --git a/patch/bar_taggrid.c b/patch/bar_taggrid.c new file mode 100644 index 0000000..4fa98d7 --- /dev/null +++ b/patch/bar_taggrid.c @@ -0,0 +1,142 @@ +int +width_taggrid(Monitor *m, int max_width) +{ + return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)); +} + +int +draw_taggrid(Monitor *m, int x_pos, int w) +{ + unsigned int x, y, h, max_x, columns, occ = 0; + int invert, i,j, k; + Client *c; + + for (c = m->clients; c; c = c->next) + occ |= c->tags; + + h = bh / tagrows; + x = max_x = x_pos; + y = 0; + columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); + + /* Firstly we will fill the borders of squares */ + XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); + + /* We will draw LENGTH(tags) squares in tagraws raws. */ + for (j = 0, i = 0; j < tagrows; j++) { + x = x_pos; + for (k = 0; k < columns && i < LENGTH(tags); k++, i++) { + invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; + + /* Select active color for current square */ + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel : + scheme[SchemeNorm][ColFg].pixel); + XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); + + /* Mark square if tag has client */ + if (occ & 1 << i) { + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel : + scheme[SchemeNorm][ColBg].pixel); + XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, + h / 2, h / 2); + } + x += h; + if (x > max_x) { + max_x = x; + } + } + y += h; + } + return max_x; +} + +int +click_taggrid(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + unsigned int i, columns; + + columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); + i = (rel_x - 0) / (bh / tagrows) + columns * (rel_y / (bh / tagrows)); + if (i >= LENGTH(tags)) { + i = LENGTH(tags) - 1; + } + arg->ui = 1 << i; + return ClkTagBar; +} + +void +switchtag(const Arg *arg) +{ + unsigned int columns; + unsigned int new_tagset = 0; + unsigned int pos, i; + int col, row; + Arg new_arg; + + columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); + + for (i = 0; i < LENGTH(tags); ++i) { + if (!(selmon->tagset[selmon->seltags] & 1 << i)) { + continue; + } + pos = i; + row = pos / columns; + col = pos % columns; + if (arg->ui & SWITCHTAG_UP) { /* UP */ + row --; + if (row < 0) { + row = tagrows - 1; + } + do { + pos = row * columns + col; + row --; + } while (pos >= LENGTH(tags)); + } + if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */ + row ++; + if (row >= tagrows) { + row = 0; + } + pos = row * columns + col; + if (pos >= LENGTH(tags)) { + row = 0; + } + pos = row * columns + col; + } + if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */ + col --; + if (col < 0) { + col = columns - 1; + } + do { + pos = row * columns + col; + col --; + } while (pos >= LENGTH(tags)); + } + if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */ + col ++; + if (col >= columns) { + col = 0; + } + pos = row * columns + col; + if (pos >= LENGTH(tags)) { + col = 0; + pos = row * columns + col; + } + } + new_tagset |= 1 << pos; + } + new_arg.ui = new_tagset; + if (arg->ui & SWITCHTAG_TOGGLETAG) { + toggletag(&new_arg); + } + if (arg->ui & SWITCHTAG_TAG) { + tag(&new_arg); + } + if (arg->ui & SWITCHTAG_VIEW) { + view (&new_arg); + } + if (arg->ui & SWITCHTAG_TOGGLEVIEW) { + toggleview (&new_arg); + } +} \ No newline at end of file diff --git a/patch/bar_taggrid.h b/patch/bar_taggrid.h new file mode 100644 index 0000000..ca8a16c --- /dev/null +++ b/patch/bar_taggrid.h @@ -0,0 +1,4 @@ +static int width_taggrid(Monitor *m, int max_width); +static int draw_taggrid(Monitor *m, int x, int w); +static int click_taggrid(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static void switchtag(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_tags.c b/patch/bar_tags.c new file mode 100644 index 0000000..73dc5d7 --- /dev/null +++ b/patch/bar_tags.c @@ -0,0 +1,123 @@ +int +width_tags(Monitor *m, int max_width) +{ + int w, i; + for (w = 0, i = 0; i < LENGTH(tags); i++) { + #if BAR_ALTERNATIVE_TAGS_PATCH + w += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]); + #else + w += TEXTW(tags[i]); + #endif // BAR_ALTERNATIVE_TAGS_PATCH + } + return w; +} + +int +draw_tags(Monitor *m, int x, int w) +{ + int invert; + #if BAR_ALTERNATIVE_TAGS_PATCH + int wdelta; + #endif // BAR_ALTERNATIVE_TAGS_PATCH + #if !BAR_HIDEVACANTTAGS_PATCH + #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxs = drw->font->h / 9; + #else + int boxs = drw->fonts->h / 9; + #endif // BAR_PANGO_PATCH + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxw = drw->font->h / 6 + 2; + #else + int boxw = drw->fonts->h / 6 + 2; + #endif // BAR_PANGO_PATCH + #endif // BAR_HIDEVACANTTAGS_PATCH + unsigned int i, occ = 0, urg = 0; + Client *c; + + for (c = m->clients; c; c = c->next) { + #if BAR_HIDEVACANTTAGS_PATCH + occ |= c->tags == 255 ? 0 : c->tags; + #else + occ |= c->tags; + #endif // BAR_HIDEVACANTTAGS_PATCH + if (c->isurgent) + urg |= c->tags; + } + + for (i = 0; i < LENGTH(tags); i++) { + #if URGENTBORDER_PATCH + invert = 0; + #else + invert = urg & 1 << i; + #endif // URGENTBORDER_PATCH + #if BAR_HIDEVACANTTAGS_PATCH + /* do not draw vacant tags */ + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; + #endif // BAR_HIDEVACANTTAGS_PATCH + w = TEXTW(tags[i]); + #if BAR_ALTERNATIVE_TAGS_PATCH + wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0; + #endif // BAR_ALTERNATIVE_TAGS_PATCH + #if URGENTBORDER_PATCH + if (m->tagset[m->seltags] & 1 << i) + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTagsSel]); + #else + drw_setscheme(drw, scheme[SchemeSel]); + #endif // BAR_VTCOLORS_PATCH + else + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeTagsNorm]); + #else + drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH + #elif BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]); + #else // URGENTBORDER_PATCH + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); + #endif // URGENTBORDER_PATCH + #if BAR_ALTERNATIVE_TAGS_PATCH && BAR_PANGO_PATCH + drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert, False); + #elif BAR_ALTERNATIVE_TAGS_PATCH + drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), invert); + #elif BAR_PANGO_PATCH + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert, False); + #else + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert); + #endif // BAR_ALTERNATIVE_TAGS_PATCH + #if !BAR_HIDEVACANTTAGS_PATCH + if (occ & 1 << i) + #if BAR_ACTIVETAGINDICATORBAR_PATCH + drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, + #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, + #else + drw_rect(drw, x + boxs, boxs, boxw, boxw, + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH + m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert); + #endif // BAR_HIDEVACANTTAGS_PATCH + x += w; + } + + return x; +} + +int +click_tags(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + int i = 0, x = 0; + do + #if BAR_ALTERNATIVE_TAGS_PATCH + x += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]); + #else + x += TEXTW(tags[i]); + #endif + while (rel_x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + arg->ui = 1 << i; + } + return ClkTagBar; +} diff --git a/patch/bar_tags.h b/patch/bar_tags.h new file mode 100644 index 0000000..788c488 --- /dev/null +++ b/patch/bar_tags.h @@ -0,0 +1,3 @@ +static int width_tags(Monitor *m, int max_width); +static int draw_tags(Monitor *m, int x, int w); +static int click_tags(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file diff --git a/patch/bar_wintitle.c b/patch/bar_wintitle.c new file mode 100644 index 0000000..e937723 --- /dev/null +++ b/patch/bar_wintitle.c @@ -0,0 +1,89 @@ +int +width_wintitle(Monitor *m, int max_width) +{ + return max_width; +} + +int +draw_wintitle(Monitor *m, int x, int w) +{ + #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxs = drw->font->h / 9; + #else + int boxs = drw->fonts->h / 9; + #endif // BAR_PANGO_PATCH + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + #if BAR_PANGO_PATCH + int boxw = drw->font->h / 6 + 2; + #else + int boxw = drw->fonts->h / 6 + 2; + #endif // BAR_PANGO_PATCH + + if (m->sel) { + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]); + #elif BAR_TITLECOLOR_PATCH + drw_setscheme(drw, scheme[m == selmon ? SchemeTitle : SchemeNorm]); + #else + drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH + #if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH + XSetErrorHandler(xerrordummy); + #endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH + #if BAR_CENTEREDWINDOWNAME_PATCH + int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x; + #if BAR_PADDING_PATCH && BAR_PANGO_PATCH + drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0, False); + #elif BAR_PADDING_PATCH + drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0); + #elif BAR_PANGO_PATCH + drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False); + #else + drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0); + #endif // BAR_PADDING_PATCH + #else + #if BAR_PADDING_PATCH && BAR_PANGO_PATCH + drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0, False); + #elif BAR_PADDING_PATCH + drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0); + #elif BAR_PANGO_PATCH + drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False); + #else + drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + #endif // BAR_PADDING_PATCH + #endif // BAR_CENTEREDWINDOWNAME_PATCH + #if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH + XSync(dpy, False); + XSetErrorHandler(xerror); + #endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH + if (m->sel->isfloating) + #if BAR_ACTIVETAGINDICATORBAR_PATCH + drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, m->sel->isfixed, 0); + #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, + #else + drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + #endif // BAR_ACTIVETAGINDICATORBAR_PATCH + } else { + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTitleNorm]); + #else + drw_setscheme(drw, scheme[SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH + #if BAR_PADDING_PATCH + drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); + #else + drw_rect(drw, x, 0, w, bh, 1, 1); + #endif // BAR_PADDING_PATCH + } + return x + w; +} + +int +click_wintitle(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +{ + return ClkWinTitle; +} + + diff --git a/patch/bar_wintitle.h b/patch/bar_wintitle.h new file mode 100644 index 0000000..b1d7ddd --- /dev/null +++ b/patch/bar_wintitle.h @@ -0,0 +1,3 @@ +static int width_wintitle(Monitor *m, int max_width); +static int draw_wintitle(Monitor *m, int x, int w); +static int click_wintitle(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file diff --git a/patch/bstack.c b/patch/bstack.c deleted file mode 100644 index be06647..0000000 --- a/patch/bstack.c +++ /dev/null @@ -1,74 +0,0 @@ -static void -bstack(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); - sw = m->ww - 2*ov - iv * (n - m->nmaster - 1); - - if (m->nmaster && n > m->nmaster) { - sh = (mh - ih) * (1 - m->mfact); - mh = (mh - ih) * m->mfact; - sx = mx; - sy = my + mh + ih; - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - sh = mh * (1 - m->mfact); - mh = mh * m->mfact; - sy = my + mh; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - #if CFACTS_PATCH - resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #else - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - mx += WIDTH(c) + iv; - #else - mx += WIDTH(c); - #endif - } else { - #if CFACTS_PATCH - resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #else - resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sx += WIDTH(c) + iv; - #else - sx += WIDTH(c); - #endif - } - } -} \ No newline at end of file diff --git a/patch/bstack.h b/patch/bstack.h deleted file mode 100644 index 56c99ff..0000000 --- a/patch/bstack.h +++ /dev/null @@ -1 +0,0 @@ -static void bstack(Monitor *m); \ No newline at end of file diff --git a/patch/bstackhoriz.c b/patch/bstackhoriz.c deleted file mode 100644 index 0f9042f..0000000 --- a/patch/bstackhoriz.c +++ /dev/null @@ -1,76 +0,0 @@ -static void -bstackhoriz(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - mh = m->wh - 2*oh; - sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); - mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); - sw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sh = (mh - ih) * (1 - m->mfact); - mh = (mh - ih) * m->mfact; - sy = my + mh + ih; - sh = m->wh - mh - 2*oh - ih * (n - m->nmaster); - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - sh = mh * (1 - m->mfact); - mh = mh * m->mfact; - sy = my + mh; - sh = m->wh - mh; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i < m->nmaster) { - #if CFACTS_PATCH - resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #else - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - mx += WIDTH(c) + iv; - #else - mx += WIDTH(c); - #endif - } else { - #if CFACTS_PATCH - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sy += HEIGHT(c) + ih; - #else - sy += HEIGHT(c); - #endif - } - } -} \ No newline at end of file diff --git a/patch/bstackhoriz.h b/patch/bstackhoriz.h deleted file mode 100644 index 8dd0ebd..0000000 --- a/patch/bstackhoriz.h +++ /dev/null @@ -1 +0,0 @@ -static void bstackhoriz(Monitor *m); \ No newline at end of file diff --git a/patch/centeredfloatingmaster.c b/patch/centeredfloatingmaster.c deleted file mode 100644 index 756b41f..0000000 --- a/patch/centeredfloatingmaster.c +++ /dev/null @@ -1,94 +0,0 @@ -void -centeredfloatingmaster(Monitor *m) -{ - unsigned int i, n; - float mfacts, sfacts; - int mrest, srest; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - Client *c; - - #if VANITYGAPS_PATCH - float mivf = 1.0; // master inner vertical gap factor - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - mw = m->ww - 2*ov - iv*(n - 1); - sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); - - if (m->nmaster && n > m->nmaster) { - mivf = 0.8; - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * 0.9; - } else { - mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); - mh = m->wh * m->mfact; - } - mx = m->wx + (m->ww - mw) / 2; - my = m->wy + (m->wh - mh - 2*oh) / 2; - - sx = m->wx + ov; - sy = m->wy + oh; - sh = m->wh - 2*oh; - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (m->ww > m->wh) { - mw = m->ww * m->mfact; - mh = m->wh * 0.9; - } else { - mw = m->ww * 0.9; - mh = m->wh * m->mfact; - } - mx = m->wx + (m->ww - mw) / 2; - my = m->wy + (m->wh - mh) / 2; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - /* nmaster clients are stacked horizontally, in the center of the screen */ - #if CFACTS_PATCH - resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #else - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - mx += WIDTH(c) + iv*mivf; - #else - mx += WIDTH(c); - #endif - } else { - /* stack clients are stacked horizontally */ - #if CFACTS_PATCH - resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #else - resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sx += WIDTH(c) + iv; - #else - sx += WIDTH(c); - #endif - } -} diff --git a/patch/centeredfloatingmaster.h b/patch/centeredfloatingmaster.h deleted file mode 100644 index e4147b3..0000000 --- a/patch/centeredfloatingmaster.h +++ /dev/null @@ -1 +0,0 @@ -static void centeredfloatingmaster(Monitor *m); \ No newline at end of file diff --git a/patch/centeredmaster.c b/patch/centeredmaster.c deleted file mode 100644 index a72eb07..0000000 --- a/patch/centeredmaster.c +++ /dev/null @@ -1,159 +0,0 @@ -void -centeredmaster(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int lx = 0, ly = 0, lw = 0, lh = 0; - int rx = 0, ry = 0, rw = 0, rh = 0; - float mfacts = 0, lfacts = 0, rfacts = 0; - int mtotal = 0, ltotal = 0, rtotal = 0; - int mrest = 0, lrest = 0, rrest = 0; - Client *c; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - /* initialize areas */ - #if VANITYGAPS_PATCH - mx = m->wx + ov; - my = m->wy + oh; - mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1); - mw = m->ww - 2*ov; - lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1); - rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1)); - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (n - m->nmaster > 1) { - /* ||<-S->|<---M--->|<-S->|| */ - mw = (m->ww - 2*ov - 2*iv) * m->mfact; - lw = (m->ww - mw - 2*ov - 2*iv) / 2; - mx += lw + iv; - } else { - /* ||<---M--->|<-S->|| */ - mw = (mw - iv) * m->mfact; - lw = m->ww - mw - iv - 2*ov; - } - rw = lw; - lx = m->wx + ov; - ly = m->wy + oh; - rx = mx + mw + iv; - ry = m->wy + oh; - } - #else - mx = m->wx; - my = m->wy; - mh = m->wh; - mw = m->ww; - lh = m->wh; - rh = m->wh; - - if (m->nmaster && n > m->nmaster) { - /* go mfact box in the center if more than nmaster clients */ - if (n - m->nmaster > 1) { - /* ||<-S->|<---M--->|<-S->|| */ - mw = m->ww * m->mfact; - lw = (m->ww - mw) / 2; - mx += lw; - } else { - /* ||<---M--->|<-S->|| */ - mw = mw * m->mfact; - lw = m->ww - mw; - } - rw = lw; - lx = m->wx; - ly = m->wy; - rx = mx + mw; - ry = m->wy; - } - #endif // VANITYGAPS_PATCH - - /* calculate facts */ - #if CFACTS_PATCH - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { - if (!m->nmaster || n < m->nmaster) - mfacts += c->cfact; // total factor of master area - else if ((n - m->nmaster) % 2) - lfacts += c->cfact; // total factor of left hand stack area - else - rfacts += c->cfact; // total factor of right hand stack area - } - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) - if (!m->nmaster || n < m->nmaster) - mtotal += mh / mfacts; - else if ((n - m->nmaster) % 2) - ltotal += lh * (c->cfact / lfacts); - else - rtotal += rh * (c->cfact / rfacts); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { - if (!m->nmaster || n < m->nmaster) - mfacts += 1; - else if ((n - m->nmaster) % 2) - lfacts += 1; // total factor of left hand stack area - else - rfacts += 1; // total factor of right hand stack area - } - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) - if (!m->nmaster || n < m->nmaster) - mtotal += mh / mfacts; - else if ((n - m->nmaster) % 2) - ltotal += lh / lfacts; - else - rtotal += rh / rfacts; - #endif // CFACTS_PATCH - - mrest = mh - mtotal; - lrest = lh - ltotal; - rrest = rh - rtotal; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (!m->nmaster || i < m->nmaster) { - /* nmaster clients are stacked vertically, in the center of the screen */ - #if CFACTS_PATCH - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - my += HEIGHT(c) + ih; - #else - my += HEIGHT(c); - #endif - } else { - /* stack clients are stacked vertically */ - if ((i - m->nmaster) % 2 ) { - #if CFACTS_PATCH - resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) * c->cfact + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - ly += HEIGHT(c) + ih; - #else - ly += HEIGHT(c); - #endif - } else { - #if CFACTS_PATCH - resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) * c->cfact + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - ry += HEIGHT(c) + ih; - #else - ry += HEIGHT(c); - #endif - } - } - } -} \ No newline at end of file diff --git a/patch/centeredmaster.h b/patch/centeredmaster.h deleted file mode 100644 index b047212..0000000 --- a/patch/centeredmaster.h +++ /dev/null @@ -1 +0,0 @@ -static void centeredmaster(Monitor *m); \ No newline at end of file diff --git a/patch/columns.c b/patch/columns.c deleted file mode 100644 index bcdaa11..0000000 --- a/patch/columns.c +++ /dev/null @@ -1,73 +0,0 @@ -static void -col(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - mh = m->wh - 2*oh; - sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); - mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); - sw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv * m->nmaster; - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - sw = mw * (1 - m->mfact); - mw = mw * m->mfact; - sx = mx + mw; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - #if CFACTS_PATCH - resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #else - resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - mx += WIDTH(c) + iv; - #else - mx += WIDTH(c); - #endif - } else { - #if CFACTS_PATCH - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sy += HEIGHT(c) + ih; - #else - sy += HEIGHT(c); - #endif - } -} \ No newline at end of file diff --git a/patch/columns.h b/patch/columns.h deleted file mode 100644 index 8f64a09..0000000 --- a/patch/columns.h +++ /dev/null @@ -1 +0,0 @@ -static void col(Monitor *); \ No newline at end of file diff --git a/patch/combo.c b/patch/combo.c index 907b645..43f7e5d 100644 --- a/patch/combo.c +++ b/patch/combo.c @@ -1,12 +1,12 @@ static int combo = 0; -#if !HOLDBAR_PATCH +#if !BAR_HOLDBAR_PATCH void keyrelease(XEvent *e) { combo = 0; } -#endif // !HOLDBAR_PATCH +#endif // !BAR_HOLDBAR_PATCH void combotag(const Arg *arg) diff --git a/patch/combo.h b/patch/combo.h index 08be95e..752f636 100644 --- a/patch/combo.h +++ b/patch/combo.h @@ -1,5 +1,5 @@ -#if !HOLDBAR_PATCH +#if !BAR_HOLDBAR_PATCH static void keyrelease(XEvent *e); -#endif // !HOLDBAR_PATCH +#endif // !BAR_HOLDBAR_PATCH static void combotag(const Arg *arg); static void comboview(const Arg *arg); \ No newline at end of file diff --git a/patch/deck.c b/patch/deck.c deleted file mode 100644 index 6f2027d..0000000 --- a/patch/deck.c +++ /dev/null @@ -1,66 +0,0 @@ -static void -deck(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); - sw = mw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv; - sh = m->wh - 2*oh; - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - sw = mw * (1 - m->mfact); - mw = mw * m->mfact; - sx = mx + mw; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); - - if (n - m->nmaster > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - #if CFACTS_PATCH - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - my += HEIGHT(c) + ih; - #else - my += HEIGHT(c); - #endif - } else { - resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0); - } -} \ No newline at end of file diff --git a/patch/deck.h b/patch/deck.h deleted file mode 100644 index abedeb2..0000000 --- a/patch/deck.h +++ /dev/null @@ -1 +0,0 @@ -static void deck(Monitor *m); \ No newline at end of file diff --git a/patch/dwmblocks.c b/patch/dwmblocks.c deleted file mode 100644 index 442b0bc..0000000 --- a/patch/dwmblocks.c +++ /dev/null @@ -1,31 +0,0 @@ -static int dwmblockssig; -pid_t dwmblockspid = 0; - -int -getdwmblockspid() -{ - char buf[16]; - FILE *fp = popen("pidof -s dwmblocks", "r"); - if (fgets(buf, sizeof(buf), fp)); - pid_t pid = strtoul(buf, NULL, 10); - pclose(fp); - dwmblockspid = pid; - return pid != 0 ? 0 : -1; -} - -void -sigdwmblocks(const Arg *arg) -{ - union sigval sv; - sv.sival_int = (dwmblockssig << 8) | arg->i; - if (!dwmblockspid) - if (getdwmblockspid() == -1) - return; - - if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) { - if (errno == ESRCH) { - if (!getdwmblockspid()) - sigqueue(dwmblockspid, SIGUSR1, sv); - } - } -} \ No newline at end of file diff --git a/patch/dwmblocks.h b/patch/dwmblocks.h deleted file mode 100644 index f08f1d5..0000000 --- a/patch/dwmblocks.h +++ /dev/null @@ -1,2 +0,0 @@ -static int getdwmblockspid(); -static void sigdwmblocks(const Arg *arg); \ No newline at end of file diff --git a/patch/fibonacci.c b/patch/fibonacci.c deleted file mode 100644 index 87a1bdf..0000000 --- a/patch/fibonacci.c +++ /dev/null @@ -1,190 +0,0 @@ -#if VANITYGAPS_PATCH -void -fibonacci(Monitor *m, int s) -{ - unsigned int i, n; - int nx, ny, nw, nh; - int oh, ov, ih, iv; - int nv, hrest = 0, wrest = 0, r = 1; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - if (n == 0) - return; - - nx = m->wx + ov; - ny = oh; - nw = m->ww - 2*ov; - nh = m->wh - 2*oh; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { - if (r) { - if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw)) - || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) { - r = 0; - } - if (r && i < n - 1) { - if (i % 2) { - nv = (nh - ih) / 2; - hrest = nh - 2*nv - ih; - nh = nv; - } else { - nv = (nw - iv) / 2; - wrest = nw - 2*nv - iv; - nw = nv; - } - - if ((i % 4) == 2 && !s) - nx += nw + iv; - else if ((i % 4) == 3 && !s) - ny += nh + ih; - } - - if ((i % 4) == 0) { - if (s) { - ny += nh + ih; - nh += hrest; - } - else { - nh -= hrest; - ny -= nh + ih; - } - } - else if ((i % 4) == 1) { - nx += nw + iv; - nw += wrest; - } - else if ((i % 4) == 2) { - ny += nh + ih; - nh += hrest; - if (i < n - 1) - nw += wrest; - } - else if ((i % 4) == 3) { - if (s) { - nx += nw + iv; - nw -= wrest; - } else { - nw -= wrest; - nx -= nw + iv; - nh += hrest; - } - } - if (i == 0) { - if (n != 1) { - nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact); - wrest = 0; - } - ny = m->wy + oh; - } - else if (i == 1) - nw = m->ww - nw - iv - 2*ov; - i++; - } - - resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); - } -} -#else -void -fibonacci(Monitor *m, int s) -{ - unsigned int i, n; - int nx, ny, nw, nh; - int nv, hrest = 0, wrest = 0, r = 1; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - nx = m->wx; - ny = m->wy; - nw = m->ww; - nh = m->wh; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { - if (r) { - if ((i % 2 && nh / 2 <= (bh + 2*c->bw)) - || (!(i % 2) && nw / 2 <= (bh + 2*c->bw))) { - r = 0; - } - if (r && i < n - 1) { - if (i % 2) { - nv = nh / 2; - hrest = nh - 2*nv; - nh = nv; - } else { - nv = nw / 2; - wrest = nw - 2*nv; - nw = nv; - } - - if ((i % 4) == 2 && !s) - nx += nw; - else if ((i % 4) == 3 && !s) - ny += nh; - } - - if ((i % 4) == 0) { - if (s) { - ny += nh; - nh += hrest; - } - else { - nh -= hrest; - ny -= nh; - } - } - else if ((i % 4) == 1) { - nx += nw; - nw += wrest; - } - else if ((i % 4) == 2) { - ny += nh; - nh += hrest; - if (i < n - 1) - nw += wrest; - } - else if ((i % 4) == 3) { - if (s) { - nx += nw; - nw -= wrest; - } else { - nw -= wrest; - nx -= nw; - nh += hrest; - } - } - if (i == 0) { - if (n != 1) { - nw = m->ww - m->ww * (1 - m->mfact); - wrest = 0; - } - ny = m->wy; - } - else if (i == 1) - nw = m->ww - nw; - i++; - } - - resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); - } -} -#endif - -#if FIBONACCI_DWINDLE_LAYOUT -static void -dwindle(Monitor *m) -{ - fibonacci(m, 1); -} -#endif - -#if FIBONACCI_SPIRAL_LAYOUT -static void -spiral(Monitor *m) -{ - fibonacci(m, 0); -} -#endif diff --git a/patch/fibonacci.h b/patch/fibonacci.h deleted file mode 100644 index a15eb76..0000000 --- a/patch/fibonacci.h +++ /dev/null @@ -1,7 +0,0 @@ -#if FIBONACCI_DWINDLE_LAYOUT -static void dwindle(Monitor *m); -#endif // FIBONACCI_DWINDLE_LAYOUT -static void fibonacci(Monitor *m, int s); -#if FIBONACCI_SPIRAL_LAYOUT -static void spiral(Monitor *m); -#endif // FIBONACCI_SPIRAL_LAYOUT \ No newline at end of file diff --git a/patch/flextile-deluxe.c b/patch/flextile-deluxe.c deleted file mode 100644 index a877c92..0000000 --- a/patch/flextile-deluxe.c +++ /dev/null @@ -1,770 +0,0 @@ -typedef struct { - void (*arrange)(Monitor *, int, int, int, int, int, int, int); -} LayoutArranger; - -typedef struct { - void (*arrange)(Monitor *, int, int, int, int, int, int, int, int, int); -} TileArranger; - -static const LayoutArranger flexlayouts[] = { - { layout_no_split }, - { layout_split_vertical }, - { layout_split_horizontal }, - { layout_split_centered_vertical }, - { layout_split_centered_horizontal }, - { layout_split_vertical_dual_stack }, - { layout_split_horizontal_dual_stack }, - { layout_floating_master }, - { layout_split_vertical_fixed }, - { layout_split_horizontal_fixed }, - { layout_split_centered_vertical_fixed }, - { layout_split_centered_horizontal_fixed }, - { layout_split_vertical_dual_stack_fixed }, - { layout_split_horizontal_dual_stack_fixed }, - { layout_floating_master_fixed }, -}; - -static const TileArranger flextiles[] = { - { arrange_top_to_bottom }, - { arrange_left_to_right }, - { arrange_monocle }, - { arrange_gapplessgrid }, - { arrange_gapplessgrid_alt1 }, - { arrange_gapplessgrid_alt2 }, - { arrange_gridmode }, - { arrange_horizgrid }, - { arrange_dwindle }, - { arrange_spiral }, -}; - -static void -getfactsforrange(Monitor *m, int an, int ai, int size, int *rest, float *fact) -{ - int i; - float facts; - Client *c; - int total = 0; - - facts = 0; - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i >= ai && i < (ai + an)) - #if CFACTS_PATCH - facts += c->cfact; - #else - facts += 1; - #endif // CFACTS_PATCH - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i >= ai && i < (ai + an)) - #if CFACTS_PATCH - total += size * (c->cfact / facts); - #else - total += size / facts; - #endif // CFACTS_PATCH - - *rest = size - total; - *fact = facts; -} - -#if DWMC_PATCH -static void -setlayoutaxisex(const Arg *arg) -{ - int axis, arr; - - axis = arg->i & 0x3; // lower two bytes indicates layout, master or stack1-2 - arr = ((arg->i & 0xFC) >> 2); // remaining six upper bytes indicates arrangement - - if ((axis == 0 && abs(arr) > LAYOUT_LAST) - || (axis > 0 && (arr > AXIS_LAST || arr < 0))) - arr = 0; - - selmon->ltaxis[axis] = arr; - #if PERTAG_PATCH - selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis]; - #endif // PERTAG_PATCH - arrange(selmon); -} -#endif // DWMC_PATCH - -static void -layout_no_split(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, n, 0); -} - -static void -layout_split_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (m->nmaster && n > m->nmaster) { - layout_split_vertical_fixed(m, x, y, h, w, ih, iv, n); - } else { - layout_no_split(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sw, sx; - - sw = (w - iv) * (1 - m->mfact); - w = (w - iv) * m->mfact; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sx = x; - x += sw + iv; - } else { - sx = x + w + iv; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, h, sw, ih, iv, n, n - m->nmaster, m->nmaster); -} - -static void -layout_split_vertical_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (!m->nmaster || n <= m->nmaster) { - layout_no_split(m, x, y, h, w, ih, iv, n); - } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { - layout_split_vertical(m, x, y, h, w, ih, iv, n); - } else { - layout_split_vertical_dual_stack_fixed(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_vertical_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sh, sw, sx, oy, sc; - - if (m->nstack) - sc = m->nstack; - else - sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); - - sw = (w - iv) * (1 - m->mfact); - sh = (h - ih) / 2; - w = (w - iv) * m->mfact; - oy = y + sh + ih; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sx = x; - x += sw + iv; - } else { - sx = x + w + iv; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, sh, sw, ih, iv, n, sc, m->nmaster); - (&flextiles[m->ltaxis[STACK2]])->arrange(m, sx, oy, sh, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); -} - -static void -layout_split_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (m->nmaster && n > m->nmaster) { - layout_split_horizontal_fixed(m, x, y, h, w, ih, iv, n); - } else { - layout_no_split(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sh, sy; - - sh = (h - ih) * (1 - m->mfact); - h = (h - ih) * m->mfact; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sy = y; - y += sh + ih; - } else { - sy = y + h + ih; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, w, ih, iv, n, n - m->nmaster, m->nmaster); -} - -static void -layout_split_horizontal_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (!m->nmaster || n <= m->nmaster) { - layout_no_split(m, x, y, h, w, ih, iv, n); - } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { - layout_split_horizontal(m, x, y, h, w, ih, iv, n); - } else { - layout_split_horizontal_dual_stack_fixed(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_horizontal_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sh, sy, ox, sc; - - if (m->nstack) - sc = m->nstack; - else - sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); - - sh = (h - ih) * (1 - m->mfact); - h = (h - ih) * m->mfact; - sw = (w - iv) / 2; - ox = x + sw + iv; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sy = y; - y += sh + ih; - } else { - sy = y + h + ih; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, sw, ih, iv, n, sc, m->nmaster); - (&flextiles[m->ltaxis[STACK2]])->arrange(m, ox, sy, sh, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); -} - -static void -layout_split_centered_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (!m->nmaster || n <= m->nmaster) { - layout_no_split(m, x, y, h, w, ih, iv, n); - } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { - layout_split_vertical(m, x, y, h, w, ih, iv, n); - } else { - layout_split_centered_vertical_fixed(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_centered_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sw, sx, ox, sc; - - if (m->nstack) - sc = m->nstack; - else - sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); - - sw = (w - 2*iv) * (1 - m->mfact) / 2; - w = (w - 2*iv) * m->mfact; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sx = x; - x += sw + iv; - ox = x + w + iv; - } else { - ox = x; - x += sw + iv; - sx = x + w + iv; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, h, sw, ih, iv, n, sc, m->nmaster); - (&flextiles[m->ltaxis[STACK2]])->arrange(m, ox, y, h, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); -} - -static void -layout_split_centered_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (!m->nmaster || n <= m->nmaster) { - layout_no_split(m, x, y, h, w, ih, iv, n); - } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { - layout_split_horizontal(m, x, y, h, w, ih, iv, n); - } else { - layout_split_centered_horizontal_fixed(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_split_centered_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int sh, sy, oy, sc; - - if (m->nstack) - sc = m->nstack; - else - sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); - - sh = (h - 2*ih) * (1 - m->mfact) / 2; - h = (h - 2*ih) * m->mfact; - if (m->ltaxis[LAYOUT] < 0) { // mirror - sy = y; - y += sh + ih; - oy = y + h + ih; - } else { - oy = y; - y += sh + ih; - sy = y + h + ih; - } - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); - (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, w, ih, iv, n, sc, m->nmaster); - (&flextiles[m->ltaxis[STACK2]])->arrange(m, x, oy, sh, w, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); -} - -static void -layout_floating_master(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - /* Split master into master + stack if we have enough clients */ - if (!m->nmaster || n <= m->nmaster) { - layout_no_split(m, x, y, h, w, ih, iv, n); - } else { - layout_floating_master_fixed(m, x, y, h, w, ih, iv, n); - } -} - -static void -layout_floating_master_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) -{ - int mh, mw; - - /* Draw stack area first */ - (&flextiles[m->ltaxis[STACK]])->arrange(m, x, y, h, w, ih, iv, n, n - m->nmaster, m->nmaster); - - if (w > h) { - mw = w * m->mfact; - mh = h * 0.9; - } else { - mw = w * 0.9; - mh = h * m->mfact; - } - x = x + (w - mw) / 2; - y = y + (h - mh) / 2; - - (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, mh, mw, ih, iv, n, m->nmaster, 0); -} - -static void -arrange_left_to_right(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, rest; - float facts, fact = 1; - Client *c; - - if (ai + an > n) - an = n - ai; - - w -= iv * (an - 1); - getfactsforrange(m, an, ai, w, &rest, &facts); - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i >= ai && i < (ai + an)) { - #if CFACTS_PATCH - fact = c->cfact; - #endif // CFACTS_PATCH - resize(c, x, y, w * (fact / facts) + ((i - ai) < rest ? 1 : 0) - (2*c->bw), h - (2*c->bw), 0); - x += WIDTH(c) + iv; - } - } -} - -static void -arrange_top_to_bottom(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, rest; - float facts, fact = 1; - Client *c; - - if (ai + an > n) - an = n - ai; - - h -= ih * (an - 1); - getfactsforrange(m, an, ai, h, &rest, &facts); - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i >= ai && i < (ai + an)) { - #if CFACTS_PATCH - fact = c->cfact; - #endif // CFACTS_PATCH - resize(c, x, y, w - (2*c->bw), h * (fact / facts) + ((i - ai) < rest ? 1 : 0) - (2*c->bw), 0); - y += HEIGHT(c) + ih; - } - } -} - -static void -arrange_monocle(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i; - Client *c; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i >= ai && i < (ai + an)) - resize(c, x, y, w - (2*c->bw), h - (2*c->bw), 0); -} - -static void -arrange_gridmode(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, cols, rows, ch, cw, cx, cy, cc, cr, chrest, cwrest; // counters - Client *c; - - /* grid dimensions */ - for (rows = 0; rows <= an/2; rows++) - if (rows*rows >= an) - break; - cols = (rows && (rows - 1) * rows >= an) ? rows - 1 : rows; - - /* window geoms (cell height/width) */ - ch = (h - ih * (rows - 1)) / (rows ? rows : 1); - cw = (w - iv * (cols - 1)) / (cols ? cols : 1); - chrest = h - ih * (rows - 1) - ch * rows; - cwrest = w - iv * (cols - 1) - cw * cols; - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i >= ai && i < (ai + an)) { - cc = ((i - ai) / rows); // client column number - cr = ((i - ai) % rows); // client row number - cx = x + cc * (cw + iv) + MIN(cc, cwrest); - cy = y + cr * (ch + ih) + MIN(cr, chrest); - resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); - } - } -} - -static void -arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int ntop, nbottom, rh, rest; - - /* Exception when there is only one client; don't split into two rows */ - if (an == 1) { - arrange_monocle(m, x, y, h, w, ih, iv, n, an, ai); - return; - } - - ntop = an / 2; - nbottom = an - ntop; - rh = (h - ih) / 2; - rest = h - ih - rh * 2; - arrange_left_to_right(m, x, y, rh + rest, w, ih, iv, n, ntop, ai); - arrange_left_to_right(m, x, y + rh + ih + rest, rh, w, ih, iv, n, nbottom, ai + ntop); -} - -static void -arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, cols, rows, ch, cw, cn, rn, cc, rrest, crest; // counters - Client *c; - - /* grid dimensions */ - for (cols = 1; cols <= an/2; cols++) - if (cols*cols >= an) - break; - if (an == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ - cols = 2; - rows = an/cols; - cn = rn = cc = 0; // reset column no, row no, client count - - ch = (h - ih * (rows - 1)) / rows; - rrest = (h - ih * (rows - 1)) - ch * rows; - cw = (w - iv * (cols - 1)) / cols; - crest = (w - iv * (cols - 1)) - cw * cols; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - if (i >= ai && i < (ai + an)) { - if (cc/rows + 1 > cols - an%cols) { - rows = an/cols + 1; - ch = (h - ih * (rows - 1)) / rows; - rrest = (h - ih * (rows - 1)) - ch * rows; - } - resize(c, - x, - y + rn*(ch + ih) + MIN(rn, rrest), - cw + (cn < crest ? 1 : 0) - 2*c->bw, - ch + (rn < rrest ? 1 : 0) - 2*c->bw, - 0); - rn++; - cc++; - if (rn >= rows) { - rn = 0; - x += cw + ih + (cn < crest ? 1 : 0); - cn++; - } - } - } -} - -/* This version of gappless grid fills rows first */ -static void -arrange_gapplessgrid_alt1(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, cols, rows, rest, ch; - - /* grid dimensions */ - for (cols = 1; cols <= an/2; cols++) - if (cols*cols >= an) - break; - rows = (cols && (cols - 1) * cols >= an) ? cols - 1 : cols; - ch = (h - ih * (rows - 1)) / (rows ? rows : 1); - rest = (h - ih * (rows - 1)) - ch * rows; - - for (i = 0; i < rows; i++) { - arrange_left_to_right(m, x, y, ch + (i < rest ? 1 : 0), w, ih, iv, n, MIN(cols, an - i*cols), ai + i*cols); - y += ch + (i < rest ? 1 : 0) + ih; - } -} - -/* This version of gappless grid fills columns first */ -static void -arrange_gapplessgrid_alt2(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - int i, cols, rows, rest, cw; - - /* grid dimensions */ - for (rows = 0; rows <= an/2; rows++) - if (rows*rows >= an) - break; - cols = (rows && (rows - 1) * rows >= an) ? rows - 1 : rows; - cw = (w - iv * (cols - 1)) / (cols ? cols : 1); - rest = (w - iv * (cols - 1)) - cw * cols; - - for (i = 0; i < cols; i++) { - arrange_top_to_bottom(m, x, y, h, cw + (i < rest ? 1 : 0), ih, iv, n, MIN(rows, an - i*rows), ai + i*rows); - x += cw + (i < rest ? 1 : 0) + iv; - } -} - -static void -arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai, int s) -{ - int i, j, nv, hrest = 0, wrest = 0, nx = x, ny = y, nw = w, nh = h, r = 1; - Client *c; - - for (i = 0, j = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), j++) { - if (j >= ai && j < (ai + an)) { - if (r) { - if ((i % 2 && ((nh - ih) / 2) <= (bh + 2*c->bw)) || (!(i % 2) && ((nw - iv) / 2) <= (bh + 2*c->bw))) { - r = 0; - } - if (r && i < an - 1) { - if (i % 2) { - nv = (nh - ih) / 2; - hrest = nh - 2*nv - ih; - nh = nv; - } else { - nv = (nw - iv) / 2; - wrest = nw - 2*nv - iv; - nw = nv; - } - - if ((i % 4) == 2 && !s) - nx += nw + iv; - else if ((i % 4) == 3 && !s) - ny += nh + ih; - } - if ((i % 4) == 0) { - if (s) { - ny += nh + ih; - nh += hrest; - } - else { - nh -= hrest; - ny -= nh + ih; - } - } - else if ((i % 4) == 1) { - nx += nw + iv; - nw += wrest; - } - else if ((i % 4) == 2) { - ny += nh + ih; - nh += hrest; - if (i < n - 1) - nw += wrest; - } - else if ((i % 4) == 3) { - if (s) { - nx += nw + iv; - nw -= wrest; - } else { - nw -= wrest; - nx -= nw + iv; - nh += hrest; - } - } - if (i == 0) { - if (an != 1) { - nw = (w - iv) - (w - iv) * (1 - m->mfact); - wrest = 0; - } - ny = y; - } - else if (i == 1) - nw = w - nw - iv; - i++; - } - - resize(c, nx, ny, nw - 2 * c->bw, nh - 2*c->bw, False); - } - } -} - -static void -arrange_dwindle(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 1); -} - -static void -arrange_spiral(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) -{ - arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 0); -} - -static void -flextile(Monitor *m) -{ - unsigned int n; - int oh = 0, ov = 0, ih = 0, iv = 0; // gaps outer/inner horizontal/vertical - - #if VANITYGAPS_PATCH - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - Client *c; - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (m->lt[m->sellt]->preset.layout != m->ltaxis[LAYOUT] || - m->lt[m->sellt]->preset.masteraxis != m->ltaxis[MASTER] || - m->lt[m->sellt]->preset.stack1axis != m->ltaxis[STACK] || - m->lt[m->sellt]->preset.stack2axis != m->ltaxis[STACK2]) - setflexsymbols(m, n); - else if (m->lt[m->sellt]->preset.symbolfunc != NULL) - m->lt[m->sellt]->preset.symbolfunc(m, n); - - if (n == 0) - return; - - #if VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH - /* No outer gap if full screen monocle */ - if (abs(m->ltaxis[MASTER]) == MONOCLE && (abs(m->ltaxis[LAYOUT]) == NO_SPLIT || n <= m->nmaster)) { - oh = 0; - ov = 0; - } - #endif // VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH - - (&flexlayouts[abs(m->ltaxis[LAYOUT])])->arrange(m, m->wx + ov, m->wy + oh, m->wh - 2*oh, m->ww - 2*ov, ih, iv, n); - return; -} - -static void -setflexsymbols(Monitor *m, unsigned int n) -{ - int l; - char sym1, sym2, sym3; - Client *c; - - if (n == 0) - for (c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - - l = abs(m->ltaxis[LAYOUT]); - if (m->ltaxis[MASTER] == MONOCLE && (l == NO_SPLIT || !m->nmaster || n <= m->nmaster)) { - monoclesymbols(m, n); - return; - } - - if (m->ltaxis[STACK] == MONOCLE && (l == SPLIT_VERTICAL || l == SPLIT_HORIZONTAL_FIXED)) { - decksymbols(m, n); - return; - } - - /* Layout symbols */ - if (l == NO_SPLIT || !m->nmaster) { - sym1 = sym2 = sym3 = (int)tilesymb[m->ltaxis[MASTER]]; - } else { - sym2 = layoutsymb[l]; - if (m->ltaxis[LAYOUT] < 0) { - sym1 = tilesymb[m->ltaxis[STACK]]; - sym3 = tilesymb[m->ltaxis[MASTER]]; - } else { - sym1 = tilesymb[m->ltaxis[MASTER]]; - sym3 = tilesymb[m->ltaxis[STACK]]; - } - } - - snprintf(m->ltsymbol, sizeof m->ltsymbol, "%c%c%c", sym1, sym2, sym3); -} - -static void -monoclesymbols(Monitor *m, unsigned int n) -{ - if (n > 0) - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); - else - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[M]"); -} - -static void -decksymbols(Monitor *m, unsigned int n) -{ - if (n > m->nmaster) - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[]%d", n); - else - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[D]"); -} - -/* Mirror layout axis for flextile */ -void -mirrorlayout(const Arg *arg) -{ - if (!selmon->lt[selmon->sellt]->arrange) - return; - selmon->ltaxis[LAYOUT] *= -1; - #if PERTAG_PATCH - selmon->pertag->ltaxis[selmon->pertag->curtag][0] = selmon->ltaxis[LAYOUT]; - #endif // PERTAG_PATCH - arrange(selmon); -} - -/* Rotate layout axis for flextile */ -void -rotatelayoutaxis(const Arg *arg) -{ - int incr = (arg->i > 0 ? 1 : -1); - int axis = abs(arg->i) - 1; - - if (!selmon->lt[selmon->sellt]->arrange) - return; - if (axis == LAYOUT) { - if (selmon->ltaxis[LAYOUT] >= 0) { - selmon->ltaxis[LAYOUT] += incr; - if (selmon->ltaxis[LAYOUT] >= LAYOUT_LAST) - selmon->ltaxis[LAYOUT] = 0; - else if (selmon->ltaxis[LAYOUT] < 0) - selmon->ltaxis[LAYOUT] = LAYOUT_LAST - 1; - } else { - selmon->ltaxis[LAYOUT] -= incr; - if (selmon->ltaxis[LAYOUT] <= -LAYOUT_LAST) - selmon->ltaxis[LAYOUT] = 0; - else if (selmon->ltaxis[LAYOUT] > 0) - selmon->ltaxis[LAYOUT] = -LAYOUT_LAST + 1; - } - } else { - selmon->ltaxis[axis] += incr; - if (selmon->ltaxis[axis] >= AXIS_LAST) - selmon->ltaxis[axis] = 0; - else if (selmon->ltaxis[axis] < 0) - selmon->ltaxis[axis] = AXIS_LAST - 1; - } - #if PERTAG_PATCH - selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis]; - #endif // PERTAG_PATCH - arrange(selmon); - setflexsymbols(selmon, 0); -} - -void -incnstack(const Arg *arg) -{ - #if PERTAG_PATCH - selmon->nstack = selmon->pertag->nstacks[selmon->pertag->curtag] = MAX(selmon->nstack + arg->i, 0); - #else - selmon->nstack = MAX(selmon->nstack + arg->i, 0); - #endif // PERTAG_PATCH - arrange(selmon); -} diff --git a/patch/flextile-deluxe.h b/patch/flextile-deluxe.h deleted file mode 100644 index 01bce7b..0000000 --- a/patch/flextile-deluxe.h +++ /dev/null @@ -1,117 +0,0 @@ -static void flextile(Monitor *m); -static void getfactsforrange(Monitor *m, int an, int ai, int size, int *rest, float *fact); -static void mirrorlayout(const Arg *arg); -static void rotatelayoutaxis(const Arg *arg); -#if DWMC_PATCH -static void setlayoutaxisex(const Arg *arg); -#endif // DWMC_PATCH -static void incnstack(const Arg *arg); - -/* Symbol handlers */ -static void setflexsymbols(Monitor *m, unsigned int n); -static void monoclesymbols(Monitor *m, unsigned int n); -static void decksymbols(Monitor *m, unsigned int n); - -/* Layout split */ -static void layout_no_split(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_vertical_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_horizontal_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_centered_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_centered_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_floating_master(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_vertical_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_horizontal_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_centered_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_split_centered_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); -static void layout_floating_master_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); - -/* Layout tile arrangements */ -static void arrange_left_to_right(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_top_to_bottom(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_monocle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_gapplessgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_gapplessgrid_alt1(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_gapplessgrid_alt2(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_gridmode(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_horizgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_dwindle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); -static void arrange_spiral(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); - -/* Named flextile constants */ -enum { - LAYOUT, // controls overall layout arrangement / split - MASTER, // indicates the tile arrangement for the master area - STACK, // indicates the tile arrangement for the stack area - STACK2, // indicates the tile arrangement for the secondary stack area - LTAXIS_LAST, -}; - -/* Layout arrangements */ -enum { - NO_SPLIT, - SPLIT_VERTICAL, // master stack vertical split - SPLIT_HORIZONTAL, // master stack horizontal split - SPLIT_CENTERED_VERTICAL, // centered master vertical split - SPLIT_CENTERED_HORIZONTAL, // centered master horizontal split - SPLIT_VERTICAL_DUAL_STACK, // master stack vertical split with dual stack - SPLIT_HORIZONTAL_DUAL_STACK, // master stack vertical split with dual stack - FLOATING_MASTER, // (fake) floating master - SPLIT_VERTICAL_FIXED, // master stack vertical fixed split - SPLIT_HORIZONTAL_FIXED, // master stack horizontal fixed split - SPLIT_CENTERED_VERTICAL_FIXED, // centered master vertical fixed split - SPLIT_CENTERED_HORIZONTAL_FIXED, // centered master horizontal fixed split - SPLIT_VERTICAL_DUAL_STACK_FIXED, // master stack vertical split with fixed dual stack - SPLIT_HORIZONTAL_DUAL_STACK_FIXED, // master stack vertical split with fixed dual stack - FLOATING_MASTER_FIXED, // (fake) fixed floating master - LAYOUT_LAST, -}; - -static char layoutsymb[] = { - 32, // " ", - 124, // "|", - 61, // "=", - 94, // "^", - 126, // "~", - 58, // ":", - 59, // ";", - 43, // "+", - 124, // "¦", - 61, // "=", - 94, // "^", - 126, // "~", - 58, // ":", - 59, // ";", - 43, // "+", -}; - -/* Tile arrangements */ -enum { - TOP_TO_BOTTOM, // clients are arranged vertically - LEFT_TO_RIGHT, // clients are arranged horizontally - MONOCLE, // clients are arranged in deck / monocle mode - GAPPLESSGRID, // clients are arranged in a gappless grid (original formula) - GAPPLESSGRID_ALT1, // clients are arranged in a gappless grid (alt. 1, fills rows first) - GAPPLESSGRID_ALT2, // clients are arranged in a gappless grid (alt. 2, fills columns first) - GRIDMODE, // clients are arranged in a grid - HORIZGRID, // clients are arranged in a horizontal grid - DWINDLE, // clients are arranged in fibonacci dwindle mode - SPIRAL, // clients are arranged in fibonacci spiral mode - AXIS_LAST, -}; - -static char tilesymb[] = { - 61, // "=", - 124, // "|", - 68, // "D", - 71, // "G", - 49, // "1", - 50, // "2" - 35, // "#", - 126, // "~", - 92, // "\\", - 64, // "@", -}; diff --git a/patch/gapplessgrid.c b/patch/gapplessgrid.c deleted file mode 100644 index 0330181..0000000 --- a/patch/gapplessgrid.c +++ /dev/null @@ -1,98 +0,0 @@ -#if VANITYGAPS_PATCH -void -gaplessgrid(Monitor *m) -{ - unsigned int i, n; - int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters - int oh, ov, ih, iv; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - if (n == 0) - return; - - /* grid dimensions */ - for (cols = 0; cols <= n/2; cols++) - if (cols*cols >= n) - break; - if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ - cols = 2; - rows = n/cols; - cn = rn = 0; // reset column no, row no, client count - - ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; - cw = (m->ww - 2*ov - iv * (cols - 1)) / cols; - rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; - crest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; - x = m->wx + ov; - y = m->wy + oh; - - for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { - if (i/rows + 1 > cols - n%cols) { - rows = n/cols + 1; - ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; - rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; - } - resize(c, - x, - y + rn*(ch + ih) + MIN(rn, rrest), - cw + (cn < crest ? 1 : 0) - 2*c->bw, - ch + (rn < rrest ? 1 : 0) - 2*c->bw, - 0); - rn++; - if (rn >= rows) { - rn = 0; - x += cw + ih + (cn < crest ? 1 : 0); - cn++; - } - } -} -#else -void -gaplessgrid(Monitor *m) -{ - unsigned int i, n; - int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - /* grid dimensions */ - for (cols = 0; cols <= n/2; cols++) - if (cols*cols >= n) - break; - if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ - cols = 2; - rows = n/cols; - cn = rn = 0; // reset column no, row no, client count - - ch = m->wh / rows; - cw = m->ww / cols; - rrest = m->wh - ch * rows; - crest = m->ww - cw * cols; - x = m->wx; - y = m->wy; - - for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { - if (i/rows + 1 > cols - n%cols) { - rows = n/cols + 1; - ch = m->wh / rows; - rrest = m->wh - ch * rows; - } - resize(c, - x, - y + rn*ch + MIN(rn, rrest), - cw + (cn < crest ? 1 : 0) - 2*c->bw, - ch + (rn < rrest ? 1 : 0) - 2*c->bw, - 0); - rn++; - if (rn >= rows) { - rn = 0; - x += cw + (cn < crest ? 1 : 0); - cn++; - } - } -} -#endif diff --git a/patch/gapplessgrid.h b/patch/gapplessgrid.h deleted file mode 100644 index 28a7b5d..0000000 --- a/patch/gapplessgrid.h +++ /dev/null @@ -1 +0,0 @@ -static void gaplessgrid(Monitor *m); \ No newline at end of file diff --git a/patch/grid.c b/patch/grid.c deleted file mode 100644 index df19896..0000000 --- a/patch/grid.c +++ /dev/null @@ -1,60 +0,0 @@ -#if VANITYGAPS_PATCH -void -grid(Monitor *m) -{ - unsigned int i, n; - int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; - int oh, ov, ih, iv; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - - /* grid dimensions */ - for (rows = 0; rows <= n/2; rows++) - if (rows*rows >= n) - break; - cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; - - /* window geoms (cell height/width) */ - ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1); - cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1); - chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; - cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - cc = i / rows; - cr = i % rows; - cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest); - cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest); - resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); - } -} -#else -void -grid(Monitor *m) -{ - unsigned int i, n; - int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - - /* grid dimensions */ - for (rows = 0; rows <= n/2; rows++) - if (rows*rows >= n) - break; - cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; - - /* window geoms (cell height/width) */ - ch = m->wh / (rows ? rows : 1); - cw = m->ww / (cols ? cols : 1); - chrest = m->wh - ch * rows; - cwrest = m->ww - cw * cols; - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { - cc = i / rows; - cr = i % rows; - cx = m->wx + cc * cw + MIN(cc, cwrest); - cy = m->wy + cr * ch + MIN(cr, chrest); - resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); - } -} -#endif \ No newline at end of file diff --git a/patch/grid.h b/patch/grid.h deleted file mode 100644 index 81149ce..0000000 --- a/patch/grid.h +++ /dev/null @@ -1 +0,0 @@ -static void grid(Monitor *m); \ No newline at end of file diff --git a/patch/holdbar.c b/patch/holdbar.c index e3a5bfc..4be9af1 100644 --- a/patch/holdbar.c +++ b/patch/holdbar.c @@ -5,18 +5,18 @@ holdbar(const Arg *arg) return; selmon->showbar = 2; updateholdbarpos(selmon); - #if BARPADDING_PATCH + #if BAR_PADDING_PATCH XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); #else XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BARPADDING_PATCH - #if EXTRABAR_PATCH - #if BARPADDING_PATCH + #endif // BAR_PADDING_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); #else XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BARPADDING_PATCH - #endif // EXTRABAR_PATCH + #endif // BAR_PADDING_PATCH + #endif // BAR_EXTRABAR_PATCH } void @@ -35,18 +35,18 @@ keyrelease(XEvent *e) if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY) && selmon->showbar == 2) { selmon->showbar = 0; updateholdbarpos(selmon); - #if BARPADDING_PATCH + #if BAR_PADDING_PATCH XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); #else XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BARPADDING_PATCH - #if EXTRABAR_PATCH - #if BARPADDING_PATCH + #endif // BAR_PADDING_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); #else XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BARPADDING_PATCH - #endif // EXTRABAR_PATCH + #endif // BAR_PADDING_PATCH + #endif // BAR_EXTRABAR_PATCH arrange(selmon); } #if COMBO_PATCH @@ -59,8 +59,8 @@ updateholdbarpos(Monitor *m) { m->wy = m->my; m->wh = m->mh; - #if EXTRABAR_PATCH - #if BARPADDING_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH m->wh = m->wh - vertpad * m->showbar * 2 - bh * m->showbar * 2; m->wy = m->showbar ? m->wy + bh + vertpad: m->wy; if (m->showbar) { @@ -80,8 +80,8 @@ updateholdbarpos(Monitor *m) m->by = -bh; m->eby = -bh; } - #endif // BARPADDING_PATCH - #elif BARPADDING_PATCH + #endif // BAR_PADDING_PATCH + #elif BAR_PADDING_PATCH if (m->showbar) { m->wh = m->wh - vertpad - bh; m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; @@ -95,5 +95,5 @@ updateholdbarpos(Monitor *m) m->wy = m->topbar ? m->wy + bh : m->wy; } else m->by = -bh; - #endif // EXTRABAR_PATCH + #endif // BAR_EXTRABAR_PATCH } diff --git a/patch/horizgrid.c b/patch/horizgrid.c deleted file mode 100644 index 48f66ab..0000000 --- a/patch/horizgrid.c +++ /dev/null @@ -1,103 +0,0 @@ -void -horizgrid(Monitor *m) { - Client *c; - unsigned int n, i; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - int ntop; - float mfacts = 0, sfacts = 0; - int mrest, srest, mtotal = 0, stotal = 0; - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - if (n == 0) - return; - - if (n <= 2) - ntop = n; - else { - ntop = n / 2; - } - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - sh = mh = m->wh - 2*oh; - sw = mw = m->ww - 2*ov; - - if (n > ntop) { - sh = (mh - ih) / 2; - mh = mh - ih - sh; - sy = my + mh + ih; - mw = m->ww - 2*ov - iv * (ntop - 1); - sw = m->ww - 2*ov - iv * (n - ntop - 1); - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (n > ntop) { - sh = mh / 2; - mh = mh - sh; - sy = my + mh; - } - #endif // VANITYGAPS_PATCH - - /* calculate facts */ - #if CFACTS_PATCH - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < ntop) - mfacts += c->cfact; - else - sfacts += c->cfact; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < ntop) - mtotal += mh * (c->cfact / mfacts); - else - stotal += sw * (c->cfact / sfacts); - #else - mfacts = ntop; - sfacts = n - ntop; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < ntop) - mtotal += mh / mfacts; - else - stotal += sw / sfacts; - #endif // CFACTS_PATCH - - mrest = mh - mtotal; - srest = sw - stotal; - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < ntop) { - #if CFACTS_PATCH - resize(c, mx, my, mw * (c->cfact / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #else - resize(c, mx, my, mw / mfacts + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - mx += WIDTH(c) + iv; - #else - mx += WIDTH(c); - #endif // VANITYGAPS_PATCH - } else { - #if CFACTS_PATCH - resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #else - resize(c, sx, sy, sw / sfacts + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sx += WIDTH(c) + iv; - #else - sx += WIDTH(c); - #endif // VANITYGAPS_PATCH - } -} \ No newline at end of file diff --git a/patch/horizgrid.h b/patch/horizgrid.h deleted file mode 100644 index 71a57fb..0000000 --- a/patch/horizgrid.h +++ /dev/null @@ -1 +0,0 @@ -static void horizgrid(Monitor *m); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index d574fd6..5cde652 100644 --- a/patch/include.c +++ b/patch/include.c @@ -1,19 +1,57 @@ -/* Patches */ -#if ALPHA_PATCH -#include "alpha.c" +/* Bar functionality */ +#if BAR_ALPHA_PATCH +#include "bar_alpha.c" #endif -#if ALTERNATIVE_TAGS_PATCH -#include "alternativetags.c" +#if BAR_ALTERNATIVE_TAGS_PATCH +#include "bar_alternativetags.c" #endif +#if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH +#include "bar_dwmblocks.c" +#endif +#if BAR_LTSYMBOL_PATCH +#include "bar_ltsymbol.c" +#endif +#if BAR_STATUS_PATCH +#include "bar_status.c" +#endif +#if BAR_STATUS2D_PATCH +#include "bar_status2d.c" +#if BAR_EXTRABAR_PATCH +#include "bar_status2d_eb.c" +#endif // BAR_EXTRABAR_PATCH +#endif +#if BAR_STATUSBUTTON_PATCH +#include "bar_statusbutton.c" +#endif +#if BAR_STATUSCMD_PATCH +#include "bar_statuscmd.c" +#endif +#if BAR_TAGS_PATCH +#include "bar_tags.c" +#endif +#if BAR_TAGGRID_PATCH +#include "bar_taggrid.c" +#endif +#if BAR_WINTITLE_PATCH +#include "bar_wintitle.c" +#endif +#if BAR_FANCYBAR_PATCH +#include "bar_fancybar.c" +#endif +#if BAR_AWESOMEBAR_PATCH +#include "bar_awesomebar.c" +#endif +#if BAR_SYSTRAY_PATCH +#include "bar_systray.c" +#endif + +/* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH #include "attachx.c" #endif #if AUTOSTART_PATCH #include "autostart.c" #endif -#if AWESOMEBAR_PATCH -#include "awesomebar.c" -#endif #if CFACTS_PATCH #include "cfacts.c" #endif @@ -29,15 +67,12 @@ #if DRAGCFACT_PATCH && CFACTS_PATCH #include "dragcfact.c" #endif -#if DWMBLOCKS_PATCH && STATUSCMD_PATCH -#include "dwmblocks.c" -#endif #if DWMC_PATCH #include "dwmc.c" #elif FSIGNAL_PATCH #include "fsignal.c" #endif -#if EWMHTAGS_PATCH +#if BAR_EWMHTAGS_PATCH #include "ewmhtags.c" #endif #if EXRESIZE_PATCH @@ -58,7 +93,7 @@ #if FULLSCREEN_PATCH #include "fullscreen.c" #endif -#if HOLDBAR_PATCH +#if BAR_HOLDBAR_PATCH #include "holdbar.c" #endif #if INPLACEROTATE_PATCH @@ -131,21 +166,12 @@ #if STACKER_PATCH #include "stacker.c" #endif -#if STATUS2D_PATCH && !STATUSCOLORS_PATCH -#include "status2d.c" -#endif -#if STATUSCOLORS_PATCH +#if BAR_STATUSCOLORS_PATCH #include "statuscolors.c" #endif -#if STATUSCMD_PATCH -#include "statuscmd.c" -#endif #if STICKY_PATCH #include "sticky.c" #endif -#if SYSTRAY_PATCH -#include "systray.c" -#endif #if SWALLOW_PATCH #include "swallow.c" #endif @@ -188,7 +214,7 @@ #if VANITYGAPS_PATCH #include "vanitygaps.c" #endif -#if VTCOLORS_PATCH +#if BAR_VTCOLORS_PATCH #include "vtcolors.c" #endif #if WARP_PATCH @@ -200,7 +226,7 @@ #if ZOOMSWAP_PATCH #include "zoomswap.c" #endif -#if XRDB_PATCH && !VTCOLORS_PATCH +#if XRDB_PATCH && !BAR_VTCOLORS_PATCH #include "xrdb.c" #endif #if DRAGMFACT_PATCH @@ -211,44 +237,44 @@ #include "layout_facts.c" #endif #if BSTACK_LAYOUT -#include "bstack.c" +#include "layout_bstack.c" #endif #if BSTACKHORIZ_LAYOUT -#include "bstackhoriz.c" +#include "layout_bstackhoriz.c" #endif #if CENTEREDMASTER_LAYOUT -#include "centeredmaster.c" +#include "layout_centeredmaster.c" #endif #if CENTEREDFLOATINGMASTER_LAYOUT -#include "centeredfloatingmaster.c" +#include "layout_centeredfloatingmaster.c" #endif #if COLUMNS_LAYOUT -#include "columns.c" +#include "layout_columns.c" #endif #if DECK_LAYOUT -#include "deck.c" +#include "layout_deck.c" #endif #if FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT -#include "fibonacci.c" +#include "layout_fibonacci.c" #endif #if FLEXTILE_DELUXE_LAYOUT -#include "flextile-deluxe.c" +#include "layout_flextile-deluxe.c" #endif #if GAPPLESSGRID_LAYOUT -#include "gapplessgrid.c" +#include "layout_gapplessgrid.c" #endif #if GRIDMODE_LAYOUT -#include "grid.c" +#include "layout_grid.c" #endif #if HORIZGRID_LAYOUT -#include "horizgrid.c" +#include "layout_horizgrid.c" #endif #if MONOCLE_LAYOUT -#include "monocle.c" +#include "layout_monocle.c" #endif #if NROWGRID_LAYOUT -#include "nrowgrid.c" +#include "layout_nrowgrid.c" #endif #if TILE_LAYOUT -#include "tile.c" -#endif +#include "layout_tile.c" +#endif \ No newline at end of file diff --git a/patch/include.h b/patch/include.h index 97628aa..49ce915 100644 --- a/patch/include.h +++ b/patch/include.h @@ -1,19 +1,57 @@ -/* Patches */ -#if ALPHA_PATCH -#include "alpha.h" +/* Bar functionality */ +#if BAR_ALPHA_PATCH +#include "bar_alpha.h" #endif -#if ALTERNATIVE_TAGS_PATCH -#include "alternativetags.h" +#if BAR_ALTERNATIVE_TAGS_PATCH +#include "bar_alternativetags.h" #endif +#if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH +#include "bar_dwmblocks.h" +#endif +#if BAR_LTSYMBOL_PATCH +#include "bar_ltsymbol.h" +#endif +#if BAR_STATUS_PATCH +#include "bar_status.h" +#endif +#if BAR_STATUS2D_PATCH +#include "bar_status2d.h" +#if BAR_EXTRABAR_PATCH +#include "bar_status2d_eb.h" +#endif // BAR_EXTRABAR_PATCH +#endif +#if BAR_STATUSBUTTON_PATCH +#include "bar_statusbutton.h" +#endif +#if BAR_STATUSCMD_PATCH +#include "bar_statuscmd.h" +#endif +#if BAR_TAGS_PATCH +#include "bar_tags.h" +#endif +#if BAR_TAGGRID_PATCH +#include "bar_taggrid.h" +#endif +#if BAR_WINTITLE_PATCH +#include "bar_wintitle.h" +#endif +#if BAR_FANCYBAR_PATCH +#include "bar_fancybar.h" +#endif +#if BAR_AWESOMEBAR_PATCH +#include "bar_awesomebar.h" +#endif +#if BAR_SYSTRAY_PATCH +#include "bar_systray.h" +#endif + +/* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH #include "attachx.h" #endif #if AUTOSTART_PATCH #include "autostart.h" #endif -#if AWESOMEBAR_PATCH -#include "awesomebar.h" -#endif #if CFACTS_PATCH #include "cfacts.h" #endif @@ -32,15 +70,12 @@ #if DRAGMFACT_PATCH #include "dragmfact.h" #endif -#if DWMBLOCKS_PATCH && STATUSCMD_PATCH -#include "dwmblocks.h" -#endif #if DWMC_PATCH #include "dwmc.h" #elif FSIGNAL_PATCH #include "fsignal.h" #endif -#if EWMHTAGS_PATCH +#if BAR_EWMHTAGS_PATCH #include "ewmhtags.h" #endif #if EXRESIZE_PATCH @@ -61,7 +96,7 @@ #if FULLSCREEN_PATCH #include "fullscreen.h" #endif -#if HOLDBAR_PATCH +#if BAR_HOLDBAR_PATCH #include "holdbar.h" #endif #if INPLACEROTATE_PATCH @@ -134,18 +169,9 @@ #if STACKER_PATCH #include "stacker.h" #endif -#if STATUS2D_PATCH && !STATUSCOLORS_PATCH -#include "status2d.h" -#endif -#if STATUSCMD_PATCH -#include "statuscmd.h" -#endif #if STICKY_PATCH #include "sticky.h" #endif -#if SYSTRAY_PATCH -#include "systray.h" -#endif #if SWALLOW_PATCH #include "swallow.h" #endif @@ -188,7 +214,7 @@ #if VANITYGAPS_PATCH #include "vanitygaps.h" #endif -#if VTCOLORS_PATCH +#if BAR_VTCOLORS_PATCH #include "vtcolors.h" #endif #if WARP_PATCH @@ -200,49 +226,49 @@ #if ZOOMSWAP_PATCH #include "zoomswap.h" #endif -#if XRDB_PATCH && !VTCOLORS_PATCH +#if XRDB_PATCH && !BAR_VTCOLORS_PATCH #include "xrdb.h" #endif /* Layouts */ #if BSTACK_LAYOUT -#include "bstack.h" +#include "layout_bstack.h" #endif #if BSTACKHORIZ_LAYOUT -#include "bstackhoriz.h" +#include "layout_bstackhoriz.h" #endif #if CENTEREDMASTER_LAYOUT -#include "centeredmaster.h" +#include "layout_centeredmaster.h" #endif #if CENTEREDFLOATINGMASTER_LAYOUT -#include "centeredfloatingmaster.h" +#include "layout_centeredfloatingmaster.h" #endif #if COLUMNS_LAYOUT -#include "columns.h" +#include "layout_columns.h" #endif #if DECK_LAYOUT -#include "deck.h" +#include "layout_deck.h" #endif #if FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT -#include "fibonacci.h" +#include "layout_fibonacci.h" #endif #if FLEXTILE_DELUXE_LAYOUT -#include "flextile-deluxe.h" +#include "layout_flextile-deluxe.h" #endif #if GAPPLESSGRID_LAYOUT -#include "gapplessgrid.h" +#include "layout_gapplessgrid.h" #endif #if GRIDMODE_LAYOUT -#include "grid.h" +#include "layout_grid.h" #endif #if HORIZGRID_LAYOUT -#include "horizgrid.h" +#include "layout_horizgrid.h" #endif #if MONOCLE_LAYOUT -#include "monocle.h" +#include "layout_monocle.h" #endif #if NROWGRID_LAYOUT -#include "nrowgrid.h" +#include "layout_nrowgrid.h" #endif #if TILE_LAYOUT -#include "tile.h" -#endif +#include "layout_tile.h" +#endif \ No newline at end of file diff --git a/patch/killunsel.c b/patch/killunsel.c index 1e15d2b..774847b 100644 --- a/patch/killunsel.c +++ b/patch/killunsel.c @@ -8,11 +8,11 @@ killunsel(const Arg *arg) for (i = selmon->clients; i; i = i->next) { if (ISVISIBLE(i) && i != selmon->sel) { - #if SYSTRAY_PATCH + #if BAR_SYSTRAY_PATCH if (!sendevent(i->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0, 0, 0)) #else if (!sendevent(i, wmatom[WMDelete])) - #endif // SYSTRAY_PATCH + #endif // BAR_SYSTRAY_PATCH { XGrabServer(dpy); XSetErrorHandler(xerrordummy); diff --git a/patch/layout_bstack.c b/patch/layout_bstack.c new file mode 100644 index 0000000..be06647 --- /dev/null +++ b/patch/layout_bstack.c @@ -0,0 +1,74 @@ +static void +bstack(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); + sw = m->ww - 2*ov - iv * (n - m->nmaster - 1); + + if (m->nmaster && n > m->nmaster) { + sh = (mh - ih) * (1 - m->mfact); + mh = (mh - ih) * m->mfact; + sx = mx; + sy = my + mh + ih; + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + sh = mh * (1 - m->mfact); + mh = mh * m->mfact; + sy = my + mh; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + #if CFACTS_PATCH + resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv; + #else + mx += WIDTH(c); + #endif + } else { + #if CFACTS_PATCH + resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #else + resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sx += WIDTH(c) + iv; + #else + sx += WIDTH(c); + #endif + } + } +} \ No newline at end of file diff --git a/patch/layout_bstack.h b/patch/layout_bstack.h new file mode 100644 index 0000000..56c99ff --- /dev/null +++ b/patch/layout_bstack.h @@ -0,0 +1 @@ +static void bstack(Monitor *m); \ No newline at end of file diff --git a/patch/layout_bstackhoriz.c b/patch/layout_bstackhoriz.c new file mode 100644 index 0000000..0f9042f --- /dev/null +++ b/patch/layout_bstackhoriz.c @@ -0,0 +1,76 @@ +static void +bstackhoriz(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + mh = m->wh - 2*oh; + sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); + mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); + sw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sh = (mh - ih) * (1 - m->mfact); + mh = (mh - ih) * m->mfact; + sy = my + mh + ih; + sh = m->wh - mh - 2*oh - ih * (n - m->nmaster); + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + sh = mh * (1 - m->mfact); + mh = mh * m->mfact; + sy = my + mh; + sh = m->wh - mh; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + #if CFACTS_PATCH + resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv; + #else + mx += WIDTH(c); + #endif + } else { + #if CFACTS_PATCH + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sy += HEIGHT(c) + ih; + #else + sy += HEIGHT(c); + #endif + } + } +} \ No newline at end of file diff --git a/patch/layout_bstackhoriz.h b/patch/layout_bstackhoriz.h new file mode 100644 index 0000000..8dd0ebd --- /dev/null +++ b/patch/layout_bstackhoriz.h @@ -0,0 +1 @@ +static void bstackhoriz(Monitor *m); \ No newline at end of file diff --git a/patch/layout_centeredfloatingmaster.c b/patch/layout_centeredfloatingmaster.c new file mode 100644 index 0000000..756b41f --- /dev/null +++ b/patch/layout_centeredfloatingmaster.c @@ -0,0 +1,94 @@ +void +centeredfloatingmaster(Monitor *m) +{ + unsigned int i, n; + float mfacts, sfacts; + int mrest, srest; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + Client *c; + + #if VANITYGAPS_PATCH + float mivf = 1.0; // master inner vertical gap factor + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + mw = m->ww - 2*ov - iv*(n - 1); + sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); + + if (m->nmaster && n > m->nmaster) { + mivf = 0.8; + /* go mfact box in the center if more than nmaster clients */ + if (m->ww > m->wh) { + mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); + mh = m->wh * 0.9; + } else { + mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); + mh = m->wh * m->mfact; + } + mx = m->wx + (m->ww - mw) / 2; + my = m->wy + (m->wh - mh - 2*oh) / 2; + + sx = m->wx + ov; + sy = m->wy + oh; + sh = m->wh - 2*oh; + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (m->ww > m->wh) { + mw = m->ww * m->mfact; + mh = m->wh * 0.9; + } else { + mw = m->ww * 0.9; + mh = m->wh * m->mfact; + } + mx = m->wx + (m->ww - mw) / 2; + my = m->wy + (m->wh - mh) / 2; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked horizontally, in the center of the screen */ + #if CFACTS_PATCH + resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv*mivf; + #else + mx += WIDTH(c); + #endif + } else { + /* stack clients are stacked horizontally */ + #if CFACTS_PATCH + resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #else + resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sx += WIDTH(c) + iv; + #else + sx += WIDTH(c); + #endif + } +} diff --git a/patch/layout_centeredfloatingmaster.h b/patch/layout_centeredfloatingmaster.h new file mode 100644 index 0000000..e4147b3 --- /dev/null +++ b/patch/layout_centeredfloatingmaster.h @@ -0,0 +1 @@ +static void centeredfloatingmaster(Monitor *m); \ No newline at end of file diff --git a/patch/layout_centeredmaster.c b/patch/layout_centeredmaster.c new file mode 100644 index 0000000..a72eb07 --- /dev/null +++ b/patch/layout_centeredmaster.c @@ -0,0 +1,159 @@ +void +centeredmaster(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int lx = 0, ly = 0, lw = 0, lh = 0; + int rx = 0, ry = 0, rw = 0, rh = 0; + float mfacts = 0, lfacts = 0, rfacts = 0; + int mtotal = 0, ltotal = 0, rtotal = 0; + int mrest = 0, lrest = 0, rrest = 0; + Client *c; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + /* initialize areas */ + #if VANITYGAPS_PATCH + mx = m->wx + ov; + my = m->wy + oh; + mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1); + mw = m->ww - 2*ov; + lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1); + rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1)); + + if (m->nmaster && n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (n - m->nmaster > 1) { + /* ||<-S->|<---M--->|<-S->|| */ + mw = (m->ww - 2*ov - 2*iv) * m->mfact; + lw = (m->ww - mw - 2*ov - 2*iv) / 2; + mx += lw + iv; + } else { + /* ||<---M--->|<-S->|| */ + mw = (mw - iv) * m->mfact; + lw = m->ww - mw - iv - 2*ov; + } + rw = lw; + lx = m->wx + ov; + ly = m->wy + oh; + rx = mx + mw + iv; + ry = m->wy + oh; + } + #else + mx = m->wx; + my = m->wy; + mh = m->wh; + mw = m->ww; + lh = m->wh; + rh = m->wh; + + if (m->nmaster && n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (n - m->nmaster > 1) { + /* ||<-S->|<---M--->|<-S->|| */ + mw = m->ww * m->mfact; + lw = (m->ww - mw) / 2; + mx += lw; + } else { + /* ||<---M--->|<-S->|| */ + mw = mw * m->mfact; + lw = m->ww - mw; + } + rw = lw; + lx = m->wx; + ly = m->wy; + rx = mx + mw; + ry = m->wy; + } + #endif // VANITYGAPS_PATCH + + /* calculate facts */ + #if CFACTS_PATCH + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (!m->nmaster || n < m->nmaster) + mfacts += c->cfact; // total factor of master area + else if ((n - m->nmaster) % 2) + lfacts += c->cfact; // total factor of left hand stack area + else + rfacts += c->cfact; // total factor of right hand stack area + } + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) + if (!m->nmaster || n < m->nmaster) + mtotal += mh / mfacts; + else if ((n - m->nmaster) % 2) + ltotal += lh * (c->cfact / lfacts); + else + rtotal += rh * (c->cfact / rfacts); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (!m->nmaster || n < m->nmaster) + mfacts += 1; + else if ((n - m->nmaster) % 2) + lfacts += 1; // total factor of left hand stack area + else + rfacts += 1; // total factor of right hand stack area + } + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) + if (!m->nmaster || n < m->nmaster) + mtotal += mh / mfacts; + else if ((n - m->nmaster) % 2) + ltotal += lh / lfacts; + else + rtotal += rh / rfacts; + #endif // CFACTS_PATCH + + mrest = mh - mtotal; + lrest = lh - ltotal; + rrest = rh - rtotal; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (!m->nmaster || i < m->nmaster) { + /* nmaster clients are stacked vertically, in the center of the screen */ + #if CFACTS_PATCH + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + my += HEIGHT(c) + ih; + #else + my += HEIGHT(c); + #endif + } else { + /* stack clients are stacked vertically */ + if ((i - m->nmaster) % 2 ) { + #if CFACTS_PATCH + resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) * c->cfact + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + ly += HEIGHT(c) + ih; + #else + ly += HEIGHT(c); + #endif + } else { + #if CFACTS_PATCH + resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) * c->cfact + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + ry += HEIGHT(c) + ih; + #else + ry += HEIGHT(c); + #endif + } + } + } +} \ No newline at end of file diff --git a/patch/layout_centeredmaster.h b/patch/layout_centeredmaster.h new file mode 100644 index 0000000..b047212 --- /dev/null +++ b/patch/layout_centeredmaster.h @@ -0,0 +1 @@ +static void centeredmaster(Monitor *m); \ No newline at end of file diff --git a/patch/layout_columns.c b/patch/layout_columns.c new file mode 100644 index 0000000..bcdaa11 --- /dev/null +++ b/patch/layout_columns.c @@ -0,0 +1,73 @@ +static void +col(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + mh = m->wh - 2*oh; + sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); + mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); + sw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sw = (mw - iv) * (1 - m->mfact); + mw = (mw - iv) * m->mfact; + sx = mx + mw + iv * m->nmaster; + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + sw = mw * (1 - m->mfact); + mw = mw * m->mfact; + sx = mx + mw; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + #if CFACTS_PATCH + resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv; + #else + mx += WIDTH(c); + #endif + } else { + #if CFACTS_PATCH + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sy += HEIGHT(c) + ih; + #else + sy += HEIGHT(c); + #endif + } +} \ No newline at end of file diff --git a/patch/layout_columns.h b/patch/layout_columns.h new file mode 100644 index 0000000..8f64a09 --- /dev/null +++ b/patch/layout_columns.h @@ -0,0 +1 @@ +static void col(Monitor *); \ No newline at end of file diff --git a/patch/layout_deck.c b/patch/layout_deck.c new file mode 100644 index 0000000..6f2027d --- /dev/null +++ b/patch/layout_deck.c @@ -0,0 +1,66 @@ +static void +deck(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); + sw = mw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sw = (mw - iv) * (1 - m->mfact); + mw = (mw - iv) * m->mfact; + sx = mx + mw + iv; + sh = m->wh - 2*oh; + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + sw = mw * (1 - m->mfact); + mw = mw * m->mfact; + sx = mx + mw; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); + + if (n - m->nmaster > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + #if CFACTS_PATCH + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + my += HEIGHT(c) + ih; + #else + my += HEIGHT(c); + #endif + } else { + resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0); + } +} \ No newline at end of file diff --git a/patch/layout_deck.h b/patch/layout_deck.h new file mode 100644 index 0000000..abedeb2 --- /dev/null +++ b/patch/layout_deck.h @@ -0,0 +1 @@ +static void deck(Monitor *m); \ No newline at end of file diff --git a/patch/layout_fibonacci.c b/patch/layout_fibonacci.c new file mode 100644 index 0000000..87a1bdf --- /dev/null +++ b/patch/layout_fibonacci.c @@ -0,0 +1,190 @@ +#if VANITYGAPS_PATCH +void +fibonacci(Monitor *m, int s) +{ + unsigned int i, n; + int nx, ny, nw, nh; + int oh, ov, ih, iv; + int nv, hrest = 0, wrest = 0, r = 1; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + nx = m->wx + ov; + ny = oh; + nw = m->ww - 2*ov; + nh = m->wh - 2*oh; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { + if (r) { + if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw)) + || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) { + r = 0; + } + if (r && i < n - 1) { + if (i % 2) { + nv = (nh - ih) / 2; + hrest = nh - 2*nv - ih; + nh = nv; + } else { + nv = (nw - iv) / 2; + wrest = nw - 2*nv - iv; + nw = nv; + } + + if ((i % 4) == 2 && !s) + nx += nw + iv; + else if ((i % 4) == 3 && !s) + ny += nh + ih; + } + + if ((i % 4) == 0) { + if (s) { + ny += nh + ih; + nh += hrest; + } + else { + nh -= hrest; + ny -= nh + ih; + } + } + else if ((i % 4) == 1) { + nx += nw + iv; + nw += wrest; + } + else if ((i % 4) == 2) { + ny += nh + ih; + nh += hrest; + if (i < n - 1) + nw += wrest; + } + else if ((i % 4) == 3) { + if (s) { + nx += nw + iv; + nw -= wrest; + } else { + nw -= wrest; + nx -= nw + iv; + nh += hrest; + } + } + if (i == 0) { + if (n != 1) { + nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact); + wrest = 0; + } + ny = m->wy + oh; + } + else if (i == 1) + nw = m->ww - nw - iv - 2*ov; + i++; + } + + resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); + } +} +#else +void +fibonacci(Monitor *m, int s) +{ + unsigned int i, n; + int nx, ny, nw, nh; + int nv, hrest = 0, wrest = 0, r = 1; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + nx = m->wx; + ny = m->wy; + nw = m->ww; + nh = m->wh; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { + if (r) { + if ((i % 2 && nh / 2 <= (bh + 2*c->bw)) + || (!(i % 2) && nw / 2 <= (bh + 2*c->bw))) { + r = 0; + } + if (r && i < n - 1) { + if (i % 2) { + nv = nh / 2; + hrest = nh - 2*nv; + nh = nv; + } else { + nv = nw / 2; + wrest = nw - 2*nv; + nw = nv; + } + + if ((i % 4) == 2 && !s) + nx += nw; + else if ((i % 4) == 3 && !s) + ny += nh; + } + + if ((i % 4) == 0) { + if (s) { + ny += nh; + nh += hrest; + } + else { + nh -= hrest; + ny -= nh; + } + } + else if ((i % 4) == 1) { + nx += nw; + nw += wrest; + } + else if ((i % 4) == 2) { + ny += nh; + nh += hrest; + if (i < n - 1) + nw += wrest; + } + else if ((i % 4) == 3) { + if (s) { + nx += nw; + nw -= wrest; + } else { + nw -= wrest; + nx -= nw; + nh += hrest; + } + } + if (i == 0) { + if (n != 1) { + nw = m->ww - m->ww * (1 - m->mfact); + wrest = 0; + } + ny = m->wy; + } + else if (i == 1) + nw = m->ww - nw; + i++; + } + + resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); + } +} +#endif + +#if FIBONACCI_DWINDLE_LAYOUT +static void +dwindle(Monitor *m) +{ + fibonacci(m, 1); +} +#endif + +#if FIBONACCI_SPIRAL_LAYOUT +static void +spiral(Monitor *m) +{ + fibonacci(m, 0); +} +#endif diff --git a/patch/layout_fibonacci.h b/patch/layout_fibonacci.h new file mode 100644 index 0000000..a15eb76 --- /dev/null +++ b/patch/layout_fibonacci.h @@ -0,0 +1,7 @@ +#if FIBONACCI_DWINDLE_LAYOUT +static void dwindle(Monitor *m); +#endif // FIBONACCI_DWINDLE_LAYOUT +static void fibonacci(Monitor *m, int s); +#if FIBONACCI_SPIRAL_LAYOUT +static void spiral(Monitor *m); +#endif // FIBONACCI_SPIRAL_LAYOUT \ No newline at end of file diff --git a/patch/layout_flextile-deluxe.c b/patch/layout_flextile-deluxe.c new file mode 100644 index 0000000..a877c92 --- /dev/null +++ b/patch/layout_flextile-deluxe.c @@ -0,0 +1,770 @@ +typedef struct { + void (*arrange)(Monitor *, int, int, int, int, int, int, int); +} LayoutArranger; + +typedef struct { + void (*arrange)(Monitor *, int, int, int, int, int, int, int, int, int); +} TileArranger; + +static const LayoutArranger flexlayouts[] = { + { layout_no_split }, + { layout_split_vertical }, + { layout_split_horizontal }, + { layout_split_centered_vertical }, + { layout_split_centered_horizontal }, + { layout_split_vertical_dual_stack }, + { layout_split_horizontal_dual_stack }, + { layout_floating_master }, + { layout_split_vertical_fixed }, + { layout_split_horizontal_fixed }, + { layout_split_centered_vertical_fixed }, + { layout_split_centered_horizontal_fixed }, + { layout_split_vertical_dual_stack_fixed }, + { layout_split_horizontal_dual_stack_fixed }, + { layout_floating_master_fixed }, +}; + +static const TileArranger flextiles[] = { + { arrange_top_to_bottom }, + { arrange_left_to_right }, + { arrange_monocle }, + { arrange_gapplessgrid }, + { arrange_gapplessgrid_alt1 }, + { arrange_gapplessgrid_alt2 }, + { arrange_gridmode }, + { arrange_horizgrid }, + { arrange_dwindle }, + { arrange_spiral }, +}; + +static void +getfactsforrange(Monitor *m, int an, int ai, int size, int *rest, float *fact) +{ + int i; + float facts; + Client *c; + int total = 0; + + facts = 0; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i >= ai && i < (ai + an)) + #if CFACTS_PATCH + facts += c->cfact; + #else + facts += 1; + #endif // CFACTS_PATCH + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i >= ai && i < (ai + an)) + #if CFACTS_PATCH + total += size * (c->cfact / facts); + #else + total += size / facts; + #endif // CFACTS_PATCH + + *rest = size - total; + *fact = facts; +} + +#if DWMC_PATCH +static void +setlayoutaxisex(const Arg *arg) +{ + int axis, arr; + + axis = arg->i & 0x3; // lower two bytes indicates layout, master or stack1-2 + arr = ((arg->i & 0xFC) >> 2); // remaining six upper bytes indicates arrangement + + if ((axis == 0 && abs(arr) > LAYOUT_LAST) + || (axis > 0 && (arr > AXIS_LAST || arr < 0))) + arr = 0; + + selmon->ltaxis[axis] = arr; + #if PERTAG_PATCH + selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis]; + #endif // PERTAG_PATCH + arrange(selmon); +} +#endif // DWMC_PATCH + +static void +layout_no_split(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, n, 0); +} + +static void +layout_split_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (m->nmaster && n > m->nmaster) { + layout_split_vertical_fixed(m, x, y, h, w, ih, iv, n); + } else { + layout_no_split(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sw, sx; + + sw = (w - iv) * (1 - m->mfact); + w = (w - iv) * m->mfact; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sx = x; + x += sw + iv; + } else { + sx = x + w + iv; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, h, sw, ih, iv, n, n - m->nmaster, m->nmaster); +} + +static void +layout_split_vertical_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (!m->nmaster || n <= m->nmaster) { + layout_no_split(m, x, y, h, w, ih, iv, n); + } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { + layout_split_vertical(m, x, y, h, w, ih, iv, n); + } else { + layout_split_vertical_dual_stack_fixed(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_vertical_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sh, sw, sx, oy, sc; + + if (m->nstack) + sc = m->nstack; + else + sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); + + sw = (w - iv) * (1 - m->mfact); + sh = (h - ih) / 2; + w = (w - iv) * m->mfact; + oy = y + sh + ih; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sx = x; + x += sw + iv; + } else { + sx = x + w + iv; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, sh, sw, ih, iv, n, sc, m->nmaster); + (&flextiles[m->ltaxis[STACK2]])->arrange(m, sx, oy, sh, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); +} + +static void +layout_split_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (m->nmaster && n > m->nmaster) { + layout_split_horizontal_fixed(m, x, y, h, w, ih, iv, n); + } else { + layout_no_split(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sh, sy; + + sh = (h - ih) * (1 - m->mfact); + h = (h - ih) * m->mfact; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sy = y; + y += sh + ih; + } else { + sy = y + h + ih; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, w, ih, iv, n, n - m->nmaster, m->nmaster); +} + +static void +layout_split_horizontal_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (!m->nmaster || n <= m->nmaster) { + layout_no_split(m, x, y, h, w, ih, iv, n); + } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { + layout_split_horizontal(m, x, y, h, w, ih, iv, n); + } else { + layout_split_horizontal_dual_stack_fixed(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_horizontal_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sh, sy, ox, sc; + + if (m->nstack) + sc = m->nstack; + else + sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); + + sh = (h - ih) * (1 - m->mfact); + h = (h - ih) * m->mfact; + sw = (w - iv) / 2; + ox = x + sw + iv; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sy = y; + y += sh + ih; + } else { + sy = y + h + ih; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, sw, ih, iv, n, sc, m->nmaster); + (&flextiles[m->ltaxis[STACK2]])->arrange(m, ox, sy, sh, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); +} + +static void +layout_split_centered_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (!m->nmaster || n <= m->nmaster) { + layout_no_split(m, x, y, h, w, ih, iv, n); + } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { + layout_split_vertical(m, x, y, h, w, ih, iv, n); + } else { + layout_split_centered_vertical_fixed(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_centered_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sw, sx, ox, sc; + + if (m->nstack) + sc = m->nstack; + else + sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); + + sw = (w - 2*iv) * (1 - m->mfact) / 2; + w = (w - 2*iv) * m->mfact; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sx = x; + x += sw + iv; + ox = x + w + iv; + } else { + ox = x; + x += sw + iv; + sx = x + w + iv; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, sx, y, h, sw, ih, iv, n, sc, m->nmaster); + (&flextiles[m->ltaxis[STACK2]])->arrange(m, ox, y, h, sw, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); +} + +static void +layout_split_centered_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (!m->nmaster || n <= m->nmaster) { + layout_no_split(m, x, y, h, w, ih, iv, n); + } else if (n <= m->nmaster + (m->nstack ? m->nstack : 1)) { + layout_split_horizontal(m, x, y, h, w, ih, iv, n); + } else { + layout_split_centered_horizontal_fixed(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_split_centered_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int sh, sy, oy, sc; + + if (m->nstack) + sc = m->nstack; + else + sc = (n - m->nmaster) / 2 + ((n - m->nmaster) % 2 > 0 ? 1 : 0); + + sh = (h - 2*ih) * (1 - m->mfact) / 2; + h = (h - 2*ih) * m->mfact; + if (m->ltaxis[LAYOUT] < 0) { // mirror + sy = y; + y += sh + ih; + oy = y + h + ih; + } else { + oy = y; + y += sh + ih; + sy = y + h + ih; + } + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, h, w, ih, iv, n, m->nmaster, 0); + (&flextiles[m->ltaxis[STACK]])->arrange(m, x, sy, sh, w, ih, iv, n, sc, m->nmaster); + (&flextiles[m->ltaxis[STACK2]])->arrange(m, x, oy, sh, w, ih, iv, n, n - m->nmaster - sc, m->nmaster + sc); +} + +static void +layout_floating_master(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + /* Split master into master + stack if we have enough clients */ + if (!m->nmaster || n <= m->nmaster) { + layout_no_split(m, x, y, h, w, ih, iv, n); + } else { + layout_floating_master_fixed(m, x, y, h, w, ih, iv, n); + } +} + +static void +layout_floating_master_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n) +{ + int mh, mw; + + /* Draw stack area first */ + (&flextiles[m->ltaxis[STACK]])->arrange(m, x, y, h, w, ih, iv, n, n - m->nmaster, m->nmaster); + + if (w > h) { + mw = w * m->mfact; + mh = h * 0.9; + } else { + mw = w * 0.9; + mh = h * m->mfact; + } + x = x + (w - mw) / 2; + y = y + (h - mh) / 2; + + (&flextiles[m->ltaxis[MASTER]])->arrange(m, x, y, mh, mw, ih, iv, n, m->nmaster, 0); +} + +static void +arrange_left_to_right(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, rest; + float facts, fact = 1; + Client *c; + + if (ai + an > n) + an = n - ai; + + w -= iv * (an - 1); + getfactsforrange(m, an, ai, w, &rest, &facts); + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i >= ai && i < (ai + an)) { + #if CFACTS_PATCH + fact = c->cfact; + #endif // CFACTS_PATCH + resize(c, x, y, w * (fact / facts) + ((i - ai) < rest ? 1 : 0) - (2*c->bw), h - (2*c->bw), 0); + x += WIDTH(c) + iv; + } + } +} + +static void +arrange_top_to_bottom(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, rest; + float facts, fact = 1; + Client *c; + + if (ai + an > n) + an = n - ai; + + h -= ih * (an - 1); + getfactsforrange(m, an, ai, h, &rest, &facts); + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i >= ai && i < (ai + an)) { + #if CFACTS_PATCH + fact = c->cfact; + #endif // CFACTS_PATCH + resize(c, x, y, w - (2*c->bw), h * (fact / facts) + ((i - ai) < rest ? 1 : 0) - (2*c->bw), 0); + y += HEIGHT(c) + ih; + } + } +} + +static void +arrange_monocle(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i; + Client *c; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i >= ai && i < (ai + an)) + resize(c, x, y, w - (2*c->bw), h - (2*c->bw), 0); +} + +static void +arrange_gridmode(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, cols, rows, ch, cw, cx, cy, cc, cr, chrest, cwrest; // counters + Client *c; + + /* grid dimensions */ + for (rows = 0; rows <= an/2; rows++) + if (rows*rows >= an) + break; + cols = (rows && (rows - 1) * rows >= an) ? rows - 1 : rows; + + /* window geoms (cell height/width) */ + ch = (h - ih * (rows - 1)) / (rows ? rows : 1); + cw = (w - iv * (cols - 1)) / (cols ? cols : 1); + chrest = h - ih * (rows - 1) - ch * rows; + cwrest = w - iv * (cols - 1) - cw * cols; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i >= ai && i < (ai + an)) { + cc = ((i - ai) / rows); // client column number + cr = ((i - ai) % rows); // client row number + cx = x + cc * (cw + iv) + MIN(cc, cwrest); + cy = y + cr * (ch + ih) + MIN(cr, chrest); + resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); + } + } +} + +static void +arrange_horizgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int ntop, nbottom, rh, rest; + + /* Exception when there is only one client; don't split into two rows */ + if (an == 1) { + arrange_monocle(m, x, y, h, w, ih, iv, n, an, ai); + return; + } + + ntop = an / 2; + nbottom = an - ntop; + rh = (h - ih) / 2; + rest = h - ih - rh * 2; + arrange_left_to_right(m, x, y, rh + rest, w, ih, iv, n, ntop, ai); + arrange_left_to_right(m, x, y + rh + ih + rest, rh, w, ih, iv, n, nbottom, ai + ntop); +} + +static void +arrange_gapplessgrid(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, cols, rows, ch, cw, cn, rn, cc, rrest, crest; // counters + Client *c; + + /* grid dimensions */ + for (cols = 1; cols <= an/2; cols++) + if (cols*cols >= an) + break; + if (an == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + rows = an/cols; + cn = rn = cc = 0; // reset column no, row no, client count + + ch = (h - ih * (rows - 1)) / rows; + rrest = (h - ih * (rows - 1)) - ch * rows; + cw = (w - iv * (cols - 1)) / cols; + crest = (w - iv * (cols - 1)) - cw * cols; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i >= ai && i < (ai + an)) { + if (cc/rows + 1 > cols - an%cols) { + rows = an/cols + 1; + ch = (h - ih * (rows - 1)) / rows; + rrest = (h - ih * (rows - 1)) - ch * rows; + } + resize(c, + x, + y + rn*(ch + ih) + MIN(rn, rrest), + cw + (cn < crest ? 1 : 0) - 2*c->bw, + ch + (rn < rrest ? 1 : 0) - 2*c->bw, + 0); + rn++; + cc++; + if (rn >= rows) { + rn = 0; + x += cw + ih + (cn < crest ? 1 : 0); + cn++; + } + } + } +} + +/* This version of gappless grid fills rows first */ +static void +arrange_gapplessgrid_alt1(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, cols, rows, rest, ch; + + /* grid dimensions */ + for (cols = 1; cols <= an/2; cols++) + if (cols*cols >= an) + break; + rows = (cols && (cols - 1) * cols >= an) ? cols - 1 : cols; + ch = (h - ih * (rows - 1)) / (rows ? rows : 1); + rest = (h - ih * (rows - 1)) - ch * rows; + + for (i = 0; i < rows; i++) { + arrange_left_to_right(m, x, y, ch + (i < rest ? 1 : 0), w, ih, iv, n, MIN(cols, an - i*cols), ai + i*cols); + y += ch + (i < rest ? 1 : 0) + ih; + } +} + +/* This version of gappless grid fills columns first */ +static void +arrange_gapplessgrid_alt2(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + int i, cols, rows, rest, cw; + + /* grid dimensions */ + for (rows = 0; rows <= an/2; rows++) + if (rows*rows >= an) + break; + cols = (rows && (rows - 1) * rows >= an) ? rows - 1 : rows; + cw = (w - iv * (cols - 1)) / (cols ? cols : 1); + rest = (w - iv * (cols - 1)) - cw * cols; + + for (i = 0; i < cols; i++) { + arrange_top_to_bottom(m, x, y, h, cw + (i < rest ? 1 : 0), ih, iv, n, MIN(rows, an - i*rows), ai + i*rows); + x += cw + (i < rest ? 1 : 0) + iv; + } +} + +static void +arrange_fibonacci(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai, int s) +{ + int i, j, nv, hrest = 0, wrest = 0, nx = x, ny = y, nw = w, nh = h, r = 1; + Client *c; + + for (i = 0, j = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), j++) { + if (j >= ai && j < (ai + an)) { + if (r) { + if ((i % 2 && ((nh - ih) / 2) <= (bh + 2*c->bw)) || (!(i % 2) && ((nw - iv) / 2) <= (bh + 2*c->bw))) { + r = 0; + } + if (r && i < an - 1) { + if (i % 2) { + nv = (nh - ih) / 2; + hrest = nh - 2*nv - ih; + nh = nv; + } else { + nv = (nw - iv) / 2; + wrest = nw - 2*nv - iv; + nw = nv; + } + + if ((i % 4) == 2 && !s) + nx += nw + iv; + else if ((i % 4) == 3 && !s) + ny += nh + ih; + } + if ((i % 4) == 0) { + if (s) { + ny += nh + ih; + nh += hrest; + } + else { + nh -= hrest; + ny -= nh + ih; + } + } + else if ((i % 4) == 1) { + nx += nw + iv; + nw += wrest; + } + else if ((i % 4) == 2) { + ny += nh + ih; + nh += hrest; + if (i < n - 1) + nw += wrest; + } + else if ((i % 4) == 3) { + if (s) { + nx += nw + iv; + nw -= wrest; + } else { + nw -= wrest; + nx -= nw + iv; + nh += hrest; + } + } + if (i == 0) { + if (an != 1) { + nw = (w - iv) - (w - iv) * (1 - m->mfact); + wrest = 0; + } + ny = y; + } + else if (i == 1) + nw = w - nw - iv; + i++; + } + + resize(c, nx, ny, nw - 2 * c->bw, nh - 2*c->bw, False); + } + } +} + +static void +arrange_dwindle(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 1); +} + +static void +arrange_spiral(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n, int an, int ai) +{ + arrange_fibonacci(m, x, y, h, w, ih, iv, n, an, ai, 0); +} + +static void +flextile(Monitor *m) +{ + unsigned int n; + int oh = 0, ov = 0, ih = 0, iv = 0; // gaps outer/inner horizontal/vertical + + #if VANITYGAPS_PATCH + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + Client *c; + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (m->lt[m->sellt]->preset.layout != m->ltaxis[LAYOUT] || + m->lt[m->sellt]->preset.masteraxis != m->ltaxis[MASTER] || + m->lt[m->sellt]->preset.stack1axis != m->ltaxis[STACK] || + m->lt[m->sellt]->preset.stack2axis != m->ltaxis[STACK2]) + setflexsymbols(m, n); + else if (m->lt[m->sellt]->preset.symbolfunc != NULL) + m->lt[m->sellt]->preset.symbolfunc(m, n); + + if (n == 0) + return; + + #if VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH + /* No outer gap if full screen monocle */ + if (abs(m->ltaxis[MASTER]) == MONOCLE && (abs(m->ltaxis[LAYOUT]) == NO_SPLIT || n <= m->nmaster)) { + oh = 0; + ov = 0; + } + #endif // VANITYGAPS_PATCH && !VANITYGAPS_MONOCLE_PATCH + + (&flexlayouts[abs(m->ltaxis[LAYOUT])])->arrange(m, m->wx + ov, m->wy + oh, m->wh - 2*oh, m->ww - 2*ov, ih, iv, n); + return; +} + +static void +setflexsymbols(Monitor *m, unsigned int n) +{ + int l; + char sym1, sym2, sym3; + Client *c; + + if (n == 0) + for (c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + + l = abs(m->ltaxis[LAYOUT]); + if (m->ltaxis[MASTER] == MONOCLE && (l == NO_SPLIT || !m->nmaster || n <= m->nmaster)) { + monoclesymbols(m, n); + return; + } + + if (m->ltaxis[STACK] == MONOCLE && (l == SPLIT_VERTICAL || l == SPLIT_HORIZONTAL_FIXED)) { + decksymbols(m, n); + return; + } + + /* Layout symbols */ + if (l == NO_SPLIT || !m->nmaster) { + sym1 = sym2 = sym3 = (int)tilesymb[m->ltaxis[MASTER]]; + } else { + sym2 = layoutsymb[l]; + if (m->ltaxis[LAYOUT] < 0) { + sym1 = tilesymb[m->ltaxis[STACK]]; + sym3 = tilesymb[m->ltaxis[MASTER]]; + } else { + sym1 = tilesymb[m->ltaxis[MASTER]]; + sym3 = tilesymb[m->ltaxis[STACK]]; + } + } + + snprintf(m->ltsymbol, sizeof m->ltsymbol, "%c%c%c", sym1, sym2, sym3); +} + +static void +monoclesymbols(Monitor *m, unsigned int n) +{ + if (n > 0) + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + else + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[M]"); +} + +static void +decksymbols(Monitor *m, unsigned int n) +{ + if (n > m->nmaster) + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[]%d", n); + else + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[D]"); +} + +/* Mirror layout axis for flextile */ +void +mirrorlayout(const Arg *arg) +{ + if (!selmon->lt[selmon->sellt]->arrange) + return; + selmon->ltaxis[LAYOUT] *= -1; + #if PERTAG_PATCH + selmon->pertag->ltaxis[selmon->pertag->curtag][0] = selmon->ltaxis[LAYOUT]; + #endif // PERTAG_PATCH + arrange(selmon); +} + +/* Rotate layout axis for flextile */ +void +rotatelayoutaxis(const Arg *arg) +{ + int incr = (arg->i > 0 ? 1 : -1); + int axis = abs(arg->i) - 1; + + if (!selmon->lt[selmon->sellt]->arrange) + return; + if (axis == LAYOUT) { + if (selmon->ltaxis[LAYOUT] >= 0) { + selmon->ltaxis[LAYOUT] += incr; + if (selmon->ltaxis[LAYOUT] >= LAYOUT_LAST) + selmon->ltaxis[LAYOUT] = 0; + else if (selmon->ltaxis[LAYOUT] < 0) + selmon->ltaxis[LAYOUT] = LAYOUT_LAST - 1; + } else { + selmon->ltaxis[LAYOUT] -= incr; + if (selmon->ltaxis[LAYOUT] <= -LAYOUT_LAST) + selmon->ltaxis[LAYOUT] = 0; + else if (selmon->ltaxis[LAYOUT] > 0) + selmon->ltaxis[LAYOUT] = -LAYOUT_LAST + 1; + } + } else { + selmon->ltaxis[axis] += incr; + if (selmon->ltaxis[axis] >= AXIS_LAST) + selmon->ltaxis[axis] = 0; + else if (selmon->ltaxis[axis] < 0) + selmon->ltaxis[axis] = AXIS_LAST - 1; + } + #if PERTAG_PATCH + selmon->pertag->ltaxis[selmon->pertag->curtag][axis] = selmon->ltaxis[axis]; + #endif // PERTAG_PATCH + arrange(selmon); + setflexsymbols(selmon, 0); +} + +void +incnstack(const Arg *arg) +{ + #if PERTAG_PATCH + selmon->nstack = selmon->pertag->nstacks[selmon->pertag->curtag] = MAX(selmon->nstack + arg->i, 0); + #else + selmon->nstack = MAX(selmon->nstack + arg->i, 0); + #endif // PERTAG_PATCH + arrange(selmon); +} diff --git a/patch/layout_flextile-deluxe.h b/patch/layout_flextile-deluxe.h new file mode 100644 index 0000000..01bce7b --- /dev/null +++ b/patch/layout_flextile-deluxe.h @@ -0,0 +1,117 @@ +static void flextile(Monitor *m); +static void getfactsforrange(Monitor *m, int an, int ai, int size, int *rest, float *fact); +static void mirrorlayout(const Arg *arg); +static void rotatelayoutaxis(const Arg *arg); +#if DWMC_PATCH +static void setlayoutaxisex(const Arg *arg); +#endif // DWMC_PATCH +static void incnstack(const Arg *arg); + +/* Symbol handlers */ +static void setflexsymbols(Monitor *m, unsigned int n); +static void monoclesymbols(Monitor *m, unsigned int n); +static void decksymbols(Monitor *m, unsigned int n); + +/* Layout split */ +static void layout_no_split(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_vertical_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_horizontal_dual_stack(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_centered_vertical(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_centered_horizontal(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_floating_master(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_vertical_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_horizontal_dual_stack_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_centered_vertical_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_split_centered_horizontal_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); +static void layout_floating_master_fixed(Monitor *m, int x, int y, int h, int w, int ih, int iv, int n); + +/* Layout tile arrangements */ +static void arrange_left_to_right(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_top_to_bottom(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_monocle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_gapplessgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_gapplessgrid_alt1(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_gapplessgrid_alt2(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_gridmode(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_horizgrid(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_dwindle(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); +static void arrange_spiral(Monitor *m, int ax, int ay, int ah, int aw, int ih, int iv, int n, int an, int ai); + +/* Named flextile constants */ +enum { + LAYOUT, // controls overall layout arrangement / split + MASTER, // indicates the tile arrangement for the master area + STACK, // indicates the tile arrangement for the stack area + STACK2, // indicates the tile arrangement for the secondary stack area + LTAXIS_LAST, +}; + +/* Layout arrangements */ +enum { + NO_SPLIT, + SPLIT_VERTICAL, // master stack vertical split + SPLIT_HORIZONTAL, // master stack horizontal split + SPLIT_CENTERED_VERTICAL, // centered master vertical split + SPLIT_CENTERED_HORIZONTAL, // centered master horizontal split + SPLIT_VERTICAL_DUAL_STACK, // master stack vertical split with dual stack + SPLIT_HORIZONTAL_DUAL_STACK, // master stack vertical split with dual stack + FLOATING_MASTER, // (fake) floating master + SPLIT_VERTICAL_FIXED, // master stack vertical fixed split + SPLIT_HORIZONTAL_FIXED, // master stack horizontal fixed split + SPLIT_CENTERED_VERTICAL_FIXED, // centered master vertical fixed split + SPLIT_CENTERED_HORIZONTAL_FIXED, // centered master horizontal fixed split + SPLIT_VERTICAL_DUAL_STACK_FIXED, // master stack vertical split with fixed dual stack + SPLIT_HORIZONTAL_DUAL_STACK_FIXED, // master stack vertical split with fixed dual stack + FLOATING_MASTER_FIXED, // (fake) fixed floating master + LAYOUT_LAST, +}; + +static char layoutsymb[] = { + 32, // " ", + 124, // "|", + 61, // "=", + 94, // "^", + 126, // "~", + 58, // ":", + 59, // ";", + 43, // "+", + 124, // "¦", + 61, // "=", + 94, // "^", + 126, // "~", + 58, // ":", + 59, // ";", + 43, // "+", +}; + +/* Tile arrangements */ +enum { + TOP_TO_BOTTOM, // clients are arranged vertically + LEFT_TO_RIGHT, // clients are arranged horizontally + MONOCLE, // clients are arranged in deck / monocle mode + GAPPLESSGRID, // clients are arranged in a gappless grid (original formula) + GAPPLESSGRID_ALT1, // clients are arranged in a gappless grid (alt. 1, fills rows first) + GAPPLESSGRID_ALT2, // clients are arranged in a gappless grid (alt. 2, fills columns first) + GRIDMODE, // clients are arranged in a grid + HORIZGRID, // clients are arranged in a horizontal grid + DWINDLE, // clients are arranged in fibonacci dwindle mode + SPIRAL, // clients are arranged in fibonacci spiral mode + AXIS_LAST, +}; + +static char tilesymb[] = { + 61, // "=", + 124, // "|", + 68, // "D", + 71, // "G", + 49, // "1", + 50, // "2" + 35, // "#", + 126, // "~", + 92, // "\\", + 64, // "@", +}; diff --git a/patch/layout_gapplessgrid.c b/patch/layout_gapplessgrid.c new file mode 100644 index 0000000..0330181 --- /dev/null +++ b/patch/layout_gapplessgrid.c @@ -0,0 +1,98 @@ +#if VANITYGAPS_PATCH +void +gaplessgrid(Monitor *m) +{ + unsigned int i, n; + int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + /* grid dimensions */ + for (cols = 0; cols <= n/2; cols++) + if (cols*cols >= n) + break; + if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + rows = n/cols; + cn = rn = 0; // reset column no, row no, client count + + ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; + cw = (m->ww - 2*ov - iv * (cols - 1)) / cols; + rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + crest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; + x = m->wx + ov; + y = m->wy + oh; + + for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { + if (i/rows + 1 > cols - n%cols) { + rows = n/cols + 1; + ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; + rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + } + resize(c, + x, + y + rn*(ch + ih) + MIN(rn, rrest), + cw + (cn < crest ? 1 : 0) - 2*c->bw, + ch + (rn < rrest ? 1 : 0) - 2*c->bw, + 0); + rn++; + if (rn >= rows) { + rn = 0; + x += cw + ih + (cn < crest ? 1 : 0); + cn++; + } + } +} +#else +void +gaplessgrid(Monitor *m) +{ + unsigned int i, n; + int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + /* grid dimensions */ + for (cols = 0; cols <= n/2; cols++) + if (cols*cols >= n) + break; + if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + rows = n/cols; + cn = rn = 0; // reset column no, row no, client count + + ch = m->wh / rows; + cw = m->ww / cols; + rrest = m->wh - ch * rows; + crest = m->ww - cw * cols; + x = m->wx; + y = m->wy; + + for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { + if (i/rows + 1 > cols - n%cols) { + rows = n/cols + 1; + ch = m->wh / rows; + rrest = m->wh - ch * rows; + } + resize(c, + x, + y + rn*ch + MIN(rn, rrest), + cw + (cn < crest ? 1 : 0) - 2*c->bw, + ch + (rn < rrest ? 1 : 0) - 2*c->bw, + 0); + rn++; + if (rn >= rows) { + rn = 0; + x += cw + (cn < crest ? 1 : 0); + cn++; + } + } +} +#endif diff --git a/patch/layout_gapplessgrid.h b/patch/layout_gapplessgrid.h new file mode 100644 index 0000000..28a7b5d --- /dev/null +++ b/patch/layout_gapplessgrid.h @@ -0,0 +1 @@ +static void gaplessgrid(Monitor *m); \ No newline at end of file diff --git a/patch/layout_grid.c b/patch/layout_grid.c new file mode 100644 index 0000000..df19896 --- /dev/null +++ b/patch/layout_grid.c @@ -0,0 +1,60 @@ +#if VANITYGAPS_PATCH +void +grid(Monitor *m) +{ + unsigned int i, n; + int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + + /* grid dimensions */ + for (rows = 0; rows <= n/2; rows++) + if (rows*rows >= n) + break; + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; + + /* window geoms (cell height/width) */ + ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1); + cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1); + chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + cc = i / rows; + cr = i % rows; + cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest); + cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest); + resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); + } +} +#else +void +grid(Monitor *m) +{ + unsigned int i, n; + int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + + /* grid dimensions */ + for (rows = 0; rows <= n/2; rows++) + if (rows*rows >= n) + break; + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; + + /* window geoms (cell height/width) */ + ch = m->wh / (rows ? rows : 1); + cw = m->ww / (cols ? cols : 1); + chrest = m->wh - ch * rows; + cwrest = m->ww - cw * cols; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + cc = i / rows; + cr = i % rows; + cx = m->wx + cc * cw + MIN(cc, cwrest); + cy = m->wy + cr * ch + MIN(cr, chrest); + resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); + } +} +#endif \ No newline at end of file diff --git a/patch/layout_grid.h b/patch/layout_grid.h new file mode 100644 index 0000000..81149ce --- /dev/null +++ b/patch/layout_grid.h @@ -0,0 +1 @@ +static void grid(Monitor *m); \ No newline at end of file diff --git a/patch/layout_horizgrid.c b/patch/layout_horizgrid.c new file mode 100644 index 0000000..48f66ab --- /dev/null +++ b/patch/layout_horizgrid.c @@ -0,0 +1,103 @@ +void +horizgrid(Monitor *m) { + Client *c; + unsigned int n, i; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + int ntop; + float mfacts = 0, sfacts = 0; + int mrest, srest, mtotal = 0, stotal = 0; + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + if (n == 0) + return; + + if (n <= 2) + ntop = n; + else { + ntop = n / 2; + } + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + sw = mw = m->ww - 2*ov; + + if (n > ntop) { + sh = (mh - ih) / 2; + mh = mh - ih - sh; + sy = my + mh + ih; + mw = m->ww - 2*ov - iv * (ntop - 1); + sw = m->ww - 2*ov - iv * (n - ntop - 1); + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (n > ntop) { + sh = mh / 2; + mh = mh - sh; + sy = my + mh; + } + #endif // VANITYGAPS_PATCH + + /* calculate facts */ + #if CFACTS_PATCH + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < ntop) + mfacts += c->cfact; + else + sfacts += c->cfact; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < ntop) + mtotal += mh * (c->cfact / mfacts); + else + stotal += sw * (c->cfact / sfacts); + #else + mfacts = ntop; + sfacts = n - ntop; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < ntop) + mtotal += mh / mfacts; + else + stotal += sw / sfacts; + #endif // CFACTS_PATCH + + mrest = mh - mtotal; + srest = sw - stotal; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < ntop) { + #if CFACTS_PATCH + resize(c, mx, my, mw * (c->cfact / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #else + resize(c, mx, my, mw / mfacts + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + mx += WIDTH(c) + iv; + #else + mx += WIDTH(c); + #endif // VANITYGAPS_PATCH + } else { + #if CFACTS_PATCH + resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #else + resize(c, sx, sy, sw / sfacts + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sx += WIDTH(c) + iv; + #else + sx += WIDTH(c); + #endif // VANITYGAPS_PATCH + } +} \ No newline at end of file diff --git a/patch/layout_horizgrid.h b/patch/layout_horizgrid.h new file mode 100644 index 0000000..71a57fb --- /dev/null +++ b/patch/layout_horizgrid.h @@ -0,0 +1 @@ +static void horizgrid(Monitor *m); \ No newline at end of file diff --git a/patch/layout_monocle.c b/patch/layout_monocle.c new file mode 100644 index 0000000..1533aa9 --- /dev/null +++ b/patch/layout_monocle.c @@ -0,0 +1,37 @@ +#if VANITYGAPS_PATCH && VANITYGAPS_MONOCLE_PATCH +void +monocle(Monitor *m) +{ + unsigned int n; + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + + #if !MONOCLESYMBOL_PATCH + if (n > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + #endif // MONOCLESYMBOL_PATCH + for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) + resize(c, m->wx + ov, m->wy + oh, m->ww - 2 * c->bw - 2 * ov, m->wh - 2 * c->bw - 2 * oh, 0); +} +#else +void +monocle(Monitor *m) +{ + #if !MONOCLESYMBOL_PATCH + unsigned int n = 0; + #endif // MONOCLESYMBOL_PATCH + Client *c; + + #if !MONOCLESYMBOL_PATCH + for (c = m->clients; c; c = c->next) + if (ISVISIBLE(c)) + n++; + if (n > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + #endif // MONOCLESYMBOL_PATCH + for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); +} +#endif // VANITYGAPS_PATCH \ No newline at end of file diff --git a/patch/layout_monocle.h b/patch/layout_monocle.h new file mode 100644 index 0000000..d3df960 --- /dev/null +++ b/patch/layout_monocle.h @@ -0,0 +1 @@ +static void monocle(Monitor *m); \ No newline at end of file diff --git a/patch/layout_nrowgrid.c b/patch/layout_nrowgrid.c new file mode 100644 index 0000000..5709d80 --- /dev/null +++ b/patch/layout_nrowgrid.c @@ -0,0 +1,103 @@ +#if VANITYGAPS_PATCH +void +nrowgrid(Monitor *m) +{ + unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */ + int oh, ov, ih, iv; /* vanitygap settings */ + unsigned int cx, cy, cw, ch; /* client geometry */ + unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ + unsigned int cols, rows = m->nmaster + 1; + Client *c; + + /* count clients */ + getgaps(m, &oh, &ov, &ih, &iv, &n); + + /* nothing to do here */ + if (n == 0) + return; + + /* force 2 clients to always split vertically */ + if (FORCE_VSPLIT && n == 2) + rows = 1; + + /* never allow empty rows */ + if (n < rows) + rows = n; + + /* define first row */ + cols = n / rows; + uc = cols; + cy = m->wy + oh; + ch = (m->wh - 2*oh - ih*(rows - 1)) / rows; + uh = ch; + + for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) { + if (ci == cols) { + uw = 0; + ci = 0; + ri++; + + /* next row */ + cols = (n - uc) / (rows - ri); + uc += cols; + cy = m->wy + oh + uh + ih; + uh += ch + ih; + } + + cx = m->wx + ov + uw; + cw = (m->ww - 2*ov - uw) / (cols - ci); + uw += cw + iv; + + resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); + } +} +#else +void +nrowgrid(Monitor *m) +{ + unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */ + unsigned int cx, cy, cw, ch; /* client geometry */ + unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ + unsigned int cols, rows = m->nmaster + 1; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + /* force 2 clients to always split vertically */ + if (FORCE_VSPLIT && n == 2) + rows = 1; + + /* never allow empty rows */ + if (n < rows) + rows = n; + + /* define first row */ + cols = n / rows; + uc = cols; + cy = m->wy; + ch = m->wh / rows; + uh = ch; + + for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) { + if (ci == cols) { + uw = 0; + ci = 0; + ri++; + + /* next row */ + cols = (n - uc) / (rows - ri); + uc += cols; + cy = m->wy + uh; + uh += ch; + } + + cx = m->wx + uw; + cw = (m->ww - uw) / (cols - ci); + uw += cw; + + resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); + } +} +#endif \ No newline at end of file diff --git a/patch/layout_nrowgrid.h b/patch/layout_nrowgrid.h new file mode 100644 index 0000000..de71a50 --- /dev/null +++ b/patch/layout_nrowgrid.h @@ -0,0 +1 @@ +static void nrowgrid(Monitor *m); \ No newline at end of file diff --git a/patch/layout_tile.c b/patch/layout_tile.c new file mode 100644 index 0000000..fa0b90a --- /dev/null +++ b/patch/layout_tile.c @@ -0,0 +1,73 @@ +static void +tile(Monitor *m) +{ + unsigned int i, n; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + + #if VANITYGAPS_PATCH + int oh, ov, ih, iv; + getgaps(m, &oh, &ov, &ih, &iv, &n); + #else + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + #endif // VANITYGAPS_PATCH + + if (n == 0) + return; + + #if VANITYGAPS_PATCH + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); + sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); + sw = mw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sw = (mw - iv) * (1 - m->mfact); + mw = (mw - iv) * m->mfact; + sx = mx + mw + iv; + } + #else + sx = mx = m->wx; + sy = my = m->wy; + sh = mh = m->wh; + sw = mw = m->ww; + + if (m->nmaster && n > m->nmaster) { + sw = mw * (1 - m->mfact); + mw = mw * m->mfact; + sx = mx + mw; + } + #endif // VANITYGAPS_PATCH + + getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + #if CFACTS_PATCH + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + my += HEIGHT(c) + ih; + #else + my += HEIGHT(c); + #endif + } else { + #if CFACTS_PATCH + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #else + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + #endif // CFACTS_PATCH + #if VANITYGAPS_PATCH + sy += HEIGHT(c) + ih; + #else + sy += HEIGHT(c); + #endif + } +} \ No newline at end of file diff --git a/patch/layout_tile.h b/patch/layout_tile.h new file mode 100644 index 0000000..8730e13 --- /dev/null +++ b/patch/layout_tile.h @@ -0,0 +1 @@ +static void tile(Monitor *); \ No newline at end of file diff --git a/patch/monocle.c b/patch/monocle.c deleted file mode 100644 index 1533aa9..0000000 --- a/patch/monocle.c +++ /dev/null @@ -1,37 +0,0 @@ -#if VANITYGAPS_PATCH && VANITYGAPS_MONOCLE_PATCH -void -monocle(Monitor *m) -{ - unsigned int n; - int oh, ov, ih, iv; - Client *c; - - getgaps(m, &oh, &ov, &ih, &iv, &n); - - #if !MONOCLESYMBOL_PATCH - if (n > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); - #endif // MONOCLESYMBOL_PATCH - for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) - resize(c, m->wx + ov, m->wy + oh, m->ww - 2 * c->bw - 2 * ov, m->wh - 2 * c->bw - 2 * oh, 0); -} -#else -void -monocle(Monitor *m) -{ - #if !MONOCLESYMBOL_PATCH - unsigned int n = 0; - #endif // MONOCLESYMBOL_PATCH - Client *c; - - #if !MONOCLESYMBOL_PATCH - for (c = m->clients; c; c = c->next) - if (ISVISIBLE(c)) - n++; - if (n > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); - #endif // MONOCLESYMBOL_PATCH - for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) - resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); -} -#endif // VANITYGAPS_PATCH \ No newline at end of file diff --git a/patch/monocle.h b/patch/monocle.h deleted file mode 100644 index d3df960..0000000 --- a/patch/monocle.h +++ /dev/null @@ -1 +0,0 @@ -static void monocle(Monitor *m); \ No newline at end of file diff --git a/patch/nrowgrid.c b/patch/nrowgrid.c deleted file mode 100644 index 5709d80..0000000 --- a/patch/nrowgrid.c +++ /dev/null @@ -1,103 +0,0 @@ -#if VANITYGAPS_PATCH -void -nrowgrid(Monitor *m) -{ - unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */ - int oh, ov, ih, iv; /* vanitygap settings */ - unsigned int cx, cy, cw, ch; /* client geometry */ - unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ - unsigned int cols, rows = m->nmaster + 1; - Client *c; - - /* count clients */ - getgaps(m, &oh, &ov, &ih, &iv, &n); - - /* nothing to do here */ - if (n == 0) - return; - - /* force 2 clients to always split vertically */ - if (FORCE_VSPLIT && n == 2) - rows = 1; - - /* never allow empty rows */ - if (n < rows) - rows = n; - - /* define first row */ - cols = n / rows; - uc = cols; - cy = m->wy + oh; - ch = (m->wh - 2*oh - ih*(rows - 1)) / rows; - uh = ch; - - for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) { - if (ci == cols) { - uw = 0; - ci = 0; - ri++; - - /* next row */ - cols = (n - uc) / (rows - ri); - uc += cols; - cy = m->wy + oh + uh + ih; - uh += ch + ih; - } - - cx = m->wx + ov + uw; - cw = (m->ww - 2*ov - uw) / (cols - ci); - uw += cw + iv; - - resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); - } -} -#else -void -nrowgrid(Monitor *m) -{ - unsigned int n = 0, i = 0, ri = 0, ci = 0; /* counters */ - unsigned int cx, cy, cw, ch; /* client geometry */ - unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ - unsigned int cols, rows = m->nmaster + 1; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - /* force 2 clients to always split vertically */ - if (FORCE_VSPLIT && n == 2) - rows = 1; - - /* never allow empty rows */ - if (n < rows) - rows = n; - - /* define first row */ - cols = n / rows; - uc = cols; - cy = m->wy; - ch = m->wh / rows; - uh = ch; - - for (c = nexttiled(m->clients); c; c = nexttiled(c->next), i++, ci++) { - if (ci == cols) { - uw = 0; - ci = 0; - ri++; - - /* next row */ - cols = (n - uc) / (rows - ri); - uc += cols; - cy = m->wy + uh; - uh += ch; - } - - cx = m->wx + uw; - cw = (m->ww - uw) / (cols - ci); - uw += cw; - - resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); - } -} -#endif \ No newline at end of file diff --git a/patch/nrowgrid.h b/patch/nrowgrid.h deleted file mode 100644 index de71a50..0000000 --- a/patch/nrowgrid.h +++ /dev/null @@ -1 +0,0 @@ -static void nrowgrid(Monitor *m); \ No newline at end of file diff --git a/patch/status2d.c b/patch/status2d.c deleted file mode 100644 index 99dcacd..0000000 --- a/patch/status2d.c +++ /dev/null @@ -1,209 +0,0 @@ -int -drawstatusbar(Monitor *m, int bh, char* stext, int stw, int stp, int align) -{ - int ret, i, w, x, len; - short isCode = 0; - char *text; - char *p; - - len = strlen(stext) + 1; - if (!(text = (char*) malloc(sizeof(char)*len))) - die("malloc"); - p = text; - #if STATUSCMD_PATCH - copyvalidchars(text, stext); - #else - memcpy(text, stext, len); - #endif // STATUSCMD_PATCH - - /* compute width of the status text */ - w = stp * 2; - i = -1; - while (text[++i]) { - if (text[i] == '^') { - if (!isCode) { - isCode = 1; - text[i] = '\0'; - #if PANGO_PATCH - w += TEXTWM(text) - lrpad; - #else - w += TEXTW(text) - lrpad; - #endif // PANGO_PATCH - text[i] = '^'; - if (text[++i] == 'f') - w += atoi(text + ++i); - } else { - isCode = 0; - text = text + i + 1; - i = -1; - } - } - } - if (!isCode) - #if PANGO_PATCH - w += TEXTWM(text) - lrpad; - #else - w += TEXTW(text) - lrpad; - #endif // PANGO_PATCH - else - isCode = 0; - text = p; - w += 2; /* 1px padding on both sides */ - if (align == 0) - x = 0 + stp; // left - else if (align == 1) - x = m->ww - w - stw + stp; // right - else - x = m->ww / 2 - w / 2; // center - ret = w; - - drw_setscheme(drw, scheme[LENGTH(colors)]); - drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; - drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; - drw_rect(drw, x - stp - 1, 0, w, bh, 1, 1); - x++; - - /* process status text */ - i = -1; - while (text[++i]) { - if (text[i] == '^' && !isCode) { - isCode = 1; - - text[i] = '\0'; - #if PANGO_PATCH - w = TEXTWM(text) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0, True); - #else - w = TEXTW(text) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0); - #endif // PANGO_PATCH - - x += w; - - /* process code */ - while (text[++i] != '^') { - if (text[i] == 'c') { - char buf[8]; - if (i + 7 > len) { - i += 7; - break; - } - memcpy(buf, (char*)text+i+1, 7); - buf[7] = '\0'; - #if ALPHA_PATCH && STATUS2D_NO_ALPHA_PATCH - drw_clr_create(drw, &drw->scheme[ColFg], buf, 0xff); - #elif ALPHA_PATCH - drw_clr_create(drw, &drw->scheme[ColFg], buf, alphas[SchemeNorm][ColFg]); - #else - drw_clr_create(drw, &drw->scheme[ColFg], buf); - #endif // ALPHA_PATCH - i += 7; - } else if (text[i] == 'b') { - char buf[8]; - if (i + 7 > len) { - i += 7; - break; - } - memcpy(buf, (char*)text+i+1, 7); - buf[7] = '\0'; - #if ALPHA_PATCH && STATUS2D_NO_ALPHA_PATCH - drw_clr_create(drw, &drw->scheme[ColBg], buf, 0xff); - #elif ALPHA_PATCH - drw_clr_create(drw, &drw->scheme[ColBg], buf, alphas[SchemeNorm][ColBg]); - #else - drw_clr_create(drw, &drw->scheme[ColBg], buf); - #endif // ALPHA_PATCH - i += 7; - } else if (text[i] == 'd') { - drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; - drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; - } else if (text[i] == 'r') { - int rx = atoi(text + ++i); - while (text[++i] != ','); - int ry = atoi(text + ++i); - while (text[++i] != ','); - int rw = atoi(text + ++i); - while (text[++i] != ','); - int rh = atoi(text + ++i); - - if (ry < 0) - ry = 0; - if (rx < 0) - rx = 0; - - drw_rect(drw, rx + x, ry, rw, rh, 1, 0); - } else if (text[i] == 'f') { - x += atoi(text + ++i); - } - } - - text = text + i + 1; - i=-1; - isCode = 0; - } - } - - if (!isCode) { - #if PANGO_PATCH - w = TEXTWM(text) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0, True); - #else - w = TEXTW(text) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0); - #endif // PANGO_PATCH - } - - drw_setscheme(drw, scheme[SchemeNorm]); - free(p); - - return ret; -} - -int -status2dtextlength(char* stext) -{ - int i, w, len; - short isCode = 0; - char *text; - - len = strlen(stext) + 1; - if (!(text = (char*) malloc(sizeof(char)*len))) - die("malloc"); - - #if STATUSCMD_PATCH - copyvalidchars(text, stext); - #else - memcpy(text, stext, len); - #endif // STATUSCMD_PATCH - - /* compute width of the status text */ - w = 0; - i = -1; - while (text[++i]) { - if (text[i] == '^') { - if (!isCode) { - isCode = 1; - text[i] = '\0'; - #if PANGO_PATCH - w += TEXTWM(text) - lrpad; - #else - w += TEXTW(text) - lrpad; - #endif // PANGO_PATCH - text[i] = '^'; - if (text[++i] == 'f') - w += atoi(text + ++i); - } else { - isCode = 0; - text = text + i + 1; - i = -1; - } - } - } - if (!isCode) - #if PANGO_PATCH - w += TEXTWM(text) - lrpad; - #else - w += TEXTW(text) - lrpad; - #endif // PANGO_PATCH - return w; -} diff --git a/patch/status2d.h b/patch/status2d.h deleted file mode 100644 index 7688807..0000000 --- a/patch/status2d.h +++ /dev/null @@ -1,2 +0,0 @@ -static int drawstatusbar(Monitor *m, int bh, char* text, int stw, int stp, int align); -static int status2dtextlength(char* stext); \ No newline at end of file diff --git a/patch/statuscolors.c b/patch/statuscolors.c index ef41735..cc24ad4 100644 --- a/patch/statuscolors.c +++ b/patch/statuscolors.c @@ -12,11 +12,11 @@ textw_wosc(char *s) } ctmp = *ts; *ts = '\0'; - #if PANGO_PATCH + #if BAR_PANGO_PATCH sw += drw_font_getwidth(drw, tp, True); #else sw += drw_fontset_getwidth(drw, tp); - #endif // PANGO_PATCH + #endif // BAR_PANGO_PATCH *ts = ctmp; if (ctmp == '\0') break; diff --git a/patch/systray.c b/patch/systray.c deleted file mode 100644 index 0ca2f86..0000000 --- a/patch/systray.c +++ /dev/null @@ -1,206 +0,0 @@ - -static Systray *systray = NULL; -static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ; - -unsigned int -getsystraywidth() -{ - unsigned int w = 0; - Client *i; - if (showsystray) - for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); - return w ? w + systrayspacing : 0; -} - -void -removesystrayicon(Client *i) -{ - Client **ii; - - if (!showsystray || !i) - return; - for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next); - if (ii) - *ii = i->next; - free(i); -} - -void -resizerequest(XEvent *e) -{ - XResizeRequestEvent *ev = &e->xresizerequest; - Client *i; - - if ((i = wintosystrayicon(ev->window))) { - updatesystrayicongeom(i, ev->width, ev->height); - updatesystray(); - } -} - -Monitor * -systraytomon(Monitor *m) -{ - Monitor *t; - int i, n; - if (!systraypinning) { - if (!m) - return selmon; - return m == selmon ? m : NULL; - } - for (n = 1, t = mons; t && t->next; n++, t = t->next); - for (i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next); - if (systraypinningfailfirst && n < systraypinning) - return mons; - return t; -} - -void -updatesystray(void) -{ - XSetWindowAttributes wa; - XWindowChanges wc; - Client *i; - Monitor *m = systraytomon(NULL); - unsigned int x = m->mx + m->mw; - unsigned int w = 1, xpad = 0, ypad = 0; - #if BARPADDING_PATCH - xpad = sp; - ypad = vp; - #endif // BARPADDING_PATCH - - if (!showsystray) - return; - if (!systray) { - /* init systray */ - if (!(systray = (Systray *)calloc(1, sizeof(Systray)))) - die("fatal: could not malloc() %u bytes\n", sizeof(Systray)); - - wa.override_redirect = True; - wa.event_mask = ButtonPressMask|ExposureMask; - wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; - wa.border_pixel = 0; - #if ALPHA_PATCH - wa.colormap = cmap; - systray->win = XCreateWindow(dpy, root, x - xpad, m->by + ypad, w, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); - #else - systray->win = XCreateSimpleWindow(dpy, root, x - xpad, m->by + ypad, w, bh, 0, 0, scheme[SchemeNorm][ColBg].pixel); - XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa); - #endif // ALPHA_PATCH - XSelectInput(dpy, systray->win, SubstructureNotifyMask); - XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)&systrayorientation, 1); - #if ALPHA_PATCH - XChangeProperty(dpy, systray->win, netatom[NetSystemTrayVisual], XA_VISUALID, 32, - PropModeReplace, (unsigned char *)&visual->visualid, 1); - #endif // ALPHA_PATCH - XChangeProperty(dpy, systray->win, netatom[NetWMWindowType], XA_ATOM, 32, - PropModeReplace, (unsigned char *)&netatom[NetWMWindowTypeDock], 1); - XMapRaised(dpy, systray->win); - XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime); - if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) { - sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0); - XSync(dpy, False); - } - else { - fprintf(stderr, "dwm: unable to obtain system tray.\n"); - free(systray); - systray = NULL; - return; - } - } - - drw_setscheme(drw, scheme[SchemeNorm]); - for (w = 0, i = systray->icons; i; i = i->next) { - /* make sure the background color stays the same */ - wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; - XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa); - XMapRaised(dpy, i->win); - w += systrayspacing; - i->x = w; - XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h); - w += i->w; - if (i->mon != m) - i->mon = m; - } - w = w ? w + systrayspacing : 1; - x -= w; - XMoveResizeWindow(dpy, systray->win, x - xpad, m->by + ypad, w, bh); - wc.x = x - xpad; - wc.y = m->by + ypad; - wc.width = w; - wc.height = bh; - wc.stack_mode = Above; wc.sibling = m->barwin; - XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc); - XMapWindow(dpy, systray->win); - XMapSubwindows(dpy, systray->win); - /* redraw background */ - XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel); - XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh); - XSync(dpy, False); -} - -void -updatesystrayicongeom(Client *i, int w, int h) -{ - if (i) { - i->h = bh; - if (w == h) - i->w = bh; - else if (h == bh) - i->w = w; - else - i->w = (int) ((float)bh * ((float)w / (float)h)); - applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False); - /* force icons into the systray dimensions if they don't want to */ - if (i->h > bh) { - if (i->w == i->h) - i->w = bh; - else - i->w = (int) ((float)bh * ((float)i->w / (float)i->h)); - i->h = bh; - } - if (i->w > 2*bh) - i->w = bh; - } -} - -void -updatesystrayiconstate(Client *i, XPropertyEvent *ev) -{ - long flags; - int code = 0; - - if (!showsystray || !i || ev->atom != xatom[XembedInfo] || - !(flags = getatomprop(i, xatom[XembedInfo]))) - return; - - if (flags & XEMBED_MAPPED && !i->tags) { - i->tags = 1; - code = XEMBED_WINDOW_ACTIVATE; - XMapRaised(dpy, i->win); - setclientstate(i, NormalState); - } - else if (!(flags & XEMBED_MAPPED) && i->tags) { - i->tags = 0; - code = XEMBED_WINDOW_DEACTIVATE; - XUnmapWindow(dpy, i->win); - setclientstate(i, WithdrawnState); - } - else - return; - sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0, - systray->win, XEMBED_EMBEDDED_VERSION); -} - -Client * -wintosystrayicon(Window w) -{ - Client *i = NULL; - - if (!showsystray || !w) - return i; - for (i = systray->icons; i && i->win != w; i = i->next); - return i; -} \ No newline at end of file diff --git a/patch/systray.h b/patch/systray.h deleted file mode 100644 index 1a2bab6..0000000 --- a/patch/systray.h +++ /dev/null @@ -1,37 +0,0 @@ -#define SYSTEM_TRAY_REQUEST_DOCK 0 -#define _NET_SYSTEM_TRAY_ORIENTATION_HORZ 0 - -/* XEMBED messages */ -#define XEMBED_EMBEDDED_NOTIFY 0 -#define XEMBED_WINDOW_ACTIVATE 1 -#define XEMBED_FOCUS_IN 4 -#define XEMBED_MODALITY_ON 10 - -#define XEMBED_MAPPED (1 << 0) -#define XEMBED_WINDOW_ACTIVATE 1 -#define XEMBED_WINDOW_DEACTIVATE 2 - -#define VERSION_MAJOR 0 -#define VERSION_MINOR 0 -#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR - -/* enums */ -enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */ - -typedef struct Systray Systray; -struct Systray { - Window win; - Client *icons; -}; - -/* function declarations */ -static Atom getatomprop(Client *c, Atom prop); -static unsigned int getsystraywidth(); -static void removesystrayicon(Client *i); -static void resizerequest(XEvent *e); -static Monitor *systraytomon(Monitor *m); -static void updatesystray(void); -static void updatesystrayicongeom(Client *i, int w, int h); -static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); -static Client *wintosystrayicon(Window w); - diff --git a/patch/tile.c b/patch/tile.c deleted file mode 100644 index fa0b90a..0000000 --- a/patch/tile.c +++ /dev/null @@ -1,73 +0,0 @@ -static void -tile(Monitor *m) -{ - unsigned int i, n; - int mx = 0, my = 0, mh = 0, mw = 0; - int sx = 0, sy = 0, sh = 0, sw = 0; - float mfacts, sfacts; - int mrest, srest; - Client *c; - - - #if VANITYGAPS_PATCH - int oh, ov, ih, iv; - getgaps(m, &oh, &ov, &ih, &iv, &n); - #else - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - #endif // VANITYGAPS_PATCH - - if (n == 0) - return; - - #if VANITYGAPS_PATCH - sx = mx = m->wx + ov; - sy = my = m->wy + oh; - mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); - sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); - sw = mw = m->ww - 2*ov; - - if (m->nmaster && n > m->nmaster) { - sw = (mw - iv) * (1 - m->mfact); - mw = (mw - iv) * m->mfact; - sx = mx + mw + iv; - } - #else - sx = mx = m->wx; - sy = my = m->wy; - sh = mh = m->wh; - sw = mw = m->ww; - - if (m->nmaster && n > m->nmaster) { - sw = mw * (1 - m->mfact); - mw = mw * m->mfact; - sx = mx + mw; - } - #endif // VANITYGAPS_PATCH - - getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); - - for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - #if CFACTS_PATCH - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - my += HEIGHT(c) + ih; - #else - my += HEIGHT(c); - #endif - } else { - #if CFACTS_PATCH - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #else - resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); - #endif // CFACTS_PATCH - #if VANITYGAPS_PATCH - sy += HEIGHT(c) + ih; - #else - sy += HEIGHT(c); - #endif - } -} \ No newline at end of file diff --git a/patch/tile.h b/patch/tile.h deleted file mode 100644 index 8730e13..0000000 --- a/patch/tile.h +++ /dev/null @@ -1 +0,0 @@ -static void tile(Monitor *); \ No newline at end of file diff --git a/patch/xrdb.c b/patch/xrdb.c index ef9e186..f3bd38a 100644 --- a/patch/xrdb.c +++ b/patch/xrdb.c @@ -30,16 +30,16 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.selfloatcolor", selfloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH - #if STATUSCOLORS_PATCH + #if BAR_STATUSCOLORS_PATCH XRDB_LOAD_COLOR("dwm.warnfgcolor", warnfgcolor); XRDB_LOAD_COLOR("dwm.warnbgcolor", warnbgcolor); XRDB_LOAD_COLOR("dwm.warnbordercolor", warnbordercolor); #if FLOAT_BORDER_COLOR_PATCH XRDB_LOAD_COLOR("dwm.warnfloatcolor", warnfloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH - #endif // STATUSCOLORS_PATCH + #endif // BAR_STATUSCOLORS_PATCH - #if URGENTBORDER_PATCH || STATUSCOLORS_PATCH + #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH XRDB_LOAD_COLOR("dwm.urgfgcolor", urgfgcolor); XRDB_LOAD_COLOR("dwm.urgbgcolor", urgbgcolor); XRDB_LOAD_COLOR("dwm.urgbordercolor", urgbordercolor); @@ -57,14 +57,14 @@ loadxrdb() #endif // FLOAT_BORDER_COLOR_PATCH #endif // AWESOMEBAR_PATCH - #if TITLECOLOR_PATCH + #if BAR_TITLECOLOR_PATCH XRDB_LOAD_COLOR("dwm.titlefgcolor", titlefgcolor); XRDB_LOAD_COLOR("dwm.titlebgcolor", titlebgcolor); XRDB_LOAD_COLOR("dwm.titlebordercolor", titlebordercolor); #if FLOAT_BORDER_COLOR_PATCH XRDB_LOAD_COLOR("dwm.titlefloatcolor", titlefloatcolor); #endif // FLOAT_BORDER_COLOR_PATCH - #endif // TITLECOLOR_PATCH + #endif // BAR_TITLECOLOR_PATCH } } } @@ -79,9 +79,9 @@ xrdb(const Arg *arg) int i; for (i = 0; i < LENGTH(colors); i++) scheme[i] = drw_scm_create(drw, colors[i], - #if ALPHA_PATCH + #if BAR_ALPHA_PATCH alphas[i], - #endif // ALPHA_PATCH + #endif // BAR_ALPHA_PATCH #if FLOAT_BORDER_COLOR_PATCH 4 #else diff --git a/patches.def.h b/patches.def.h index 81dcc7c..a95e26e 100644 --- a/patches.def.h +++ b/patches.def.h @@ -10,31 +10,228 @@ * here for grouping purposes. */ -/* Patches */ +/** + * Bar modules + */ -/* This patch changes the rectangle indicating if a tag is used by a client into a bar - * above the tag name for better visibility. - * https://dwm.suckless.org/patches/activetagindicatorbar/ +/* Enhanced taskbar that shows the titles of all visible windows in the status bar + * and allows focus / hiding / unhiding of windows by clicking on the status bar. + * Awesomebar takes precedence over fancybar. + * https://dwm.suckless.org/patches/awesomebar/ */ -#define ACTIVETAGINDICATORBAR_PATCH 0 +#define BAR_AWESOMEBAR_PATCH 0 -/* Alternative patch to the activetagindicatorbar patch, adds the bar below the tag - * icon rather than above. +/* This patch depends on statuscmd patch and adds integration with a (patched) dwmblocks + * instance to give a clickable status bar. + * Patch: https://gist.github.com/danbyl/54f7c1d57fc6507242a95b71c3d8fdea + * dwmblocks: https://github.com/torrinfail/dwmblocks + */ +#define BAR_DWMBLOCKS_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. Fancybar takes precedence over + * the centeredwindowname patch. + * https://dwm.suckless.org/patches/fancybar/ + */ +#define BAR_FANCYBAR_PATCH 0 + +/* Show layout symbol in bar */ +#define BAR_LTSYMBOL_PATCH 1 + +/* This patch adds an option to place tags in rows like in many other window managers. + * https://dwm.suckless.org/patches/taggrid/ + */ +#define BAR_TAGGRID_PATCH 0 + +/* Show status in bar */ +#define BAR_STATUS_PATCH 1 + +/* This patch adds a clickable button to the left hand side of the statusbar. + * https://dwm.suckless.org/patches/statusbutton/ + */ +#define BAR_STATUSBUTTON_PATCH 0 + +/* This patch adds the ability to execute shell commands based on the mouse button and position + * when clicking the status bar. Refer to the website for usage. + * https://dwm.suckless.org/patches/statuscmd/ + */ +#define BAR_STATUSCMD_PATCH 0 + +/* Status2d allows colors and rectangle drawing in your dwm status bar. + * This patch is incompatible with the statuscolors patch which takes precedence. + * This patch is incompatible with the extrabar patch. + * https://dwm.suckless.org/patches/status2d/ + */ +#define BAR_STATUS2D_PATCH 0 + +/* Supplementary patch should you want to disable alpha for the status2d section */ +#define BAR_STATUS2D_NO_ALPHA_PATCH 0 + +/* The systray patch adds systray for the status bar. + * https://dwm.suckless.org/patches/systray/ + */ +#define BAR_SYSTRAY_PATCH 0 + +/* Show tag symbols in bar */ +#define BAR_TAGS_PATCH 1 + +/* Show window title in bar */ +#define BAR_WINTITLE_PATCH 1 + +/** + * Bar options */ -#define ACTIVETAGINDICATORBAR_ALT1_PATCH 0 /* The alpha patch adds transparency for the status bar. * You need to uncomment the corresponding line in config.mk to use the -lXrender library * when including this patch. * https://dwm.suckless.org/patches/alpha/ */ -#define ALPHA_PATCH 0 +#define BAR_ALPHA_PATCH 0 /* This patch introduces alternative tags which can be switched on the fly for the * sole purpose of providing visual aid. * https://dwm.suckless.org/patches/alternativetags/ */ -#define ALTERNATIVE_TAGS_PATCH 0 +#define BAR_ALTERNATIVE_TAGS_PATCH 0 + +/* This patch changes the rectangle indicating if a tag is used by a client into a bar + * above the tag name for better visibility. + * https://dwm.suckless.org/patches/activetagindicatorbar/ + */ +#define BAR_ACTIVETAGINDICATORBAR_PATCH 0 + +/* Alternative patch to the activetagindicatorbar patch, adds the bar below the tag + * icon rather than above. + */ +#define BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH 0 + +/* This patch centers the WM_NAME of the currently selected window on the status bar. + * Both fancybar and awesomebar patches take precedence over this patch. + * This patch only applies when the BAR_WINTITLE_PATCH module is used. + * https://dwm.suckless.org/patches/centeredwindowname/ + */ +#define BAR_CENTEREDWINDOWNAME_PATCH 0 + +/* This patch enables color emoji in dwm by removing a workaround for a BadLength error + * in the Xft library when color glyphs are used. + * To enable this you will need an updated Xft library that can handle color glyphs otherwise + * dwm will crash on encountering such characters. Note that you will also need a font that + * provides color emojis for this to work. + */ +#define BAR_COLOR_EMOJI_PATCH 0 + +/* Updates the position of dmenu to match that of the bar. I.e. if topbar is 0 then dmenu + * will appear at the bottom and if 1 then dmenu will appear at the top. + * https://dwm.suckless.org/patches/dmenumatchtop + */ +#define BAR_DMENUMATCHTOP_PATCH 0 + +/* This patch will enable an extra status bar in dwm in a similar manner to the dualstatus + * patch. If the primary status is at the top via topbar then the extra status bar will be + * placed at the bottom and vice versa. + * https://dwm.suckless.org/patches/extrabar/ + */ +#define BAR_EXTRABAR_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 BAR_EWMHTAGS_PATCH 0 + +/* Allows the bar height to be explicitly set rather than being derived from font. + * https://dwm.suckless.org/patches/bar_height/ + */ +#define BAR_HEIGHT_PATCH 0 + +/* This patch prevents dwm from drawing tags with no clients (i.e. vacant) on the bar. + * https://dwm.suckless.org/patches/hide_vacant_tags/ + */ +#define BAR_HIDEVACANTTAGS_PATCH 0 + +/* With this patch dwm's built-in status bar is only shown when HOLDKEY is pressed + * and the bar will now overlay the display. + * http://dwm.suckless.org/patches/holdbar/ + */ +#define BAR_HOLDBAR_PATCH 0 + +/* Sometimes dwm crashes when it cannot render some glyphs in window titles (usually emoji). + * This patch is essentially a hack to ignore any errors when drawing text on the status bar. + * https://groups.google.com/forum/m/#!topic/wmii/7bncCahYIww + * https://docs.google.com/viewer?a=v&pid=forums&srcid=MDAwODA2MTg0MDQyMjE0OTgzMzMBMDQ3ODQzODkyMTU3NTAyMTMxNTYBX2RUMVNtOUtDQUFKATAuMQEBdjI&authuser=0 + */ +#define BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH 0 + +/* This patch adds vertical and horizontal space between the statusbar and the edge of the screen. + * https://dwm.suckless.org/patches/barpadding/ + */ +#define BAR_PADDING_PATCH 0 + +/* This patch adds simple markup for status messages using pango markup. + * This depends on the pango library v1.44 or greater. + * You need to uncomment the corresponding lines in config.mk to use the pango libraries + * when including this patch. + * + * Note that the pango patch does not protect against the BadLength error from Xft + * when color glyphs are used, which means that dwm will crash if color emoji is used. + * + * If you need color emoji then you may want to install this patched library from the AUR: + * https://aur.archlinux.org/packages/libxft-bgra/ + * + * A long term fix for the libXft library is pending approval of this pull request: + * https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1 + * + * Also see: + * https://developer.gnome.org/pygtk/stable/pango-markup-language.html + * https://lists.suckless.org/hackers/2004/17285.html + * https://dwm.suckless.org/patches/pango/ + */ +#define BAR_PANGO_PATCH 0 + +/* This patch allows the status text to be fixed to the bar on a specific + * monitor rather than being drawn on the focused monitor. + * The statusallmons patch takes precedence over this patch. + * NB: If used together with the systray patch then consider setting + * systraypinning to statmonval+1. + * https://dwm.suckless.org/patches/staticstatus/ + */ +#define BAR_STATICSTATUS_PATCH 0 + +/* This patch draws and updates the statusbar on all monitors. + * https://dwm.suckless.org/patches/statusallmons/ + */ +#define BAR_STATUSALLMONS_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. + * https://dwm.suckless.org/patches/statuscolors/ + */ +#define BAR_STATUSCOLORS_PATCH 0 + +/* This patch adds configuration options for horizontal and vertical padding in the status bar. + * https://dwm.suckless.org/patches/statuspadding/ + */ +#define BAR_STATUSPADDING_PATCH 0 + +/* Adds a new color scheme used by the (selected) window title in the bar. + * https://dwm.suckless.org/patches/titlecolor/ + */ +#define BAR_TITLECOLOR_PATCH 0 + +/* This patch adds the ability for dwm to read colors from the linux virtual console. + * /sys/module/vt/parameters/default_{red,grn,blu} + * Essentially this way the colors you use in your regular tty is "mirrored" to dwm. + * https://dwm.suckless.org/patches/vtcolors/ + */ +#define BAR_VTCOLORS_PATCH 0 + +/*** + * Other patches + */ /* This patch prevents the focus to drift from the active fullscreen client when * using focusstack(). @@ -80,23 +277,6 @@ */ #define AUTORESIZE_PATCH 0 -/* Enhanced taskbar that shows the titles of all visible windows in the status bar - * and allows focus / hiding / unhiding of windows by clicking on the status bar. - * Awesomebar takes precedence over fancybar. - * https://dwm.suckless.org/patches/awesomebar/ - */ -#define AWESOMEBAR_PATCH 0 - -/* Allows the bar height to be explicitly set rather than being derived from font. - * https://dwm.suckless.org/patches/bar_height/ - */ -#define BAR_HEIGHT_PATCH 0 - -/* This patch adds vertical and horizontal space between the statusbar and the edge of the screen. - * https://dwm.suckless.org/patches/barpadding/ - */ -#define BARPADDING_PATCH 0 - /* This patch adds an iscentered rule to automatically center clients on the current monitor. * This patch takes precedence over centeredwindowname and fancybar patches. * https://dwm.suckless.org/patches/center/ @@ -120,12 +300,6 @@ */ #define CENTER_TRANSIENT_WINDOWS_BY_PARENT_PATCH 0 -/* This patch centers the WM_NAME of the currently selected window on the status bar. - * Both fancybar and awesomebar patches take precedence over this patch. - * https://dwm.suckless.org/patches/centeredwindowname/ - */ -#define CENTEREDWINDOWNAME_PATCH 0 - /* This patch provides the ability to assign different weights to clients in their * respective stack in tiled layout. * https://dwm.suckless.org/patches/cfacts/ @@ -137,14 +311,6 @@ */ #define CMDCUSTOMIZE_PATCH 0 -/* This patch enables color emoji in dwm by removing a workaround for a BadLength error - * in the Xft library when color glyphs are used. - * To enable this you will need an updated Xft library that can handle color glyphs otherwise - * dwm will crash on encountering such characters. Note that you will also need a font that - * provides color emojis for this to work. - */ -#define COLOR_EMOJI_PATCH 0 - /* This patch tweaks the tagging interface so that you can select multiple tags for tag * or view by pressing all the right keys as a combo. For example to view tags 1 and 3, * hold MOD and then press and hold 1 and 3 together. @@ -157,12 +323,6 @@ */ #define CYCLELAYOUTS_PATCH 0 -/* Updates the position of dmenu to match that of the bar. I.e. if topbar is 0 then dmenu - * will appear at the bottom and if 1 then dmenu will appear at the top. - * https://dwm.suckless.org/patches/dmenumatchtop - */ -#define DMENUMATCHTOP_PATCH 0 - /* Similarly to the dragmfact patch this allows you to click and drag clients to change the * cfact to adjust the client's size in the stack. This patch depends on the cfacts patch. */ @@ -175,13 +335,6 @@ */ #define DRAGMFACT_PATCH 0 -/* This patch depends on statuscmd patch and adds integration with a (patched) dwmblocks - * instance to give a clickable status bar. - * Patch: https://gist.github.com/danbyl/54f7c1d57fc6507242a95b71c3d8fdea - * dwmblocks: https://github.com/torrinfail/dwmblocks - */ -#define DWMBLOCKS_PATCH 0 - /* Simple dwmc client using a fork of fsignal to communicate with dwm. * To use this either copy the patch/dwmc shell script to somewhere in your path or * uncomment the following line in Makefile: @@ -197,13 +350,6 @@ */ #define EMPTYVIEW_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 allows the user to change size and placement of floating windows using only the * keyboard. It also allows for temporary vertical and horizontal extension of windows similar * to other WMs fill command. @@ -211,13 +357,6 @@ */ #define EXRESIZE_PATCH 0 -/* This patch will enable an extra status bar in dwm in a similar manner to the dualstatus - * patch. If the primary status is at the top via topbar then the extra status bar will be - * placed at the bottom and vice versa. - * https://dwm.suckless.org/patches/extrabar/ - */ -#define EXTRABAR_PATCH 0 - /* Only allow clients to "fullscreen" into the space currently given to them. * As an example, this will allow you to view a fullscreen video in your browser on * one half of the screen, while having the other half available for other tasks. @@ -233,14 +372,6 @@ */ #define FAKEFULLSCREEN_CLIENT_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. Fancybar takes precedence over - * the centeredwindowname patch. - * https://dwm.suckless.org/patches/fancybar/ - */ -#define FANCYBAR_PATCH 0 - /* This patch allows a different border color to be chosen for floating windows. * https://dwm.suckless.org/patches/float_border_color/ */ @@ -296,17 +427,6 @@ */ #define FULLSCREEN_PATCH 0 -/* This patch prevents dwm from drawing tags with no clients (i.e. vacant) on the bar. - * https://dwm.suckless.org/patches/hide_vacant_tags/ - */ -#define HIDEVACANTTAGS_PATCH 0 - -/* With this patch dwm's built-in status bar is only shown when HOLDKEY is pressed - * and the bar will now overlay the display. - * http://dwm.suckless.org/patches/holdbar/ - */ -#define HOLDBAR_PATCH 0 - /* This patch provides a keybinding to rotate all clients in the currently selected * area (master or stack) without affecting the other area. * https://dwm.suckless.org/patches/inplacerotate/ @@ -318,13 +438,6 @@ */ #define ISPERMANENT_PATCH 0 -/* Sometimes dwm crashes when it cannot render some glyphs in window titles (usually emoji). - * This patch is essentially a hack to ignore any errors when drawing text on the status bar. - * https://groups.google.com/forum/m/#!topic/wmii/7bncCahYIww - * https://docs.google.com/viewer?a=v&pid=forums&srcid=MDAwODA2MTg0MDQyMjE0OTgzMzMBMDQ3ODQzODkyMTU3NTAyMTMxNTYBX2RUMVNtOUtDQUFKATAuMQEBdjI&authuser=0 - */ -#define IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH 0 - /* This patch adds key modes (like in vim or emacs) where chains of keyboard shortcuts * can be performed. * https://dwm.suckless.org/patches/keymodes/ @@ -336,17 +449,12 @@ */ #define KILLUNSEL_PATCH 0 -/* Moves the layout symbol in the status bar to the left hand side. - * http://dwm.suckless.org/patches/leftlayout/ - */ -#define LEFTLAYOUT_PATCH 0 - /* By default in dwm it is possible to make an application fullscreen, then use * the focusstack keybindings to focus on other windows beneath the current window. * It is also possible to spawn new windows (e.g. a terminal) that end up getting * focus while the previous window remains in fullscreen. This patch ensures that * in such scenarios the previous window loses fullscreen. - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-losefullscreen-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-losefullscreen-6.2.diff */ #define LOSEFULLSCREEN_PATCH 0 @@ -421,27 +529,6 @@ */ #define ONLYQUITONEMPTY_PATCH 0 -/* This patch adds simple markup for status messages using pango markup. - * This depends on the pango library v1.44 or greater. - * You need to uncomment the corresponding lines in config.mk to use the pango libraries - * when including this patch. - * - * Note that the pango patch does not protect against the BadLength error from Xft - * when color glyphs are used, which means that dwm will crash if color emoji is used. - * - * If you need color emoji then you may want to install this patched library from the AUR: - * https://aur.archlinux.org/packages/libxft-bgra/ - * - * A long term fix for the libXft library is pending approval of this pull request: - * https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1 - * - * Also see: - * https://developer.gnome.org/pygtk/stable/pango-markup-language.html - * https://lists.suckless.org/hackers/2004/17285.html - * https://dwm.suckless.org/patches/pango/ - */ -#define PANGO_PATCH 0 - /* The pertag patch adds nmaster, mfacts and layouts per tag rather than per * monitor (default). * https://dwm.suckless.org/patches/pertag/ @@ -466,6 +553,11 @@ */ #define PUSH_NO_MASTER_PATCH 0 +/* Resets the layout and mfact if there is only one visible client. + * https://dwm.suckless.org/patches/resetlayout/ + */ +#define RESETLAYOUT_PATCH 0 + /* By default, windows only resize from the bottom right corner. With this * patch the mouse is warped to the nearest corner and you resize from there. * https://dwm.suckless.org/patches/resizecorners/ @@ -503,7 +595,7 @@ */ #define SAVEFLOATS_PATCH 0 -/* The scratchpads patch allows you to spawn or restore floating terminal windows. +/* The scratchpad patch allows you to spawn or restore floating terminal windows. * It is typically useful when one need to do some short typing. * Upgraded to Christian Tenllado's multiple scratchpad version. * https://lists.suckless.org/hackers/2004/17205.html @@ -511,13 +603,6 @@ */ #define SCRATCHPADS_PATCH 0 -/* The scratchpad patch above automatically resizes and centers the scratchpad window every - * time you spawn it. This alteration of the patch disables that so that the size and position - * of the scratchpad window is retained when you respawn it. If you enable this then you may - * want to also take the centered patch and enable the iscentered flag for floating scratchpads. - */ -#define SCRATCHPAD_KEEP_POSITION_AND_SIZE_PATCH 0 - /* This alternative patch enables a scratchpad feature in dwm similar to the scratchpad * feature in i3wm. * https://github.com/GasparVardanyan/dwm-scratchpad @@ -589,82 +674,26 @@ */ #define STACKER_PATCH 0 -/* This patch allows the status text to be fixed to the bar on a specific - * monitor rather than being drawn on the focused monitor. - * The statusallmons patch takes precedence over this patch. - * NB: If used together with the systray patch then consider setting - * systraypinning to statmonval+1. - * https://dwm.suckless.org/patches/staticstatus/ - */ -#define STATICSTATUS_PATCH 0 - -/* Status2d allows colors and rectangle drawing in the dwm status bar. - * This patch is incompatible with the statuscolors patch which takes precedence. - * This patch is incompatible with the extrabar patch. - * NB: If using this with dwmblocks then make sure to increase CMDLENGTH in dwmblocks.c - * from 50 (default) to 1024. - * https://dwm.suckless.org/patches/status2d/ - */ -#define STATUS2D_PATCH 0 - -/* Supplementary patch should you want to disable alpha for the status2d section */ -#define STATUS2D_NO_ALPHA_PATCH 0 - -/* This patch draws and updates the statusbar on all monitors. - * https://dwm.suckless.org/patches/statusallmons/ - */ -#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. - * https://dwm.suckless.org/patches/statuscolors/ - */ -#define STATUSCOLORS_PATCH 0 - -/* This patch adds configuration options for horizontal and vertical padding in the status bar. - * https://dwm.suckless.org/patches/statuspadding/ - */ -#define STATUSPADDING_PATCH 0 - /* Adds toggleable keyboard shortcut to make a client 'sticky', i.e. visible on all tags. * https://dwm.suckless.org/patches/sticky/ */ #define STICKY_PATCH 0 -/* This patch adds the ability to execute shell commands based on the mouse button and position - * when clicking the status bar. Refer to the website for usage. - * https://dwm.suckless.org/patches/statuscmd/ - */ -#define STATUSCMD_PATCH 0 - -/* The systray patch adds systray for the status bar. - * https://dwm.suckless.org/patches/systray/ - */ -#define SYSTRAY_PATCH 0 - /* This patch adds "window swallowing" to dwm as known from Plan 9's windowing system rio. * Clients marked with isterminal in config.h swallow a window opened by any child process, * e.g. running xclock in a terminal. Closing the xclock window restores the terminal window * in the current position. - * This patch depends on the following additional libraries: - * - libxcb - * - Xlib-libxcb - * - xcb-res - * You need to uncomment the corresponding line in config.mk to use the -lX11-xcb, -lxcb - * and -lxcb-res libraries when including this patch. * https://dwm.suckless.org/patches/swallow/ */ #define SWALLOW_PATCH 0 /* This patch depends on the pertag patch and makes it possible to switch focus with a single - * shortcut (MOD+s) instead of having to think if you should use MOD+j or MOD+k for reaching + * shortcut (MOD+s) instead of having to think if you should use mod-j or mod-k for reaching * the previously used window. + * This patch depends on the following additional libraries: + * - libxcb + * - Xlib-libxcb + * - xcb-res * https://dwm.suckless.org/patches/swapfocus/ */ #define SWAPFOCUS_PATCH 0 @@ -693,7 +722,7 @@ * * (*) except if the client has been moved between tags or to another monitor * - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-switchtag-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-switchtag-6.2.diff * Also see https://dwm.suckless.org/patches/switchtotag */ #define SWITCHTAG_PATCH 0 @@ -704,15 +733,10 @@ #define TAGALL_PATCH 0 /* This patch allows you to move all visible windows on a monitor to an adjacent monitor. - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-tagallmon-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-tagallmon-6.2.diff */ #define TAGALLMON_PATCH 0 -/* This patch adds an option to place tags in rows like in many other window managers. - * https://dwm.suckless.org/patches/taggrid/ - */ -#define TAGGRID_PATCH 0 - /* This patch makes new clients attach into the stack area when you toggle a new tag into * view. This means your master area will remain unchanged when toggling views. * The allmaster patch will cause all clients in the master area to be left alone. This patch @@ -733,7 +757,7 @@ * monitor until you exit fullscreen view (at which point it will appear on the adjacent * monitor). This patch allows a fullscreen window to be moved to an adjacent monitor * while remaining in fullscreen. - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-tagmonfixfs-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-tagmonfixfs-6.2.diff */ #define TAGMONFIXFS_PATCH 0 @@ -745,17 +769,12 @@ /* This patch allows you to swap all visible windows on one monitor with those of an * adjacent monitor. - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-tagswapmon-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-tagswapmon-6.2.diff */ #define TAGSWAPMON_PATCH 0 -/* Adds a new color scheme used by the (selected) window title in the bar. - * https://dwm.suckless.org/patches/titlecolor/ - */ -#define TITLECOLOR_PATCH 0 - /* This patch allows you to toggle fullscreen on and off using a single shortcut key. - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-togglefullscreen-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-togglefullscreen-6.2.diff */ #define TOGGLEFULLSCREEN_PATCH 0 @@ -784,8 +803,8 @@ /* This patch adds configurable gaps between windows differentiating between outer, inner, * horizontal and vertical gaps. - * https://github.com/bakkeby/dwm-vanitygaps/tree/master/patches/dwm-vanitygaps-6.2.diff - * https://github.com/bakkeby/dwm-vanitygaps/tree/master/patches/dwm-vanitygaps-cfacts-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-vanitygaps-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-cfacts-vanitygaps-6.2.diff */ #define VANITYGAPS_PATCH 0 @@ -800,13 +819,6 @@ */ #define VIEWONTAG_PATCH 0 -/* This patch adds the ability for dwm to read colors from the linux virtual console. - * /sys/module/vt/parameters/default_{red,grn,blu} - * Essentially this way the colors you use in your regular tty is "mirrored" to dwm. - * https://dwm.suckless.org/patches/vtcolors/ - */ -#define VTCOLORS_PATCH 0 - /* This patch warps the mouse cursor to the center of the currently focused window or screen * when the mouse cursor is (a) on a different screen or (b) on top of a different window. * https://dwm.suckless.org/patches/warp/ @@ -818,7 +830,7 @@ * This patch adds the role field to the rule configuration so that one can * differentiate between, say, Firefox "browser" vs "Preferences" vs "Manager" * or Google-chrome "browser" vs "pop-up". - * https://github.com/bakkeby/patches/tree/master/dwm/dwm-windowrolerule-6.2.diff + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-windowrolerule-6.2.diff */ #define WINDOWROLERULE_PATCH 0 @@ -840,7 +852,9 @@ */ #define ZOOMSWAP_PATCH 0 -/* Layouts */ +/** + * Layouts + */ /* Bottomstack layout. * https://dwm.suckless.org/patches/bottomstack/ @@ -917,4 +931,4 @@ /* Monocle layout (default). * This can be optionally disabled in favour of other layouts. */ -#define MONOCLE_LAYOUT 1 +#define MONOCLE_LAYOUT 1 \ No newline at end of file -- cgit v1.2.3 From f2da4d20d9a79070863972423ca964cf65342ba7 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 09:26:16 +0200 Subject: Further bar renaming --- patch/bar_ewmhtags.c | 40 ++++++++++++++++ patch/bar_ewmhtags.h | 7 +++ patch/bar_holdbar.c | 99 +++++++++++++++++++++++++++++++++++++++ patch/bar_holdbar.h | 3 ++ patch/bar_statuscolors.c | 27 +++++++++++ patch/ewmhtags.c | 40 ---------------- patch/ewmhtags.h | 7 --- patch/holdbar.c | 99 --------------------------------------- patch/holdbar.h | 3 -- patch/include.c | 27 +++++------ patch/include.h | 21 ++++----- patch/statuscmd.c | 18 -------- patch/statuscmd.h | 1 - patch/statuscolors.c | 27 ----------- patch/taggrid.c | 118 ----------------------------------------------- patch/taggrid.h | 2 - 16 files changed, 197 insertions(+), 342 deletions(-) create mode 100644 patch/bar_ewmhtags.c create mode 100644 patch/bar_ewmhtags.h create mode 100644 patch/bar_holdbar.c create mode 100644 patch/bar_holdbar.h create mode 100644 patch/bar_statuscolors.c delete mode 100644 patch/ewmhtags.c delete mode 100644 patch/ewmhtags.h delete mode 100644 patch/holdbar.c delete mode 100644 patch/holdbar.h delete mode 100644 patch/statuscmd.c delete mode 100644 patch/statuscmd.h delete mode 100644 patch/statuscolors.c delete mode 100644 patch/taggrid.c delete mode 100644 patch/taggrid.h diff --git a/patch/bar_ewmhtags.c b/patch/bar_ewmhtags.c new file mode 100644 index 0000000..682d900 --- /dev/null +++ b/patch/bar_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/bar_ewmhtags.h b/patch/bar_ewmhtags.h new file mode 100644 index 0000000..2ec890e --- /dev/null +++ b/patch/bar_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/bar_holdbar.c b/patch/bar_holdbar.c new file mode 100644 index 0000000..4be9af1 --- /dev/null +++ b/patch/bar_holdbar.c @@ -0,0 +1,99 @@ +void +holdbar(const Arg *arg) +{ + if (selmon->showbar) + return; + selmon->showbar = 2; + updateholdbarpos(selmon); + #if BAR_PADDING_PATCH + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); + #else + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + #endif // BAR_PADDING_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); + #else + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); + #endif // BAR_PADDING_PATCH + #endif // BAR_EXTRABAR_PATCH +} + +void +keyrelease(XEvent *e) +{ + if (XEventsQueued(dpy, QueuedAfterReading)) { + XEvent ne; + XPeekEvent(dpy, &ne); + + if (ne.type == KeyPress && ne.xkey.time == e->xkey.time && + ne.xkey.keycode == e->xkey.keycode) { + XNextEvent(dpy, &ne); + return; + } + } + if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY) && selmon->showbar == 2) { + selmon->showbar = 0; + updateholdbarpos(selmon); + #if BAR_PADDING_PATCH + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); + #else + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + #endif // BAR_PADDING_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); + #else + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); + #endif // BAR_PADDING_PATCH + #endif // BAR_EXTRABAR_PATCH + arrange(selmon); + } + #if COMBO_PATCH + combo = 0; + #endif // COMBO_PATCH +} + +void +updateholdbarpos(Monitor *m) +{ + m->wy = m->my; + m->wh = m->mh; + #if BAR_EXTRABAR_PATCH + #if BAR_PADDING_PATCH + m->wh = m->wh - vertpad * m->showbar * 2 - bh * m->showbar * 2; + m->wy = m->showbar ? m->wy + bh + vertpad: m->wy; + if (m->showbar) { + m->by = m->topbar ? m->wy - bh - vertpad: m->wy + m->wh + vertpad; + m->eby = m->topbar ? m->wy + m->wh + vertpad: m->wy - bh - vertpad; + } else { + m->by = -bh - vertpad; + m->eby = -bh - vertpad; + } + #else + m->wh = m->wh - bh * m->showbar * 2; + m->wy = m->showbar ? m->wy + bh : m->wy; + if (m->showbar) { + m->by = m->topbar ? m->wy - bh : m->wy + m->wh; + m->eby = m->topbar ? m->wy + m->wh : m->wy - bh; + } else { + m->by = -bh; + m->eby = -bh; + } + #endif // BAR_PADDING_PATCH + #elif BAR_PADDING_PATCH + if (m->showbar) { + m->wh = m->wh - vertpad - bh; + m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; + m->wy = m->topbar ? m->wy + bh + vp : m->wy; + } else + m->by = -bh - vp; + #else + if (m->showbar) { + m->wh -= bh; + m->by = m->topbar ? m->wy : m->wy + m->wh; + m->wy = m->topbar ? m->wy + bh : m->wy; + } else + m->by = -bh; + #endif // BAR_EXTRABAR_PATCH +} diff --git a/patch/bar_holdbar.h b/patch/bar_holdbar.h new file mode 100644 index 0000000..719b9ea --- /dev/null +++ b/patch/bar_holdbar.h @@ -0,0 +1,3 @@ +static void keyrelease(XEvent *e); +static void holdbar(const Arg *arg); +static void updateholdbarpos(Monitor *m); \ No newline at end of file diff --git a/patch/bar_statuscolors.c b/patch/bar_statuscolors.c new file mode 100644 index 0000000..cc24ad4 --- /dev/null +++ b/patch/bar_statuscolors.c @@ -0,0 +1,27 @@ +int +textw_wosc(char *s) +{ + char *ts = s; + char *tp = s; + int sw = 0; + char ctmp; + while (1) { + if ((unsigned int)*ts > LENGTH(colors)) { + ts++; + continue; + } + ctmp = *ts; + *ts = '\0'; + #if BAR_PANGO_PATCH + sw += drw_font_getwidth(drw, tp, True); + #else + sw += drw_fontset_getwidth(drw, tp); + #endif // BAR_PANGO_PATCH + *ts = ctmp; + if (ctmp == '\0') + break; + tp = ++ts; + } + + return sw; +} \ No newline at end of file diff --git a/patch/ewmhtags.c b/patch/ewmhtags.c deleted file mode 100644 index 682d900..0000000 --- a/patch/ewmhtags.c +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index 2ec890e..0000000 --- a/patch/ewmhtags.h +++ /dev/null @@ -1,7 +0,0 @@ -#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/holdbar.c b/patch/holdbar.c deleted file mode 100644 index 4be9af1..0000000 --- a/patch/holdbar.c +++ /dev/null @@ -1,99 +0,0 @@ -void -holdbar(const Arg *arg) -{ - if (selmon->showbar) - return; - selmon->showbar = 2; - updateholdbarpos(selmon); - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #endif // BAR_EXTRABAR_PATCH -} - -void -keyrelease(XEvent *e) -{ - if (XEventsQueued(dpy, QueuedAfterReading)) { - XEvent ne; - XPeekEvent(dpy, &ne); - - if (ne.type == KeyPress && ne.xkey.time == e->xkey.time && - ne.xkey.keycode == e->xkey.keycode) { - XNextEvent(dpy, &ne); - return; - } - } - if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY) && selmon->showbar == 2) { - selmon->showbar = 0; - updateholdbarpos(selmon); - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #endif // BAR_EXTRABAR_PATCH - arrange(selmon); - } - #if COMBO_PATCH - combo = 0; - #endif // COMBO_PATCH -} - -void -updateholdbarpos(Monitor *m) -{ - m->wy = m->my; - m->wh = m->mh; - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - m->wh = m->wh - vertpad * m->showbar * 2 - bh * m->showbar * 2; - m->wy = m->showbar ? m->wy + bh + vertpad: m->wy; - if (m->showbar) { - m->by = m->topbar ? m->wy - bh - vertpad: m->wy + m->wh + vertpad; - m->eby = m->topbar ? m->wy + m->wh + vertpad: m->wy - bh - vertpad; - } else { - m->by = -bh - vertpad; - m->eby = -bh - vertpad; - } - #else - m->wh = m->wh - bh * m->showbar * 2; - m->wy = m->showbar ? m->wy + bh : m->wy; - if (m->showbar) { - m->by = m->topbar ? m->wy - bh : m->wy + m->wh; - m->eby = m->topbar ? m->wy + m->wh : m->wy - bh; - } else { - m->by = -bh; - m->eby = -bh; - } - #endif // BAR_PADDING_PATCH - #elif BAR_PADDING_PATCH - if (m->showbar) { - m->wh = m->wh - vertpad - bh; - m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; - m->wy = m->topbar ? m->wy + bh + vp : m->wy; - } else - m->by = -bh - vp; - #else - if (m->showbar) { - m->wh -= bh; - m->by = m->topbar ? m->wy : m->wy + m->wh; - m->wy = m->topbar ? m->wy + bh : m->wy; - } else - m->by = -bh; - #endif // BAR_EXTRABAR_PATCH -} diff --git a/patch/holdbar.h b/patch/holdbar.h deleted file mode 100644 index 719b9ea..0000000 --- a/patch/holdbar.h +++ /dev/null @@ -1,3 +0,0 @@ -static void keyrelease(XEvent *e); -static void holdbar(const Arg *arg); -static void updateholdbarpos(Monitor *m); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 5cde652..e35033e 100644 --- a/patch/include.c +++ b/patch/include.c @@ -8,6 +8,12 @@ #if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH #include "bar_dwmblocks.c" #endif +#if BAR_EWMHTAGS_PATCH +#include "bar_ewmhtags.c" +#endif +#if BAR_HOLDBAR_PATCH +#include "bar_holdbar.c" +#endif #if BAR_LTSYMBOL_PATCH #include "bar_ltsymbol.c" #endif @@ -26,6 +32,9 @@ #if BAR_STATUSCMD_PATCH #include "bar_statuscmd.c" #endif +#if BAR_STATUSCOLORS_PATCH +#include "bar_statuscolors.c" +#endif #if BAR_TAGS_PATCH #include "bar_tags.c" #endif @@ -44,6 +53,9 @@ #if BAR_SYSTRAY_PATCH #include "bar_systray.c" #endif +#if BAR_VTCOLORS_PATCH +#include "bar_vtcolors.c" +#endif /* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH @@ -72,9 +84,6 @@ #elif FSIGNAL_PATCH #include "fsignal.c" #endif -#if BAR_EWMHTAGS_PATCH -#include "ewmhtags.c" -#endif #if EXRESIZE_PATCH #include "exresize.c" #endif @@ -93,9 +102,6 @@ #if FULLSCREEN_PATCH #include "fullscreen.c" #endif -#if BAR_HOLDBAR_PATCH -#include "holdbar.c" -#endif #if INPLACEROTATE_PATCH #include "inplacerotate.c" #endif @@ -166,9 +172,6 @@ #if STACKER_PATCH #include "stacker.c" #endif -#if BAR_STATUSCOLORS_PATCH -#include "statuscolors.c" -#endif #if STICKY_PATCH #include "sticky.c" #endif @@ -190,9 +193,6 @@ #if TAGALLMON_PATCH #include "tagallmon.c" #endif -#if TAGGRID_PATCH -#include "taggrid.c" -#endif #if TAGOTHERMONITOR_PATCH #include "tagothermonitor.c" #endif @@ -214,9 +214,6 @@ #if VANITYGAPS_PATCH #include "vanitygaps.c" #endif -#if BAR_VTCOLORS_PATCH -#include "vtcolors.c" -#endif #if WARP_PATCH #include "warp.c" #endif diff --git a/patch/include.h b/patch/include.h index 49ce915..9065c87 100644 --- a/patch/include.h +++ b/patch/include.h @@ -8,6 +8,12 @@ #if BAR_DWMBLOCKS_PATCH && BAR_STATUSCMD_PATCH #include "bar_dwmblocks.h" #endif +#if BAR_EWMHTAGS_PATCH +#include "bar_ewmhtags.h" +#endif +#if BAR_HOLDBAR_PATCH +#include "bar_holdbar.h" +#endif #if BAR_LTSYMBOL_PATCH #include "bar_ltsymbol.h" #endif @@ -44,6 +50,9 @@ #if BAR_SYSTRAY_PATCH #include "bar_systray.h" #endif +#if BAR_VTCOLORS_PATCH +#include "bar_vtcolors.h" +#endif /* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH @@ -75,9 +84,6 @@ #elif FSIGNAL_PATCH #include "fsignal.h" #endif -#if BAR_EWMHTAGS_PATCH -#include "ewmhtags.h" -#endif #if EXRESIZE_PATCH #include "exresize.h" #endif @@ -96,9 +102,6 @@ #if FULLSCREEN_PATCH #include "fullscreen.h" #endif -#if BAR_HOLDBAR_PATCH -#include "holdbar.h" -#endif #if INPLACEROTATE_PATCH #include "inplacerotate.h" #endif @@ -190,9 +193,6 @@ #if TAGALLMON_PATCH #include "tagallmon.h" #endif -#if TAGGRID_PATCH -#include "taggrid.h" -#endif #if TAGOTHERMONITOR_PATCH #include "tagothermonitor.h" #endif @@ -214,9 +214,6 @@ #if VANITYGAPS_PATCH #include "vanitygaps.h" #endif -#if BAR_VTCOLORS_PATCH -#include "vtcolors.h" -#endif #if WARP_PATCH #include "warp.h" #endif diff --git a/patch/statuscmd.c b/patch/statuscmd.c deleted file mode 100644 index b38739d..0000000 --- a/patch/statuscmd.c +++ /dev/null @@ -1,18 +0,0 @@ -#if !DWMBLOCKS_PATCH -static const char statusexport[] = "export BUTTON=-;"; -static int statuscmdn; -static int lastbutton; -#endif // DWMBLOCKS_PATCH - -void -copyvalidchars(char *text, char *rawtext) -{ - int i = -1, j = 0; - - while (rawtext[++i]) { - if ((unsigned char)rawtext[i] >= ' ') { - text[j++] = rawtext[i]; - } - } - text[j] = '\0'; -} diff --git a/patch/statuscmd.h b/patch/statuscmd.h deleted file mode 100644 index 77391b6..0000000 --- a/patch/statuscmd.h +++ /dev/null @@ -1 +0,0 @@ -static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file diff --git a/patch/statuscolors.c b/patch/statuscolors.c deleted file mode 100644 index cc24ad4..0000000 --- a/patch/statuscolors.c +++ /dev/null @@ -1,27 +0,0 @@ -int -textw_wosc(char *s) -{ - char *ts = s; - char *tp = s; - int sw = 0; - char ctmp; - while (1) { - if ((unsigned int)*ts > LENGTH(colors)) { - ts++; - continue; - } - ctmp = *ts; - *ts = '\0'; - #if BAR_PANGO_PATCH - sw += drw_font_getwidth(drw, tp, True); - #else - sw += drw_fontset_getwidth(drw, tp); - #endif // BAR_PANGO_PATCH - *ts = ctmp; - if (ctmp == '\0') - break; - tp = ++ts; - } - - return sw; -} \ No newline at end of file diff --git a/patch/taggrid.c b/patch/taggrid.c deleted file mode 100644 index bfa19ec..0000000 --- a/patch/taggrid.c +++ /dev/null @@ -1,118 +0,0 @@ -void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ) -{ - unsigned int x, y, h, max_x, columns; - int invert, i,j, k; - - h = bh / tagrows; - x = max_x = *x_pos; - y = 0; - columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - - /* Firstly we will fill the borders of squares */ - - XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBorder].pixel); - XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); - - /* We will draw LENGTH(tags) squares in tagraws raws. */ - for (j = 0, i= 0; j < tagrows; j++) { - x = *x_pos; - for (k = 0; k < columns && i < LENGTH(tags); k++, i++) { - invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; - - /* Select active color for current square */ - XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel : - scheme[SchemeNorm][ColFg].pixel); - XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); - - /* Mark square if tag has client */ - if (occ & 1 << i) { - XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel : - scheme[SchemeNorm][ColBg].pixel); - XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, - h / 2, h / 2); - } - x += h; - if (x > max_x) { - max_x = x; - } - } - y += h; - } - *x_pos = max_x + 1; -} - -void switchtag(const Arg *arg) -{ - unsigned int columns; - unsigned int new_tagset = 0; - unsigned int pos, i; - int col, row; - Arg new_arg; - - columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - - for (i = 0; i < LENGTH(tags); ++i) { - if (!(selmon->tagset[selmon->seltags] & 1 << i)) { - continue; - } - pos = i; - row = pos / columns; - col = pos % columns; - if (arg->ui & SWITCHTAG_UP) { /* UP */ - row --; - if (row < 0) { - row = tagrows - 1; - } - do { - pos = row * columns + col; - row --; - } while (pos >= LENGTH(tags)); - } - if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */ - row ++; - if (row >= tagrows) { - row = 0; - } - pos = row * columns + col; - if (pos >= LENGTH(tags)) { - row = 0; - } - pos = row * columns + col; - } - if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */ - col --; - if (col < 0) { - col = columns - 1; - } - do { - pos = row * columns + col; - col --; - } while (pos >= LENGTH(tags)); - } - if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */ - col ++; - if (col >= columns) { - col = 0; - } - pos = row * columns + col; - if (pos >= LENGTH(tags)) { - col = 0; - pos = row * columns + col; - } - } - new_tagset |= 1 << pos; - } - new_arg.ui = new_tagset; - if (arg->ui & SWITCHTAG_TOGGLETAG) { - toggletag(&new_arg); - } - if (arg->ui & SWITCHTAG_TAG) { - tag(&new_arg); - } - if (arg->ui & SWITCHTAG_VIEW) { - view (&new_arg); - } - if (arg->ui & SWITCHTAG_TOGGLEVIEW) { - toggleview (&new_arg); - } -} \ No newline at end of file diff --git a/patch/taggrid.h b/patch/taggrid.h deleted file mode 100644 index 27343a6..0000000 --- a/patch/taggrid.h +++ /dev/null @@ -1,2 +0,0 @@ -static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ); -static void switchtag(const Arg *arg); \ No newline at end of file -- cgit v1.2.3 From aa70728d0049f771820f17cfca4488768cf57cef Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 14:10:47 +0200 Subject: Adding BarWidthArg, BarDrawArg, BarClickArg to keep the method signatures static --- dwm.c | 112 ++++++++++++++++++++++------------------------- patch/bar_awesomebar.c | 20 ++++----- patch/bar_awesomebar.h | 6 +-- patch/bar_fancybar.c | 10 ++--- patch/bar_fancybar.h | 6 +-- patch/bar_ltsymbol.c | 10 ++--- patch/bar_ltsymbol.h | 6 +-- patch/bar_status.c | 10 ++--- patch/bar_status.h | 6 +-- patch/bar_status2d.c | 8 ++-- patch/bar_status2d.h | 6 +-- patch/bar_status2d_eb.c | 6 +-- patch/bar_status2d_eb.h | 4 +- patch/bar_statusbutton.c | 10 ++--- patch/bar_statusbutton.h | 6 +-- patch/bar_statuscmd.c | 10 ++--- patch/bar_statuscmd.h | 6 +-- patch/bar_systray.c | 10 ++--- patch/bar_systray.h | 6 +-- patch/bar_taggrid.c | 12 ++--- patch/bar_taggrid.h | 6 +-- patch/bar_tags.c | 9 ++-- patch/bar_tags.h | 6 +-- patch/bar_vtcolors.c | 70 +++++++++++++++++++++++++++++ patch/bar_vtcolors.h | 2 + patch/bar_wintitle.c | 31 +++++-------- patch/bar_wintitle.h | 6 +-- 27 files changed, 227 insertions(+), 173 deletions(-) create mode 100644 patch/bar_vtcolors.c create mode 100644 patch/bar_vtcolors.h diff --git a/dwm.c b/dwm.c index eca9c91..7828403 100644 --- a/dwm.c +++ b/dwm.c @@ -168,12 +168,8 @@ enum { #if BAR_STATUSBUTTON_PATCH ClkButton, #endif // BAR_STATUSBUTTON_PATCH - #if BAR_TAGS_PATCH ClkTagBar, - #endif // BAR_TAGS_PATCH - #if BAR_LTSYMBOL_PATCH ClkLtSymbol, - #endif // BAR_LTSYMBOL_PATCH ClkStatusText, ClkWinTitle, ClkClientWin, @@ -210,14 +206,31 @@ struct Bar { int x[BARRULES]; // x position, array length == ^ }; + +typedef struct { + int max_width; +} BarWidthArg; + +typedef struct { + int x; + int w; +} BarDrawArg; + +typedef struct { + int rel_x; + int rel_y; + int rel_w; + int rel_h; +} BarClickArg; + typedef struct Monitor Monitor; typedef struct { int monitor; int bar; int alignment; // see bar alignment enum - int (*widthfunc)(Monitor *m, int max_width); - int (*drawfunc)(Monitor *m, int x, int w); - int (*clickfunc)(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); + int (*widthfunc)(Monitor *m, BarWidthArg *a); + int (*drawfunc)(Monitor *m, BarDrawArg *a); + int (*clickfunc)(Monitor *m, Arg *arg, BarClickArg *a); char *name; // for debugging int x, w; // position, width for internal use } BarRule; @@ -552,11 +565,13 @@ static char stext[1024]; #else static char stext[512]; #endif // BAR_STATUS2D_PATCH +#if BAR_EXTRABAR_PATCH || BAR_STATUSCMD_PATCH #if BAR_STATUS2D_PATCH static char rawstext[1024]; #else static char rawstext[512]; #endif // BAR_STATUS2D_PATCH +#endif // BAR_EXTRABAR_PATCH | BAR_STATUSCMD_PATCH #if BAR_EXTRABAR_PATCH #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH static char estext[1024]; @@ -873,6 +888,7 @@ buttonpress(XEvent *e) Monitor *m; XButtonPressedEvent *ev = &e->xbutton; const BarRule *br; + BarClickArg carg = { 0, 0, 0, 0 }; click = ClkRootWin; /* focus monitor if necessary */ @@ -889,19 +905,23 @@ buttonpress(XEvent *e) for (mi = 0, m = mons; m && m != selmon; m = m->next, mi++); // get the monitor index for (b = 0; b < LENGTH(selmon->bars); b++) { if (ev->window == selmon->bars[b]->win) { - fprintf(stderr, "buttonpress on bar, mi = %d\n", mi); for (r = 0; r < LENGTH(barrules); r++) { br = &barrules[r]; if (br->bar != b || (br->monitor == 'A' && m != selmon) || (br->monitor != -1 && br->monitor != mi) || br->clickfunc == NULL) continue; if (selmon->bars[b]->x[r] <= ev->x && ev->x <= selmon->bars[b]->x[r] + selmon->bars[b]->w[r]) { - click = br->clickfunc(m, &arg, ev->x - selmon->bars[b]->x[r], ev->y, selmon->bars[b]->w[r], bh); + carg.rel_x = ev->x - selmon->bars[b]->x[r]; + carg.rel_y = ev->y; + carg.rel_w = selmon->bars[b]->w[r]; + carg.rel_h = selmon->bars[b]->bh; + click = br->clickfunc(m, &arg, &carg); + if (click < 0) + return; break; } } break; } - } if (click == ClkRootWin && (c = wintoclient(ev->window))) { @@ -915,17 +935,17 @@ buttonpress(XEvent *e) XAllowEvents(dpy, ReplayPointer, CurrentTime); click = ClkClientWin; } - fprintf(stderr, "click = %d, dwmblockssig = %d, ev->button = %d, mi = %d\n", click, dwmblockssig, ev->button, mi); - for (i = 0; i < LENGTH(buttons); i++) + + for (i = 0; i < LENGTH(buttons); i++) { if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button - && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) { - fprintf(stderr, "found click, b.button (%d) == ev->button (%d)\n", buttons[i].button, ev->button); + && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) { #if BAR_AWESOMEBAR_PATCH buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); #else buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); #endif } + } } void @@ -1423,24 +1443,21 @@ void drawbar(Monitor *m) { Monitor *mon; - int b, r, mi; - int ret_x, w; + int b, r, w, mi; int rx, lx, rw, lw; // bar size, split between left and right if a center module is added const BarRule *br; Bar *bar; + BarWidthArg warg = { 0 }; + BarDrawArg darg = { 0, 0 }; for (mi = 0, mon = mons; mon && mon != m; mon = mon->next, mi++); // get the monitor index for (b = LENGTH(m->bars) - 1; b >= 0; b--) { - fprintf(stderr, "drawbar, monitor m = %ld, mi = %d, b = %d\n", m, mi, b); bar = m->bars[b]; - if (!bar->win) { - fprintf(stderr, "%s\n", "bar->win does not exist"); + if (!bar->win) continue; - } rw = lw = bar->bw; rx = lx = 0; - fprintf(stderr, "lx = %d, lw = %d\n", lx, lw); #if BAR_VTCOLORS_PATCH drw_setscheme(drw, scheme[SchemeTagsNorm]); @@ -1457,13 +1474,18 @@ drawbar(Monitor *m) #else drw_setscheme(drw, scheme[SchemeNorm]); #endif // BAR_VTCOLORS_PATCH - if (br->alignment < BAR_ALIGN_RIGHT_LEFT) { - w = br->widthfunc(m, lw); - w = MIN(lw, w); - } else { - w = br->widthfunc(m, rw); - w = MIN(rw, w); + warg.max_width = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw); + w = br->widthfunc(m, &warg); + w = MIN(warg.max_width, w); + + if (lw <= 0) { // if left is exhausted, switch to right side + lw = rw; + lx = rx; + } else if (rw <= 0) { + rw = lw; + rx = lx; } + switch(br->alignment) { default: case BAR_ALIGN_NONE: @@ -1523,16 +1545,9 @@ drawbar(Monitor *m) rw = bar->x[r] - rx; break; } - ret_x = br->drawfunc(m, bar->x[r], bar->w[r]); - if (ret_x != bar->x[r] + bar->w[r]) - fprintf(stderr, "%s - %d alignment, expected these to be the same: %d vs %d, w = %d, bx = %d\n", br->name, br->alignment, ret_x, bar->x[r] + bar->w[r], bar->w[r], bar->x[r]); - - if (lw <= 0) { // if left is exhausted, switch to right side - lw = rw; - lx = rx; - rw = 0; - rx = 0; - } + darg.x = bar->x[r]; + darg.w = bar->w[r]; + br->drawfunc(m, &darg); } drw_map(drw, bar->win, 0, 0, bar->bw, bar->bh); } @@ -2897,26 +2912,9 @@ setup(void) #else scheme[i] = drw_scm_create(drw, colors[i], ColCount); #endif // BAR_ALPHA_PATCH - // #if BAR_SYSTRAY_PATCH - // /* init system tray */ - // if (showsystray) - // updatesystray(); - // #endif // BAR_SYSTRAY_PATCH - /* init bars */ - // Monitor *m; - // for (m = mons; m; m = m->next) { - // fprintf(stderr, "updating bar pos\n"); - // updatebarpos(m); - // } updatebars(); updatestatus(); - // Monitor *m; - // for (m = mons; m; m = m->next) - // updatebarpos(m); - // for () - // updatebarpos(selmon); - /* supporting window for NetWMCheck */ wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0); XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32, @@ -3440,7 +3438,6 @@ updatebars(void) for (m = mons; m; m = m->next) { for (b = 0; b < LENGTH(m->bars); b++) { if (!m->bars[b]->win) { // TODO add static status controls to not create / show extra bar? - fprintf(stderr, "creating bar %d at pos x = %d, y = %d, w = %d, h = %d\n", b, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh); #if BAR_ALPHA_PATCH m->bars[b]->win = XCreateWindow(dpy, root, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, 0, depth, InputOutput, visual, @@ -3472,26 +3469,21 @@ updatebarpos(Monitor *m) int x_pad = 0; #endif // BAR_PADDING_PATCH - // for (num_bars = 0; num_bars < LENGTH(m->bars) && m->bars[num_bars]->win; num_bars++); num_bars = LENGTH(m->bars); - fprintf(stderr, "num_bars = %d\n", num_bars); if (m->showbar) { m->wh = m->wh - y_pad * num_bars - bh * num_bars; m->wy = m->wy + bh + y_pad; } for (b = 0; b < num_bars; b++) { - fprintf(stderr, "setting bx to xpad %d, b = %d\n", m->mx + x_pad, b); m->bars[b]->bx = m->mx + x_pad; m->bars[b]->bw = m->ww - 2 * x_pad; m->bars[b]->bh = bh; if (m->showbar) { - fprintf(stderr, "eh? %d, b = %d\n", topbar == b, b); m->bars[b]->by = m->topbar == b ? m->wy + m->wh : m->wy - bh; } else { m->bars[b]->by = -bh - y_pad; } - fprintf(stderr, "finished with bar, bx = %d, by = %d, bw = %d, bh = %d, m = %ld\n", m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, m); } } diff --git a/patch/bar_awesomebar.c b/patch/bar_awesomebar.c index 85ec003..ddea5ea 100644 --- a/patch/bar_awesomebar.c +++ b/patch/bar_awesomebar.c @@ -1,22 +1,22 @@ int -width_awesomebar(Monitor *m, int max_width) +width_awesomebar(Monitor *m, BarWidthArg *a) { - return max_width; + return a->max_width; } int -draw_awesomebar(Monitor *m, int x_orig, int w) +draw_awesomebar(Monitor *m, BarDrawArg *a) { int n = 0, scm, remainder = 0, tabw; - unsigned int i, x = x_orig; + unsigned int i, x = a->x; Client *c; for (c = m->clients; c; c = c->next) if (ISVISIBLE(c)) n++; if (n > 0) { - remainder = w % n; - tabw = w / n; + remainder = a->w % n; + tabw = a->w / n; for (i = 0, c = m->clients; c; c = c->next, i++) { if (!ISVISIBLE(c)) continue; @@ -46,11 +46,11 @@ draw_awesomebar(Monitor *m, int x_orig, int w) x += tabw; } } - return x_orig + w; + return a->x + a->w; } int -click_awesomebar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a) { int x = 0, n = 0; Client *c; @@ -65,8 +65,8 @@ click_awesomebar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_ if (!c || !ISVISIBLE(c)) continue; else - x += (1.0 / (double)n) * rel_w; - } while (c && rel_x > x && (c = c->next)); + x += (1.0 / (double)n) * a->rel_w; + } while (c && a->rel_x > x && (c = c->next)); if (c) { arg->v = c; diff --git a/patch/bar_awesomebar.h b/patch/bar_awesomebar.h index 84c8505..8e9387b 100644 --- a/patch/bar_awesomebar.h +++ b/patch/bar_awesomebar.h @@ -1,6 +1,6 @@ -static int width_awesomebar(Monitor *m, int max_width); -static int draw_awesomebar(Monitor *m, int x, int w); -static int click_awesomebar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int width_awesomebar(Monitor *m, BarWidthArg *a); +static int draw_awesomebar(Monitor *m, BarDrawArg *a); +static int click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a); static void hide(Client *c); static void show(Client *c); diff --git a/patch/bar_fancybar.c b/patch/bar_fancybar.c index b6f5363..810c73e 100644 --- a/patch/bar_fancybar.c +++ b/patch/bar_fancybar.c @@ -1,13 +1,13 @@ int -width_fancybar(Monitor *m, int max_width) +width_fancybar(Monitor *m, BarWidthArg *a) { - return max_width; + return a->max_width; } int -draw_fancybar(Monitor *m, int x, int w) +draw_fancybar(Monitor *m, BarDrawArg *a) { - int ftw, mw, ew = 0, n = 0; + int ftw, mw, ew = 0, n = 0, x = a->x, w = a->w; unsigned int i; Client *c; #if !BAR_HIDEVACANTTAGS_PATCH @@ -89,7 +89,7 @@ draw_fancybar(Monitor *m, int x, int w) } int -click_fancybar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_fancybar(Monitor *m, Arg *arg, BarClickArg *a) { return ClkWinTitle; } diff --git a/patch/bar_fancybar.h b/patch/bar_fancybar.h index 24336d9..b7b2875 100644 --- a/patch/bar_fancybar.h +++ b/patch/bar_fancybar.h @@ -1,3 +1,3 @@ -static int width_fancybar(Monitor *m, int max_width); -static int draw_fancybar(Monitor *m, int x, int w); -static int click_fancybar(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file +static int width_fancybar(Monitor *m, BarWidthArg *a); +static int draw_fancybar(Monitor *m, BarDrawArg *a); +static int click_fancybar(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_ltsymbol.c b/patch/bar_ltsymbol.c index f4417f1..c3a7baf 100644 --- a/patch/bar_ltsymbol.c +++ b/patch/bar_ltsymbol.c @@ -1,21 +1,21 @@ int -width_ltsymbol(Monitor *m, int max_width) +width_ltsymbol(Monitor *m, BarWidthArg *a) { return TEXTW(m->ltsymbol); } int -draw_ltsymbol(Monitor *m, int x, int w) +draw_ltsymbol(Monitor *m, BarDrawArg *a) { #if BAR_PANGO_PATCH - return drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0, False); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0, False); #else - return drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0); #endif // BAR_PANGO_PATCH } int -click_ltsymbol(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a) { return ClkLtSymbol; } \ No newline at end of file diff --git a/patch/bar_ltsymbol.h b/patch/bar_ltsymbol.h index 5471496..40f5c55 100644 --- a/patch/bar_ltsymbol.h +++ b/patch/bar_ltsymbol.h @@ -1,3 +1,3 @@ -static int width_ltsymbol(Monitor *m, int max_width); -static int draw_ltsymbol(Monitor *m, int x, int w); -static int click_ltsymbol(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int width_ltsymbol(Monitor *m, BarWidthArg *a); +static int draw_ltsymbol(Monitor *m, BarDrawArg *a); +static int click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a); diff --git a/patch/bar_status.c b/patch/bar_status.c index fdf72de..2d7283b 100644 --- a/patch/bar_status.c +++ b/patch/bar_status.c @@ -1,5 +1,5 @@ int -width_status(Monitor *m, int max_width) +width_status(Monitor *m, BarWidthArg *a) { #if BAR_PANGO_PATCH return TEXTWM(stext) - lrpad + 2; /* 2px right padding */ @@ -9,17 +9,17 @@ width_status(Monitor *m, int max_width) } int -draw_status(Monitor *m, int x, int w) +draw_status(Monitor *m, BarDrawArg *a) { #if BAR_PANGO_PATCH - return drw_text(drw, x, 0, w, bh, 0, stext, 0, True); + return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0, True); #else - return drw_text(drw, x, 0, w, bh, 0, stext, 0); + return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0); #endif // BAR_PANGO_PATCH } int -click_status(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_status(Monitor *m, Arg *arg, BarClickArg *a) { return ClkStatusText; } diff --git a/patch/bar_status.h b/patch/bar_status.h index 3b6c924..97cf8b8 100644 --- a/patch/bar_status.h +++ b/patch/bar_status.h @@ -1,3 +1,3 @@ -static int width_status(Monitor *m, int max_width); -static int draw_status(Monitor *m, int x, int w); -static int click_status(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file +static int width_status(Monitor *m, BarWidthArg *a); +static int draw_status(Monitor *m, BarDrawArg *a); +static int click_status(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c index 8b3b3e5..61ebd69 100644 --- a/patch/bar_status2d.c +++ b/patch/bar_status2d.c @@ -1,17 +1,17 @@ int -width_status2d(Monitor *m, int max_width) +width_status2d(Monitor *m, BarWidthArg *a) { return status2dtextlength(rawstext); } int -draw_status2d(Monitor *m, int x, int w) +draw_status2d(Monitor *m, BarDrawArg *a) { - return drawstatusbar(m, x, w, rawstext); + return drawstatusbar(m, a->x, a->w, rawstext); } int -click_status2d(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_status2d(Monitor *m, Arg *arg, BarClickArg *a) { return ClkStatusText; } diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index 3f1a346..621fb7f 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -1,5 +1,5 @@ -static int width_status2d(Monitor *m, int max_width); -static int draw_status2d(Monitor *m, int x, int w); -static int click_status2d(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int width_status2d(Monitor *m, BarWidthArg *a); +static int draw_status2d(Monitor *m, BarDrawArg *a); +static int click_status2d(Monitor *m, Arg *arg, BarClickArg *a); static int drawstatusbar(Monitor *m, int x, int w, char* text); static int status2dtextlength(char* stext); \ No newline at end of file diff --git a/patch/bar_status2d_eb.c b/patch/bar_status2d_eb.c index adce774..3e98866 100644 --- a/patch/bar_status2d_eb.c +++ b/patch/bar_status2d_eb.c @@ -1,11 +1,11 @@ int -width_status2d_eb(Monitor *m, int max_width) +width_status2d_eb(Monitor *m, BarWidthArg *a) { return status2dtextlength(rawestext); } int -draw_status2d_eb(Monitor *m, int x, int w) +draw_status2d_eb(Monitor *m, BarDrawArg *a) { - return drawstatusbar(m, x, w, rawestext); + return drawstatusbar(m, a->x, a->w, rawestext); } \ No newline at end of file diff --git a/patch/bar_status2d_eb.h b/patch/bar_status2d_eb.h index 87b41fb..2a43537 100644 --- a/patch/bar_status2d_eb.h +++ b/patch/bar_status2d_eb.h @@ -1,2 +1,2 @@ -static int width_status2d_eb(Monitor *m, int max_width); -static int draw_status2d_eb(Monitor *m, int x, int w); \ No newline at end of file +static int width_status2d_eb(Monitor *m, BarWidthArg *a); +static int draw_status2d_eb(Monitor *m, BarDrawArg *a); \ No newline at end of file diff --git a/patch/bar_statusbutton.c b/patch/bar_statusbutton.c index 130ef62..5f60b76 100644 --- a/patch/bar_statusbutton.c +++ b/patch/bar_statusbutton.c @@ -1,21 +1,21 @@ int -width_stbutton(Monitor *m, int max_width) +width_stbutton(Monitor *m, BarWidthArg *a) { return TEXTW(buttonbar); } int -draw_stbutton(Monitor *m, int x, int w) +draw_stbutton(Monitor *m, BarDrawArg *a) { #if BAR_PANGO_PATCH - return drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0, False); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0, False); #else - return drw_text(drw, x, 0, w, bh, lrpad / 2, buttonbar, 0); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0); #endif // BAR_PANGO_PATCH } int -click_stbutton(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_stbutton(Monitor *m, Arg *arg, BarClickArg *a) { return ClkButton; } diff --git a/patch/bar_statusbutton.h b/patch/bar_statusbutton.h index 84ac2c5..47055ad 100644 --- a/patch/bar_statusbutton.h +++ b/patch/bar_statusbutton.h @@ -1,3 +1,3 @@ -static int width_stbutton(Monitor *m, int max_width); -static int draw_stbutton(Monitor *m, int x, int w); -static int click_stbutton(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file +static int width_stbutton(Monitor *m, BarWidthArg *a); +static int draw_stbutton(Monitor *m, BarDrawArg *a); +static int click_stbutton(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c index f6166c3..14b4076 100644 --- a/patch/bar_statuscmd.c +++ b/patch/bar_statuscmd.c @@ -5,21 +5,21 @@ static int lastbutton; #endif // BAR_DWMBLOCKS_PATCH int -click_statuscmd(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a) { - return click_statuscmd_text(m, arg, rel_x, rel_y, rawstext); + return click_statuscmd_text(m, arg, a->rel_x, rawstext); } #if BAR_EXTRABAR_PATCH int -click_statuscmd_eb(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a) { - return click_statuscmd_text(m, arg, rel_x, rel_y, rawestext); + return click_statuscmd_text(m, arg, a->rel_x, rawestext); } #endif // BAR_EXTRABAR_PATCH int -click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, int rel_y, char *text) +click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text) { int i = -1; int x = 0; diff --git a/patch/bar_statuscmd.h b/patch/bar_statuscmd.h index 92ed7e1..7619ec3 100644 --- a/patch/bar_statuscmd.h +++ b/patch/bar_statuscmd.h @@ -1,6 +1,6 @@ -static int click_statuscmd(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a); #if BAR_EXTRABAR_PATCH -static int click_statuscmd_eb(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a); #endif // BAR_EXTRABAR_PATCH -static int click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, int rel_y, char *text); +static int click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text); static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file diff --git a/patch/bar_systray.c b/patch/bar_systray.c index 9938543..e9df765 100644 --- a/patch/bar_systray.c +++ b/patch/bar_systray.c @@ -5,7 +5,7 @@ static int systraybarrule = -1; static int systrayxpos = 0; int -width_systray(Monitor *m, int max_width) +width_systray(Monitor *m, BarWidthArg *a) { unsigned int w = 0; Client *i; @@ -17,15 +17,15 @@ width_systray(Monitor *m, int max_width) } int -draw_systray(Monitor *m, int x_pos, int w) +draw_systray(Monitor *m, BarDrawArg *a) { - systrayxpos = x_pos; + systrayxpos = a->x; updatesystray(); - return systrayxpos + w; + return systrayxpos + a->w; } int -click_systray(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_systray(Monitor *m, Arg *arg, BarClickArg *a) { return -1; } diff --git a/patch/bar_systray.h b/patch/bar_systray.h index de588d1..5c4f387 100644 --- a/patch/bar_systray.h +++ b/patch/bar_systray.h @@ -26,9 +26,9 @@ struct Systray { }; /* bar integration */ -static int width_systray(Monitor *m, int max_width); -static int draw_systray(Monitor *m, int x_pos, int w); -static int click_systray(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int width_systray(Monitor *m, BarWidthArg *a); +static int draw_systray(Monitor *m, BarDrawArg *a); +static int click_systray(Monitor *m, Arg *arg, BarClickArg *a); /* function declarations */ static Atom getatomprop(Client *c, Atom prop); diff --git a/patch/bar_taggrid.c b/patch/bar_taggrid.c index 4fa98d7..78b3d1c 100644 --- a/patch/bar_taggrid.c +++ b/patch/bar_taggrid.c @@ -1,11 +1,11 @@ int -width_taggrid(Monitor *m, int max_width) +width_taggrid(Monitor *m, BarWidthArg *a) { return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)); } int -draw_taggrid(Monitor *m, int x_pos, int w) +draw_taggrid(Monitor *m, BarDrawArg *a) { unsigned int x, y, h, max_x, columns, occ = 0; int invert, i,j, k; @@ -15,7 +15,7 @@ draw_taggrid(Monitor *m, int x_pos, int w) occ |= c->tags; h = bh / tagrows; - x = max_x = x_pos; + x = max_x = a->x; y = 0; columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); @@ -24,7 +24,7 @@ draw_taggrid(Monitor *m, int x_pos, int w) /* We will draw LENGTH(tags) squares in tagraws raws. */ for (j = 0, i = 0; j < tagrows; j++) { - x = x_pos; + x = a->x; for (k = 0; k < columns && i < LENGTH(tags); k++, i++) { invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; @@ -51,12 +51,12 @@ draw_taggrid(Monitor *m, int x_pos, int w) } int -click_taggrid(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_taggrid(Monitor *m, Arg *arg, BarClickArg *a) { unsigned int i, columns; columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - i = (rel_x - 0) / (bh / tagrows) + columns * (rel_y / (bh / tagrows)); + i = (a->rel_x - 0) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows)); if (i >= LENGTH(tags)) { i = LENGTH(tags) - 1; } diff --git a/patch/bar_taggrid.h b/patch/bar_taggrid.h index ca8a16c..d284a07 100644 --- a/patch/bar_taggrid.h +++ b/patch/bar_taggrid.h @@ -1,4 +1,4 @@ -static int width_taggrid(Monitor *m, int max_width); -static int draw_taggrid(Monitor *m, int x, int w); -static int click_taggrid(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); +static int width_taggrid(Monitor *m, BarWidthArg *a); +static int draw_taggrid(Monitor *m, BarDrawArg *a); +static int click_taggrid(Monitor *m, Arg *arg, BarClickArg *a); static void switchtag(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_tags.c b/patch/bar_tags.c index 73dc5d7..708e61d 100644 --- a/patch/bar_tags.c +++ b/patch/bar_tags.c @@ -1,5 +1,5 @@ int -width_tags(Monitor *m, int max_width) +width_tags(Monitor *m, BarWidthArg *a) { int w, i; for (w = 0, i = 0; i < LENGTH(tags); i++) { @@ -13,9 +13,10 @@ width_tags(Monitor *m, int max_width) } int -draw_tags(Monitor *m, int x, int w) +draw_tags(Monitor *m, BarDrawArg *a) { int invert; + int w, x = a->x; #if BAR_ALTERNATIVE_TAGS_PATCH int wdelta; #endif // BAR_ALTERNATIVE_TAGS_PATCH @@ -106,7 +107,7 @@ draw_tags(Monitor *m, int x, int w) } int -click_tags(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_tags(Monitor *m, Arg *arg, BarClickArg *a) { int i = 0, x = 0; do @@ -115,7 +116,7 @@ click_tags(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) #else x += TEXTW(tags[i]); #endif - while (rel_x >= x && ++i < LENGTH(tags)); + while (a->rel_x >= x && ++i < LENGTH(tags)); if (i < LENGTH(tags)) { arg->ui = 1 << i; } diff --git a/patch/bar_tags.h b/patch/bar_tags.h index 788c488..9961f1a 100644 --- a/patch/bar_tags.h +++ b/patch/bar_tags.h @@ -1,3 +1,3 @@ -static int width_tags(Monitor *m, int max_width); -static int draw_tags(Monitor *m, int x, int w); -static int click_tags(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file +static int width_tags(Monitor *m, BarWidthArg *a); +static int draw_tags(Monitor *m, BarDrawArg *a); +static int click_tags(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_vtcolors.c b/patch/bar_vtcolors.c new file mode 100644 index 0000000..349970f --- /dev/null +++ b/patch/bar_vtcolors.c @@ -0,0 +1,70 @@ +void +get_vt_colors(void) +{ + char *cfs[3] = { + "/sys/module/vt/parameters/default_red", + "/sys/module/vt/parameters/default_grn", + "/sys/module/vt/parameters/default_blu", + }; + char vtcs[16][8]; + char tk[] = ","; + char cl[64]; + char *tp = NULL; + FILE *fp; + size_t r; + int i, c, n; + + for (i = 0; i < 16; i++) + strcpy(vtcs[i], "#000000"); + + for (i = 0, r = 0; i < 3; i++) { + if ((fp = fopen(cfs[i], "r")) == NULL) + continue; + while ((cl[r] = fgetc(fp)) != EOF && cl[r] != '\n') + r++; + cl[r] = '\0'; + for (c = 0, tp = cl, n = 0; c < 16; c++, tp++) { + if ((r = strcspn(tp, tk)) == -1) + break; + for (n = 0; r && *tp >= 48 && *tp < 58; r--, tp++) + n = n * 10 - 48 + *tp; + vtcs[c][i * 2 + 1] = n / 16 < 10 ? n / 16 + 48 : n / 16 + 87; + vtcs[c][i * 2 + 2] = n % 16 < 10 ? n % 16 + 48 : n % 16 + 87; + } + fclose(fp); + } + for (i = 0; i < LENGTH(colors); i++) { + #if FLOAT_BORDER_COLOR_PATCH + for (c = 0; c < 4; c++) + #else + for (c = 0; c < 3; c++) + #endif // FLOAT_BORDER_COLOR_PATCH + { + n = color_ptrs[i][c]; + if (n > -1 && strlen(colors[i][c]) >= strlen(vtcs[n])) + memcpy(colors[i][c], vtcs[n], 7); + } + } +} + +int get_luminance(char *r) +{ + char *c = r; + int n[3] = {0}; + int i = 0; + + while (*c) { + if (*c >= 48 && *c < 58) + n[i / 2] = n[i / 2] * 16 - 48 + *c; + else if (*c >= 65 && *c < 71) + n[i / 2] = n[i / 2] * 16 - 55 + *c; + else if (*c >= 97 && *c < 103) + n[i / 2] = n[i / 2] * 16 - 87 + *c; + else + i--; + i++; + c++; + } + + return (0.299 * n[0] + 0.587 * n[1] + 0.114 * n[2]) / 2.55; +} \ No newline at end of file diff --git a/patch/bar_vtcolors.h b/patch/bar_vtcolors.h new file mode 100644 index 0000000..7341e6a --- /dev/null +++ b/patch/bar_vtcolors.h @@ -0,0 +1,2 @@ +static void get_vt_colors(void); +static int get_luminance(char *rgb); \ No newline at end of file diff --git a/patch/bar_wintitle.c b/patch/bar_wintitle.c index e937723..36889c1 100644 --- a/patch/bar_wintitle.c +++ b/patch/bar_wintitle.c @@ -1,11 +1,11 @@ int -width_wintitle(Monitor *m, int max_width) +width_wintitle(Monitor *m, BarWidthArg *a) { - return max_width; + return a->max_width; } int -draw_wintitle(Monitor *m, int x, int w) +draw_wintitle(Monitor *m, BarDrawArg *a) { #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH #if BAR_PANGO_PATCH @@ -19,6 +19,7 @@ draw_wintitle(Monitor *m, int x, int w) #else int boxw = drw->fonts->h / 6 + 2; #endif // BAR_PANGO_PATCH + int x = a->x, w = a->w; if (m->sel) { #if BAR_VTCOLORS_PATCH @@ -33,25 +34,17 @@ draw_wintitle(Monitor *m, int x, int w) #endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH #if BAR_CENTEREDWINDOWNAME_PATCH int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x; - #if BAR_PADDING_PATCH && BAR_PANGO_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0, False); - #elif BAR_PADDING_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, mid, m->sel->name, 0); - #elif BAR_PANGO_PATCH + #if BAR_PANGO_PATCH drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False); #else drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0); - #endif // BAR_PADDING_PATCH + #endif // BAR_PANGO_PATCH #else - #if BAR_PADDING_PATCH && BAR_PANGO_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0, False); - #elif BAR_PADDING_PATCH - drw_text(drw, x, 0, w - 2*sp, bh, lrpad / 2, m->sel->name, 0); - #elif BAR_PANGO_PATCH + #if BAR_PANGO_PATCH drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False); #else drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - #endif // BAR_PADDING_PATCH + #endif // BAR_PANGO_PATCH #endif // BAR_CENTEREDWINDOWNAME_PATCH #if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH XSync(dpy, False); @@ -61,7 +54,7 @@ draw_wintitle(Monitor *m, int x, int w) #if BAR_ACTIVETAGINDICATORBAR_PATCH drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, m->sel->isfixed, 0); #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, + drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, 0); #else drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); #endif // BAR_ACTIVETAGINDICATORBAR_PATCH @@ -71,17 +64,13 @@ draw_wintitle(Monitor *m, int x, int w) #else drw_setscheme(drw, scheme[SchemeNorm]); #endif // BAR_VTCOLORS_PATCH - #if BAR_PADDING_PATCH - drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); - #else drw_rect(drw, x, 0, w, bh, 1, 1); - #endif // BAR_PADDING_PATCH } return x + w; } int -click_wintitle(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h) +click_wintitle(Monitor *m, Arg *arg, BarClickArg *a) { return ClkWinTitle; } diff --git a/patch/bar_wintitle.h b/patch/bar_wintitle.h index b1d7ddd..d79affe 100644 --- a/patch/bar_wintitle.h +++ b/patch/bar_wintitle.h @@ -1,3 +1,3 @@ -static int width_wintitle(Monitor *m, int max_width); -static int draw_wintitle(Monitor *m, int x, int w); -static int click_wintitle(Monitor *m, Arg *arg, int rel_x, int rel_y, int rel_w, int rel_h); \ No newline at end of file +static int width_wintitle(Monitor *m, BarWidthArg *a); +static int draw_wintitle(Monitor *m, BarDrawArg *a); +static int click_wintitle(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file -- cgit v1.2.3 From e780c5078f1b344f3a9902fba1a7641e18931ca3 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 17:14:14 +0200 Subject: taggrid: fix for invalid highlighting for the last tag when columns have an uneven number of clients --- patch/bar_taggrid.c | 215 +++++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 103 deletions(-) diff --git a/patch/bar_taggrid.c b/patch/bar_taggrid.c index 78b3d1c..71379ba 100644 --- a/patch/bar_taggrid.c +++ b/patch/bar_taggrid.c @@ -7,47 +7,56 @@ width_taggrid(Monitor *m, BarWidthArg *a) int draw_taggrid(Monitor *m, BarDrawArg *a) { - unsigned int x, y, h, max_x, columns, occ = 0; - int invert, i,j, k; - Client *c; + unsigned int x, y, h, max_x, columns, occ = 0; + int invert, i,j, k; + Client *c; - for (c = m->clients; c; c = c->next) + for (c = m->clients; c; c = c->next) occ |= c->tags; - h = bh / tagrows; - x = max_x = a->x; - y = 0; - columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); + h = bh / tagrows; + x = max_x = a->x; + y = 0; + columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - /* Firstly we will fill the borders of squares */ - XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); + /* Firstly we will fill the borders of squares */ + XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); - /* We will draw LENGTH(tags) squares in tagraws raws. */ - for (j = 0, i = 0; j < tagrows; j++) { - x = a->x; - for (k = 0; k < columns && i < LENGTH(tags); k++, i++) { - invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; + /* We will draw LENGTH(tags) squares in tagraws raws. */ + for (j = 0, i = 0; j < tagrows; j++) { + x = a->x; + for (k = 0; k < columns; k++, i++) { + if (i < LENGTH(tags)) { + invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; - /* Select active color for current square */ - XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel : - scheme[SchemeNorm][ColFg].pixel); - XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); + /* Select active color for current square */ + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel : + scheme[SchemeNorm][ColFg].pixel); + XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); - /* Mark square if tag has client */ - if (occ & 1 << i) { - XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel : - scheme[SchemeNorm][ColBg].pixel); - XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, - h / 2, h / 2); - } - x += h; - if (x > max_x) { - max_x = x; - } - } - y += h; + /* Mark square if tag has client */ + if (occ & 1 << i) { + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel : + scheme[SchemeNorm][ColBg].pixel); + XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, + h / 2, h / 2); + } + } else { + #if BAR_VTCOLORS_PATCH + XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel); + #else + XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel); + #endif // BAR_VTCOLORS_PATCH + XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h); + } + x += h; + if (x > max_x) { + max_x = x; + } + } + y += h; } - return max_x; + return max_x; } int @@ -67,76 +76,76 @@ click_taggrid(Monitor *m, Arg *arg, BarClickArg *a) void switchtag(const Arg *arg) { - unsigned int columns; - unsigned int new_tagset = 0; - unsigned int pos, i; - int col, row; - Arg new_arg; + unsigned int columns; + unsigned int new_tagset = 0; + unsigned int pos, i; + int col, row; + Arg new_arg; - columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); + columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - for (i = 0; i < LENGTH(tags); ++i) { - if (!(selmon->tagset[selmon->seltags] & 1 << i)) { - continue; - } - pos = i; - row = pos / columns; - col = pos % columns; - if (arg->ui & SWITCHTAG_UP) { /* UP */ - row --; - if (row < 0) { - row = tagrows - 1; - } - do { - pos = row * columns + col; - row --; - } while (pos >= LENGTH(tags)); - } - if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */ - row ++; - if (row >= tagrows) { - row = 0; - } - pos = row * columns + col; - if (pos >= LENGTH(tags)) { - row = 0; - } - pos = row * columns + col; - } - if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */ - col --; - if (col < 0) { - col = columns - 1; - } - do { - pos = row * columns + col; - col --; - } while (pos >= LENGTH(tags)); - } - if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */ - col ++; - if (col >= columns) { - col = 0; - } - pos = row * columns + col; - if (pos >= LENGTH(tags)) { - col = 0; - pos = row * columns + col; - } - } - new_tagset |= 1 << pos; - } - new_arg.ui = new_tagset; - if (arg->ui & SWITCHTAG_TOGGLETAG) { - toggletag(&new_arg); - } - if (arg->ui & SWITCHTAG_TAG) { - tag(&new_arg); - } - if (arg->ui & SWITCHTAG_VIEW) { - view (&new_arg); - } - if (arg->ui & SWITCHTAG_TOGGLEVIEW) { - toggleview (&new_arg); - } + for (i = 0; i < LENGTH(tags); ++i) { + if (!(selmon->tagset[selmon->seltags] & 1 << i)) { + continue; + } + pos = i; + row = pos / columns; + col = pos % columns; + if (arg->ui & SWITCHTAG_UP) { /* UP */ + row --; + if (row < 0) { + row = tagrows - 1; + } + do { + pos = row * columns + col; + row --; + } while (pos >= LENGTH(tags)); + } + if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */ + row ++; + if (row >= tagrows) { + row = 0; + } + pos = row * columns + col; + if (pos >= LENGTH(tags)) { + row = 0; + } + pos = row * columns + col; + } + if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */ + col --; + if (col < 0) { + col = columns - 1; + } + do { + pos = row * columns + col; + col --; + } while (pos >= LENGTH(tags)); + } + if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */ + col ++; + if (col >= columns) { + col = 0; + } + pos = row * columns + col; + if (pos >= LENGTH(tags)) { + col = 0; + pos = row * columns + col; + } + } + new_tagset |= 1 << pos; + } + new_arg.ui = new_tagset; + if (arg->ui & SWITCHTAG_TOGGLETAG) { + toggletag(&new_arg); + } + if (arg->ui & SWITCHTAG_TAG) { + tag(&new_arg); + } + if (arg->ui & SWITCHTAG_VIEW) { + view (&new_arg); + } + if (arg->ui & SWITCHTAG_TOGGLEVIEW) { + toggleview (&new_arg); + } } \ No newline at end of file -- cgit v1.2.3 From 06c4122e07155ef604bd767182247ee6877b2c94 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 17:14:29 +0200 Subject: Movestack can cause dwm to crash if there are no selections on the monitor --- patch/movestack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patch/movestack.c b/patch/movestack.c index 2406a87..ab97b18 100644 --- a/patch/movestack.c +++ b/patch/movestack.c @@ -2,13 +2,13 @@ void movestack(const Arg *arg) { Client *c = NULL, *p = NULL, *pc = NULL, *i; - if (arg->i > 0) { + if (!selmon->sel) + return; /* find the client after selmon->sel */ for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); if (!c) for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); - } else { /* find the client before selmon->sel */ @@ -20,6 +20,7 @@ movestack(const Arg *arg) if (ISVISIBLE(i) && !i->isfloating) c = i; } + /* find the client before selmon->sel and c */ for (i = selmon->clients; i && (!p || !pc); i = i->next) { if (i->next == selmon->sel) -- cgit v1.2.3 From ad09397ad965d6104134bce7df5ad13ecfb97014 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 15 Jul 2020 17:15:35 +0200 Subject: status2d: hide click_status2d if dwmblocks is used --- patch/bar_status2d.c | 2 ++ patch/bar_status2d.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c index 61ebd69..0adaadd 100644 --- a/patch/bar_status2d.c +++ b/patch/bar_status2d.c @@ -10,11 +10,13 @@ draw_status2d(Monitor *m, BarDrawArg *a) return drawstatusbar(m, a->x, a->w, rawstext); } +#if !BAR_DWMBLOCKS_PATCH int click_status2d(Monitor *m, Arg *arg, BarClickArg *a) { return ClkStatusText; } +#endif // BAR_DWMBLOCKS_PATCH int drawstatusbar(Monitor *m, int x, int ow, char* stext) diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index 621fb7f..fa9fbeb 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -1,5 +1,7 @@ static int width_status2d(Monitor *m, BarWidthArg *a); static int draw_status2d(Monitor *m, BarDrawArg *a); +#if !BAR_DWMBLOCKS_PATCH static int click_status2d(Monitor *m, Arg *arg, BarClickArg *a); +#endif // BAR_DWMBLOCKS_PATCH static int drawstatusbar(Monitor *m, int x, int w, char* text); static int status2dtextlength(char* stext); \ No newline at end of file -- cgit v1.2.3 From 664484d572719df5c105b386fa30e8ba0b7825fa Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Jul 2020 13:03:30 +0200 Subject: Refinement --- README.md | 12 +- config.def.h | 121 ++++++++++++------ config.mk | 4 +- dwm.c | 313 +++++++++++++++++++++-------------------------- patch/bar_alpha.c | 2 +- patch/bar_awesomebar.c | 37 ++++-- patch/bar_awesomebar.h | 6 +- patch/bar_fancybar.c | 46 +++---- patch/bar_fancybar.h | 6 +- patch/bar_ltsymbol.c | 12 +- patch/bar_ltsymbol.h | 6 +- patch/bar_status.c | 14 +-- patch/bar_status.h | 6 +- patch/bar_status2d.c | 18 +-- patch/bar_status2d.h | 12 +- patch/bar_status2d_eb.c | 6 +- patch/bar_status2d_eb.h | 4 +- patch/bar_status_eb.c | 19 +++ patch/bar_status_eb.h | 2 + patch/bar_statusbutton.c | 6 +- patch/bar_statusbutton.h | 6 +- patch/bar_statuscmd.c | 10 +- patch/bar_statuscmd.h | 6 +- patch/bar_systray.c | 149 +++++++++++----------- patch/bar_systray.h | 9 +- patch/bar_taggrid.c | 35 ++++-- patch/bar_taggrid.h | 6 +- patch/bar_tags.c | 13 +- patch/bar_tags.h | 6 +- patch/bar_wintitle.c | 16 ++- patch/bar_wintitle.h | 6 +- patch/include.c | 3 + patch/include.h | 3 + patch/vtcolors.c | 70 ----------- patch/vtcolors.h | 2 - patches.def.h | 22 ++-- 36 files changed, 501 insertions(+), 513 deletions(-) create mode 100644 patch/bar_status_eb.c create mode 100644 patch/bar_status_eb.h delete mode 100644 patch/vtcolors.c delete mode 100644 patch/vtcolors.h diff --git a/README.md b/README.md index f1e32c2..477baed 100644 --- a/README.md +++ b/README.md @@ -289,8 +289,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [keymodes](https://dwm.suckless.org/patches/keymodes/) - this patch adds key modes (like in vim or emacs) where chains of keyboard shortcuts can be performed - - [leftlayout](http://dwm.suckless.org/patches/leftlayout/) - - moves the layout symbol in the status bar to the left hand side + - [-leftlayout-](http://dwm.suckless.org/patches/leftlayout/) + - -moves the layout symbol in the status bar to the left hand side- - [losefullscreen](https://github.com/bakkeby/patches/tree/master/dwm/dwm-losefullscreen-6.2.diff) - by default in dwm it is possible to make an application fullscreen, then use the focusstack keybindings to focus on other windows beneath the current window @@ -396,14 +396,14 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [stacker](https://dwm.suckless.org/patches/stacker/) - provides comprehensive utilities for managing the client stack - - [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 + - [-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- - [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 + - [-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 diff --git a/config.def.h b/config.def.h index 7e91c43..f7e2238 100644 --- a/config.def.h +++ b/config.def.h @@ -39,25 +39,18 @@ static int floatposgrid_y = 5; /* float grid rows */ static const int horizpadbar = 2; /* horizontal padding for statusbar */ static const int vertpadbar = 0; /* vertical padding for statusbar */ #endif // BAR_STATUSPADDING_PATCH -#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH -static const int statmonval = 0; -#endif // BAR_STATICSTATUS_PATCH -#if STATUSBUTTON_PATCH +#if BAR_STATUSBUTTON_PATCH static const char buttonbar[] = ""; -#endif // STATUSBUTTON_PATCH -#if SYSTRAY_PATCH +#endif // BAR_STATUSBUTTON_PATCH +#if BAR_SYSTRAY_PATCH static const unsigned int systrayspacing = 2; /* systray spacing */ static const int showsystray = 1; /* 0 means no systray */ -#endif // SYSTRAY_PATCH +#endif // BAR_SYSTRAY_PATCH #if ONLYQUITONEMPTY_PATCH static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */ #endif // ONLYQUITONEMPTY_PATCH #if BAR_EXTRABAR_PATCH static const char statussep = ';'; /* separator between status bars */ -static const int ebalign = 0; /* extrabar alignment: 0 - left, 1 - right, 2 - center */ -#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH -static const int statebmonval = statmonval; -#endif // BAR_STATICSTATUS_PATCH #endif // BAR_EXTRABAR_PATCH #if BAR_PANGO_PATCH static const char font[] = "monospace 10"; @@ -101,14 +94,14 @@ static char urgfloatcolor[] = "#000000"; #endif // FLOAT_BORDER_COLOR_PATCH #endif // URGENTBORDER_PATCH // BAR_STATUSCOLORS_PATCH -#if AWESOMEBAR_PATCH +#if BAR_AWESOMEBAR_PATCH static char hidfgcolor[] = "#005577"; static char hidbgcolor[] = "#222222"; static char hidbordercolor[] = "#005577"; #if FLOAT_BORDER_COLOR_PATCH static char hidfloatcolor[] = "#f76e0c"; #endif // FLOAT_BORDER_COLOR_PATCH -#endif // AWESOMEBAR_PATCH +#endif // BAR_AWESOMEBAR_PATCH #if BAR_TITLECOLOR_PATCH static char titlefgcolor[] = "#eeeeee"; @@ -133,9 +126,9 @@ static const unsigned int alphas[][3] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { OPAQUE, baralpha, borderalpha }, #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { OPAQUE, baralpha, borderalpha }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH #if BAR_VTCOLORS_PATCH [SchemeTagsNorm] = { OPAQUE, baralpha, borderalpha }, [SchemeTagsSel] = { OPAQUE, baralpha, borderalpha }, @@ -160,9 +153,9 @@ static const int color_ptrs[][ColCount] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { 7, 9, 9, 15 }, #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { 5, 0, 0, -1 }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH [SchemeTagsNorm] = { 2, 0, 0, -1 }, [SchemeTagsSel] = { 6, 5, 5, -1 }, [SchemeTitleNorm] = { 6, -1, -1, -1 }, @@ -179,9 +172,9 @@ static char colors[][ColCount][8] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { "#000000", "#000000", "#000000", "#000000" }, #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { "#000000", "#000000", "#000000", "#000000" }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH [SchemeTagsNorm] = { "#000000", "#000000", "#000000", "#000000" }, [SchemeTagsSel] = { "#000000", "#000000", "#000000", "#000000" }, [SchemeTitleNorm] = { "#000000", "#000000", "#000000", "#000000" }, @@ -201,9 +194,9 @@ static const int color_ptrs[][ColCount] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { 7, 9, 9 }, #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { 5, 0, 0 }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH [SchemeTagsNorm] = { 2, 0, 0 }, [SchemeTagsSel] = { 6, 5, 5 }, [SchemeTitleNorm] = { 6, -1, -1 }, @@ -220,9 +213,9 @@ static char colors[][ColCount][8] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { "#000000", "#000000", "#000000" }, #endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { "#000000", "#000000", "#000000" }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH [SchemeTagsNorm] = { "#000000", "#000000", "#000000" }, [SchemeTagsSel] = { "#000000", "#000000", "#000000" }, [SchemeTitleNorm] = { "#000000", "#000000", "#000000" }, @@ -244,9 +237,9 @@ char *colors[][ColCount] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor, urgfloatcolor }, #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidfloatcolor }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH #if BAR_TITLECOLOR_PATCH [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titlefloatcolor }, #endif // BAR_TITLECOLOR_PATCH @@ -266,9 +259,9 @@ char *colors[][ColCount] = { #if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH [SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor }, #endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH [SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH #if BAR_TITLECOLOR_PATCH [SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor }, #endif // BAR_TITLECOLOR_PATCH @@ -297,7 +290,7 @@ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; #endif // BAR_ALTERNATIVE_TAGS_PATCH -#if TAGGRID_PATCH +#if BAR_TAGGRID_PATCH /* grid of tags */ #define DRAWCLASSICTAGS 1 << 0 #define DRAWTAGGRID 1 << 1 @@ -313,7 +306,7 @@ static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const unsigned int drawtagmask = DRAWTAGGRID; /* | DRAWCLASSICTAGS to show classic row of tags */ static const int tagrows = 2; -#endif // TAGGRID_PATCH +#endif // BAR_TAGGRID_PATCH /* There are two options when it comes to per-client rules: * - a typical struct table or @@ -369,6 +362,62 @@ static const MonitorRule monrules[] = { #endif // PERTAG_PATCH #endif // MONITOR_RULES_PATCH +/* Bar rules allow you to configure what is shown where on the bar, as well as + * introducing your own bar modules. + * + * monitor: + * -1 show on all monitors + * 0 show on monitor 0 + * 'A' show on active monitor (i.e. focused / selected) (or just -1 for active?) + * bar - bar index, 0 is default, 1 is extrabar + * alignment - how the module is aligned compared to other modules + * widthfunc, drawfunc, clickfunc - providing bar module width, draw and click functions + * name - does nothing, intended for visual clue and for logging / debugging + */ +static const BarRule barrules[] = { + /* monitor bar alignment widthfunc drawfunc clickfunc name */ + #if BAR_STATUSBUTTON_PATCH + { -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, "statusbutton" }, + #endif // BAR_STATUSBUTTON_PATCH + #if BAR_TAGS_PATCH + { -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" }, + #endif // BAR_TAGS_PATCH + #if BAR_TAGGRID_PATCH + { -1, 0, BAR_ALIGN_LEFT, width_taggrid, draw_taggrid, click_taggrid, "taggrid" }, + #endif // BAR_TAGGRID_PATCH + #if BAR_LTSYMBOL_PATCH + { -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" }, + #endif // BAR_LTSYMBOL_PATCH + #if BAR_SYSTRAY_PATCH + { 0, 0, BAR_ALIGN_RIGHT, width_systray, draw_systray, click_systray, "systray" }, + #endif // BAR_SYSTRAY_PATCH + #if BAR_STATUS2D_PATCH && BAR_STATUSCMD_PATCH + { 'A', 0, BAR_ALIGN_RIGHT, width_status2d, draw_status2d, click_statuscmd, "status2d" }, + #elif BAR_STATUS2D_PATCH + { 'A', 0, BAR_ALIGN_RIGHT, width_status2d, draw_status2d, click_status2d, "status2d" }, + #elif BAR_STATUS_PATCH + { 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" }, + #endif // BAR_STATUS2D_PATCH | BAR_STATUSCMD_PATCH + #if BAR_AWESOMEBAR_PATCH + { -1, 0, BAR_ALIGN_NONE, width_awesomebar, draw_awesomebar, click_awesomebar, "awesomebar" }, + #elif BAR_FANCYBAR_PATCH + { -1, 0, BAR_ALIGN_NONE, width_fancybar, draw_fancybar, click_fancybar, "fancybar" }, + #elif BAR_WINTITLE_PATCH + { -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" }, + #endif // BAR_AWESOMEBAR_PATCH | BAR_FANCYBAR_PATCH BAR_WINTITLE_PATCH + #if BAR_EXTRABAR_PATCH + #if BAR_STATUS2D_PATCH && BAR_STATUSCMD_PATCH + { 'A', 1, BAR_ALIGN_CENTER, width_status2d_eb, draw_status2d_eb, click_statuscmd_eb, "status2d_eb" }, + #elif BAR_STATUS2D_PATCH + { 'A', 1, BAR_ALIGN_CENTER, width_status2d_eb, draw_status2d_eb, click_status2d, "status2d_eb" }, + #elif BAR_STATUSCMD_PATCH + { 'A', 1, BAR_ALIGN_CENTER, width_status_eb, draw_status_eb, click_statuscmd_eb, "status_eb" }, + #elif BAR_STATUS_PATCH + { 'A', 1, BAR_ALIGN_CENTER, width_status_eb, draw_status_eb, click_status, "status_eb" }, + #endif // BAR_STATUS2D_PATCH | BAR_STATUSCMD_PATCH + #endif // BAR_EXTRABAR_PATCH +}; + #if DWMC_PATCH /* signal definitions */ /* signum must be greater than 0 */ @@ -465,9 +514,9 @@ static Signal signals[] = { #if SELFRESTART_PATCH { "self_restart", self_restart }, #endif // SELFRESTART_PATCH - #if TAGGRID_PATCH + #if BAR_TAGGRID_PATCH { "switchtag", switchtag }, - #endif // TAGGRID_PATCH + #endif // BAR_TAGGRID_PATCH #if STICKY_PATCH { "togglesticky", togglesticky }, #endif // STICKY_PATCH @@ -547,7 +596,7 @@ static const int nmaster = 1; /* number of clients in master area */ #if FLEXTILE_DELUXE_LAYOUT static const int nstack = 0; /* number of clients in primary stack area */ #endif // FLEXTILE_DELUXE_LAYOUT -static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ #if NROWGRID_LAYOUT #define FORCE_VSPLIT 1 @@ -872,9 +921,9 @@ static Key keys[] = { { MODKEY|Mod4Mask, XK_Tab, shiftviewclients, { .i = -1 } }, { MODKEY|Mod4Mask, XK_backslash, shiftviewclients, { .i = +1 } }, #endif // SHIFTVIEW_CLIENTS_PATCH - #if AWESOMEBAR_PATCH + #if BAR_AWESOMEBAR_PATCH { MODKEY|ControlMask, XK_z, showhideclient, {0} }, - #endif // AWESOMEBAR_PATCH + #endif // BAR_AWESOMEBAR_PATCH { MODKEY|ShiftMask, XK_c, killclient, {0} }, #if KILLUNSEL_PATCH { MODKEY|ShiftMask, XK_x, killunsel, {0} }, @@ -996,7 +1045,7 @@ static Key keys[] = { #if BAR_ALTERNATIVE_TAGS_PATCH { MODKEY, XK_n, togglealttag, {0} }, #endif // BAR_ALTERNATIVE_TAGS_PATCH - #if TAGGRID_PATCH + #if BAR_TAGGRID_PATCH { MODKEY|ControlMask, XK_Up, switchtag, { .ui = SWITCHTAG_UP | SWITCHTAG_VIEW } }, { MODKEY|ControlMask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_VIEW } }, { MODKEY|ControlMask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_VIEW } }, @@ -1005,7 +1054,7 @@ static Key keys[] = { { MODKEY|Mod4Mask, XK_Down, switchtag, { .ui = SWITCHTAG_DOWN | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, { MODKEY|Mod4Mask, XK_Right, switchtag, { .ui = SWITCHTAG_RIGHT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, { MODKEY|Mod4Mask, XK_Left, switchtag, { .ui = SWITCHTAG_LEFT | SWITCHTAG_TAG | SWITCHTAG_VIEW } }, - #endif // TAGGRID_PATCH + #endif // BAR_TAGGRID_PATCH #if MOVEPLACE_PATCH { MODKEY, XK_KP_7, moveplace, {.ui = WIN_NW }}, /* XK_KP_Home, */ { MODKEY, XK_KP_8, moveplace, {.ui = WIN_N }}, /* XK_KP_Up, */ diff --git a/config.mk b/config.mk index e92e380..8694c43 100644 --- a/config.mk +++ b/config.mk @@ -21,7 +21,7 @@ FREETYPEINC = /usr/include/freetype2 #FREETYPEINC = ${X11INC}/freetype2 # Uncomment this for the alpha patch / BAR_ALPHA_PATCH -#XRENDER = -lXrender +XRENDER = -lXrender # Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH #MPDCLIENT = -lmpdclient @@ -34,7 +34,7 @@ FREETYPEINC = /usr/include/freetype2 #XEXTLIB = -lXext # Uncomment this for the swallow patch / SWALLOW_PATCH -#XCBLIBS = -lX11-xcb -lxcb -lxcb-res +XCBLIBS = -lX11-xcb -lxcb -lxcb-res # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} ${PANGOINC} diff --git a/dwm.c b/dwm.c index 7828403..1e0d51d 100644 --- a/dwm.c +++ b/dwm.c @@ -198,15 +198,17 @@ typedef union { const void *v; } Arg; +typedef struct Monitor Monitor; typedef struct Bar Bar; struct Bar { Window win; + Monitor *mon; + int idx; int bx, by, bw, bh; /* bar geometry */ int w[BARRULES]; // width, array length == barrules, then use r index for lookup purposes int x[BARRULES]; // x position, array length == ^ }; - typedef struct { int max_width; } BarWidthArg; @@ -223,14 +225,13 @@ typedef struct { int rel_h; } BarClickArg; -typedef struct Monitor Monitor; typedef struct { int monitor; int bar; int alignment; // see bar alignment enum - int (*widthfunc)(Monitor *m, BarWidthArg *a); - int (*drawfunc)(Monitor *m, BarDrawArg *a); - int (*clickfunc)(Monitor *m, Arg *arg, BarClickArg *a); + int (*widthfunc)(Bar *bar, BarWidthArg *a); + int (*drawfunc)(Bar *bar, BarDrawArg *a); + int (*clickfunc)(Bar *bar, Arg *arg, BarClickArg *a); char *name; // for debugging int x, w; // position, width for internal use } BarRule; @@ -465,6 +466,7 @@ static void detachstack(Client *c); static Monitor *dirtomon(int dir); static void drawbar(Monitor *m); static void drawbars(void); +static void drawbarwin(Bar *bar); #if !FOCUSONCLICK_PATCH static void enternotify(XEvent *e); #endif // FOCUSONCLICK_PATCH @@ -631,12 +633,6 @@ static Clr **scheme; static Display *dpy; static Drw *drw; static Monitor *mons, *selmon; -#if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH -static Monitor *statmon; -#if BAR_EXTRABAR_PATCH -static Monitor *statebmon; -#endif // BAR_EXTRABAR_PATCH -#endif // BAR_STATICSTATUS_PATCH static Window root, wmcheckwin; /* configuration, allows nested code to access above variables */ @@ -907,14 +903,16 @@ buttonpress(XEvent *e) if (ev->window == selmon->bars[b]->win) { for (r = 0; r < LENGTH(barrules); r++) { br = &barrules[r]; - if (br->bar != b || (br->monitor == 'A' && m != selmon) || (br->monitor != -1 && br->monitor != mi) || br->clickfunc == NULL) + if (br->bar != b || (br->monitor == 'A' && m != selmon) || br->clickfunc == NULL) + continue; + if (br->monitor != 'A' && br->monitor != -1 && br->monitor != mi) continue; if (selmon->bars[b]->x[r] <= ev->x && ev->x <= selmon->bars[b]->x[r] + selmon->bars[b]->w[r]) { carg.rel_x = ev->x - selmon->bars[b]->x[r]; carg.rel_y = ev->y; carg.rel_w = selmon->bars[b]->w[r]; carg.rel_h = selmon->bars[b]->bh; - click = br->clickfunc(m, &arg, &carg); + click = br->clickfunc(selmon->bars[b], &arg, &carg); if (click < 0) return; break; @@ -1049,7 +1047,11 @@ clientmessage(XEvent *e) return; } + #if BAR_SYSTRAY_WIN_PATCH + c->mon = selmon; + #else c->mon = systray->mon; + #endif // BAR_SYSTRAY_WIN_PATCH c->next = systray->icons; systray->icons = c; XGetWindowAttributes(dpy, c->win, &wa); @@ -1243,8 +1245,8 @@ createmon(void) Monitor *m; int i; #if MONITOR_RULES_PATCH - int mc, j; - Monitor *mi; + int mi, j; + Monitor *mon; const MonitorRule *mr; #endif // MONITOR_RULES_PATCH @@ -1270,17 +1272,23 @@ createmon(void) m->gappoh = gappoh; m->gappov = gappov; #endif // VANITYGAPS_PATCH - for (i = 0; i < LENGTH(m->bars); i++) + + for (i = 0; i < LENGTH(m->bars); i++) { + fprintf(stderr, "creating bar, idx = %d\n", i); m->bars[i] = ecalloc(1, sizeof(Bar)); + m->bars[i]->mon = m; + m->bars[i]->idx = i; + fprintf(stderr, "%s\n", "finished creating bar"); + } // for (r = 0; r < LENGTH(barrules); r++) { // for (b = 0; b < LENGTH(selmon->bars); b++) { #if MONITOR_RULES_PATCH - for (mc = 0, mi = mons; mi; mi = mi->next, mc++); + for (mi = 0, mon = mons; mon; mon = mon->next, mi++); // monitor index for (j = 0; j < LENGTH(monrules); j++) { mr = &monrules[j]; - if ((mr->monitor == -1 || mr->monitor == mc) + if ((mr->monitor == -1 || mr->monitor == mi) #if PERTAG_PATCH && (mr->tag == -1 || mr->tag == 0) #endif // PERTAG_PATCH @@ -1343,7 +1351,7 @@ createmon(void) #if MONITOR_RULES_PATCH for (j = 0; j < LENGTH(monrules); j++) { mr = &monrules[j]; - if ((mr->monitor == -1 || mr->monitor == mc) && (mr->tag == -1 || mr->tag == i)) { + if ((mr->monitor == -1 || mr->monitor == mi) && (mr->tag == -1 || mr->tag == i)) { m->pertag->ltidxs[i][0] = &layouts[mr->layout]; m->pertag->ltidxs[i][1] = m->lt[0]; m->pertag->nmasters[i] = (mr->nmaster > -1 ? mr->nmaster : m->nmaster); @@ -1396,7 +1404,7 @@ destroynotify(XEvent *e) #if BAR_SYSTRAY_PATCH else if (showsystray && (c = wintosystrayicon(ev->window))) { removesystrayicon(c); - updatesystray(); + drawbarwin(systray->bar); } #endif // BAR_SYSTRAY_PATCH } @@ -1442,123 +1450,122 @@ dirtomon(int dir) void drawbar(Monitor *m) { + for (int b = 0; b < LENGTH(m->bars); b++) + drawbarwin(m->bars[b]); +} + +void +drawbars(void) +{ + Monitor *m; + for (m = mons; m; m = m->next) + drawbar(m); +} + +void +drawbarwin(Bar *bar) +{ + if (!bar->win) + return; Monitor *mon; - int b, r, w, mi; + int r, w, mi; int rx, lx, rw, lw; // bar size, split between left and right if a center module is added const BarRule *br; - Bar *bar; BarWidthArg warg = { 0 }; BarDrawArg darg = { 0, 0 }; - for (mi = 0, mon = mons; mon && mon != m; mon = mon->next, mi++); // get the monitor index - for (b = LENGTH(m->bars) - 1; b >= 0; b--) { - bar = m->bars[b]; - if (!bar->win) - continue; - - rw = lw = bar->bw; - rx = lx = 0; + for (mi = 0, mon = mons; mon && mon != bar->mon; mon = mon->next, mi++); // get the monitor index + rw = lw = bar->bw; + rx = lx = 0; + #if BAR_VTCOLORS_PATCH + drw_setscheme(drw, scheme[SchemeTagsNorm]); + #else + drw_setscheme(drw, scheme[SchemeNorm]); + #endif // BAR_VTCOLORS_PATCH + drw_rect(drw, lx, 0, lw, bh, 1, 1); + for (r = 0; r < LENGTH(barrules); r++) { + br = &barrules[r]; + if (br->bar != bar->idx || br->drawfunc == NULL || (br->monitor == 'A' && bar->mon != selmon)) + continue; + if (br->monitor != 'A' && br->monitor != -1 && br->monitor != mi) + continue; #if BAR_VTCOLORS_PATCH drw_setscheme(drw, scheme[SchemeTagsNorm]); #else drw_setscheme(drw, scheme[SchemeNorm]); #endif // BAR_VTCOLORS_PATCH - drw_rect(drw, lx, 0, lw, bh, 1, 1); - for (r = 0; r < LENGTH(barrules); r++) { - br = &barrules[r]; - if (br->bar != b || (br->monitor == 'A' && m != selmon) || (br->monitor != -1 && br->monitor != mi) || br->drawfunc == NULL) - continue; - #if BAR_VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTagsNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // BAR_VTCOLORS_PATCH - warg.max_width = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw); - w = br->widthfunc(m, &warg); - w = MIN(warg.max_width, w); - - if (lw <= 0) { // if left is exhausted, switch to right side - lw = rw; - lx = rx; - } else if (rw <= 0) { - rw = lw; - rx = lx; - } + warg.max_width = (br->alignment < BAR_ALIGN_RIGHT_LEFT ? lw : rw); + w = br->widthfunc(bar, &warg); + w = MIN(warg.max_width, w); + + if (lw <= 0) { // if left is exhausted, switch to right side + lw = rw; + lx = rx; + } else if (rw <= 0) { + rw = lw; + rx = lx; + } - switch(br->alignment) { - default: - case BAR_ALIGN_NONE: - case BAR_ALIGN_LEFT_LEFT: - case BAR_ALIGN_LEFT: - bar->x[r] = lx; - bar->w[r] = w; - if (lx == rx) { - rx += w; - rw -= w; - } - lx += w; - lw -= w; - break; - case BAR_ALIGN_LEFT_RIGHT: - case BAR_ALIGN_RIGHT: - bar->x[r] = lx + lw - w; - bar->w[r] = w; - if (lx == rx) - rw -= w; - lw -= w; - break; - case BAR_ALIGN_LEFT_CENTER: - case BAR_ALIGN_CENTER: - bar->x[r] = lx + lw / 2 - w / 2; - bar->w[r] = w; - if (lx == rx) { - rw = rx + rw - bar->x[r] - bar->w[r]; - rx = bar->x[r] + bar->w[r]; - } - lw = bar->x[r] - lx; - break; - case BAR_ALIGN_RIGHT_LEFT: - bar->x[r] = rx; - bar->w[r] = w; - if (lx == rx) { - lx += w; - lw -= w; - } + switch(br->alignment) { + default: + case BAR_ALIGN_NONE: + case BAR_ALIGN_LEFT_LEFT: + case BAR_ALIGN_LEFT: + bar->x[r] = lx; + if (lx == rx) { rx += w; rw -= w; - break; - case BAR_ALIGN_RIGHT_RIGHT: - bar->x[r] = rx + rw - w; - bar->w[r] = w; - if (lx == rx) - lw -= w; + } + lx += w; + lw -= w; + break; + case BAR_ALIGN_LEFT_RIGHT: + case BAR_ALIGN_RIGHT: + bar->x[r] = lx + lw - w; + if (lx == rx) rw -= w; - break; - case BAR_ALIGN_RIGHT_CENTER: - bar->x[r] = rx + rw / 2 - w / 2; - bar->w[r] = w; - if (lx == rx) { - lw = lx + lw - bar->x[r] + bar->w[r]; - lx = bar->x[r] + bar->w[r]; - } - rw = bar->x[r] - rx; - break; + lw -= w; + break; + case BAR_ALIGN_LEFT_CENTER: + case BAR_ALIGN_CENTER: + bar->x[r] = lx + lw / 2 - w / 2; + if (lx == rx) { + rw = rx + rw - bar->x[r] - w; + rx = bar->x[r] + w; + } + lw = bar->x[r] - lx; + break; + case BAR_ALIGN_RIGHT_LEFT: + bar->x[r] = rx; + if (lx == rx) { + lx += w; + lw -= w; } - darg.x = bar->x[r]; - darg.w = bar->w[r]; - br->drawfunc(m, &darg); + rx += w; + rw -= w; + break; + case BAR_ALIGN_RIGHT_RIGHT: + bar->x[r] = rx + rw - w; + if (lx == rx) + lw -= w; + rw -= w; + break; + case BAR_ALIGN_RIGHT_CENTER: + bar->x[r] = rx + rw / 2 - w / 2; + if (lx == rx) { + lw = lx + lw - bar->x[r] + w; + lx = bar->x[r] + w; + } + rw = bar->x[r] - rx; + break; } - drw_map(drw, bar->win, 0, 0, bar->bw, bar->bh); + bar->w[r] = w; + darg.x = bar->x[r]; + darg.w = bar->w[r]; + br->drawfunc(bar, &darg); } -} - -void -drawbars(void) -{ - Monitor *m; - for (m = mons; m; m = m->next) - drawbar(m); + drw_map(drw, bar->win, 0, 0, bar->bw, bar->bh); } #if !FOCUSONCLICK_PATCH @@ -2060,7 +2067,7 @@ maprequest(XEvent *e) Client *i; if (showsystray && (i = wintosystrayicon(ev->window))) { sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION); - updatesystray(); + drawbarwin(systray->bar); } #endif // BAR_SYSTRAY_PATCH @@ -2209,7 +2216,7 @@ propertynotify(XEvent *e) } else updatesystrayiconstate(c, ev); - updatesystray(); + drawbarwin(systray->bar); } #endif // BAR_SYSTRAY_PATCH @@ -2235,11 +2242,8 @@ propertynotify(XEvent *e) break; case XA_WM_HINTS: updatewmhints(c); - drawbars(); - #if URGENTBORDER_PATCH if (c->isurgent) - XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColBorder].pixel); - #endif // URGENTBORDER_PATCH + drawbars(); break; } if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { @@ -3413,7 +3417,7 @@ unmapnotify(XEvent *e) * _not_ destroy them. We map those windows back */ XMapRaised(dpy, c->win); removesystrayicon(c); - updatesystray(); + drawbarwin(systray->bar); #endif // BAR_SYSTRAY_PATCH } } @@ -3534,14 +3538,6 @@ updategeom(void) mons = createmon(); } for (i = 0, m = mons; i < nn && m; m = m->next, i++) { - #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH - if (i == statmonval) - statmon = m; - #if BAR_EXTRABAR_PATCH - if (i == statebmonval) - statebmon = m; - #endif // BAR_EXTRABAR_PATCH - #endif // BAR_STATICSTATUS_PATCH if (i >= n || unique[i].x_org != m->mx || unique[i].y_org != m->my || unique[i].width != m->mw || unique[i].height != m->mh) @@ -3568,14 +3564,6 @@ updategeom(void) } if (m == selmon) selmon = mons; - #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH - if (m == statmon) - statmon = mons; - #if BAR_EXTRABAR_PATCH - if (m == statebmon) - statebmon = mons; - #endif // BAR_EXTRABAR_PATCH - #endif // BAR_STATICSTATUS_PATCH cleanupmon(m); } } @@ -3592,14 +3580,6 @@ updategeom(void) updatebarpos(mons); } } - #if BAR_STATICSTATUS_PATCH && !BAR_STATUSALLMONS_PATCH - if (!statmon) - statmon = mons; - #if BAR_EXTRABAR_PATCH - if (!statebmon) - statebmon = mons; - #endif // BAR_EXTRABAR_PATCH - #endif // BAR_STATICSTATUS_PATCH if (dirty) { selmon = mons; selmon = wintomon(root); @@ -3683,9 +3663,7 @@ updatesizehints(Client *c) void updatestatus(void) { - #if BAR_STATUSALLMONS_PATCH - Monitor* m; - #endif // BAR_STATUSALLMONS_PATCH + Monitor *m; #if BAR_EXTRABAR_PATCH if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) { strcpy(stext, "dwm-"VERSION); @@ -3718,18 +3696,8 @@ updatestatus(void) if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-"VERSION); #endif // BAR_EXTRABAR_PATCH - #if BAR_STATUSALLMONS_PATCH for (m = mons; m; m = m->next) drawbar(m); - #elif BAR_STATICSTATUS_PATCH - drawbar(statmon); - #if BAR_EXTRABAR_PATCH - if (statmon != statebmon) - drawbar(statebmon); - #endif // BAR_EXTRABAR_PATCH - #else - drawbar(selmon); - #endif // BAR_STATUSALLMONS_PATCH | BAR_STATICSTATUS_PATCH } void @@ -3750,19 +3718,18 @@ updatewmhints(Client *c) if (c == selmon->sel && wmh->flags & XUrgencyHint) { wmh->flags &= ~XUrgencyHint; XSetWMHints(dpy, c->win, wmh); - } else { + } else c->isurgent = (wmh->flags & XUrgencyHint) ? 1 : 0; - #if URGENTBORDER_PATCH - if (c->isurgent) { - #if FLOAT_BORDER_COLOR_PATCH - if (c->isfloating) - XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColFloat].pixel); - else - #endif - XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColBorder].pixel); - } - #endif // URGENTBORDER_PATCH + #if URGENTBORDER_PATCH + if (c->isurgent) { + #if FLOAT_BORDER_COLOR_PATCH + if (c->isfloating) + XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColFloat].pixel); + else + #endif + XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColBorder].pixel); } + #endif // URGENTBORDER_PATCH if (wmh->flags & InputHint) c->neverfocus = !wmh->input; else diff --git a/patch/bar_alpha.c b/patch/bar_alpha.c index 7da7215..d86bc1d 100644 --- a/patch/bar_alpha.c +++ b/patch/bar_alpha.c @@ -34,7 +34,7 @@ xinitvisual() XFree(infos); - if (! visual) { + if (!visual) { visual = DefaultVisual(dpy, screen); depth = DefaultDepth(dpy, screen); cmap = DefaultColormap(dpy, screen); diff --git a/patch/bar_awesomebar.c b/patch/bar_awesomebar.c index ddea5ea..446b547 100644 --- a/patch/bar_awesomebar.c +++ b/patch/bar_awesomebar.c @@ -1,26 +1,36 @@ int -width_awesomebar(Monitor *m, BarWidthArg *a) +width_awesomebar(Bar *bar, BarWidthArg *a) { return a->max_width; } int -draw_awesomebar(Monitor *m, BarDrawArg *a) +draw_awesomebar(Bar *bar, BarDrawArg *a) { int n = 0, scm, remainder = 0, tabw; - unsigned int i, x = a->x; + unsigned int i; + #if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad; + #elif BAR_TITLE_LEFT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad / 2; + #elif BAR_TITLE_RIGHT_PAD + int x = a->x, w = a->w - lrpad / 2; + #else + int x = a->x, w = a->w; + #endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD + Client *c; - for (c = m->clients; c; c = c->next) + for (c = bar->mon->clients; c; c = c->next) if (ISVISIBLE(c)) n++; if (n > 0) { - remainder = a->w % n; - tabw = a->w / n; - for (i = 0, c = m->clients; c; c = c->next, i++) { + remainder = w % n; + tabw = w / n; + for (i = 0, c = bar->mon->clients; c; c = c->next, i++) { if (!ISVISIBLE(c)) continue; - if (m->sel == c) + if (bar->mon->sel == c) #if BAR_VTCOLORS_PATCH scm = SchemeTitleSel; #elif BAR_TITLECOLOR_PATCH @@ -38,10 +48,11 @@ draw_awesomebar(Monitor *m, BarDrawArg *a) #endif // BAR_VTCOLORS_PATCH drw_setscheme(drw, scheme[scm]); + tabw += (i < remainder ? 1 : 0); #if BAR_PANGO_PATCH - drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False); + drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0, False); #else - drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0); + drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0); #endif // BAR_PANGO_PATCH x += tabw; } @@ -50,16 +61,16 @@ draw_awesomebar(Monitor *m, BarDrawArg *a) } int -click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a) +click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a) { int x = 0, n = 0; Client *c; - for (c = m->clients; c; c = c->next) + for (c = bar->mon->clients; c; c = c->next) if (ISVISIBLE(c)) n++; - c = m->clients; + c = bar->mon->clients; do { if (!c || !ISVISIBLE(c)) diff --git a/patch/bar_awesomebar.h b/patch/bar_awesomebar.h index 8e9387b..a99986e 100644 --- a/patch/bar_awesomebar.h +++ b/patch/bar_awesomebar.h @@ -1,6 +1,6 @@ -static int width_awesomebar(Monitor *m, BarWidthArg *a); -static int draw_awesomebar(Monitor *m, BarDrawArg *a); -static int click_awesomebar(Monitor *m, Arg *arg, BarClickArg *a); +static int width_awesomebar(Bar *bar, BarWidthArg *a); +static int draw_awesomebar(Bar *bar, BarDrawArg *a); +static int click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a); static void hide(Client *c); static void show(Client *c); diff --git a/patch/bar_fancybar.c b/patch/bar_fancybar.c index 810c73e..a193876 100644 --- a/patch/bar_fancybar.c +++ b/patch/bar_fancybar.c @@ -1,29 +1,33 @@ int -width_fancybar(Monitor *m, BarWidthArg *a) +width_fancybar(Bar *bar, BarWidthArg *a) { return a->max_width; } int -draw_fancybar(Monitor *m, BarDrawArg *a) +draw_fancybar(Bar *bar, BarDrawArg *a) { - int ftw, mw, ew = 0, n = 0, x = a->x, w = a->w; + int ftw, mw, ew = 0, n = 0; unsigned int i; Client *c; - #if !BAR_HIDEVACANTTAGS_PATCH - #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH + Monitor *m = bar->mon; + #if BAR_PANGO_PATCH int boxs = drw->font->h / 9; - #else - int boxs = drw->fonts->h / 9; - #endif // BAR_PANGO_PATCH - #endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - #if BAR_PANGO_PATCH int boxw = drw->font->h / 6 + 2; #else + int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; #endif // BAR_PANGO_PATCH - #endif // BAR_HIDEVACANTTAGS_PATCH + #if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad; + #elif BAR_TITLE_LEFT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad / 2; + #elif BAR_TITLE_RIGHT_PAD + int x = a->x, w = a->w - lrpad / 2; + #else + int x = a->x, w = a->w; + #endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD for (c = m->clients; c; c = c->next) { if (ISVISIBLE(c)) @@ -31,10 +35,11 @@ draw_fancybar(Monitor *m, BarDrawArg *a) } if (n > 0) { - ftw = TEXTW(m->sel->name) + lrpad; + ftw = TEXTW(m->sel->name); mw = (ftw >= w || n == 1) ? 0 : (w - ftw) / (n - 1); i = 0; + for (c = m->clients; c; c = c->next) { if (!ISVISIBLE(c) || c == m->sel) continue; @@ -44,6 +49,7 @@ draw_fancybar(Monitor *m, BarDrawArg *a) else i++; } + if (i > 0) mw += ew / i; @@ -65,31 +71,17 @@ draw_fancybar(Monitor *m, BarDrawArg *a) #else drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0); #endif // BAR_PANGO_PATCH - #if !BAR_HIDEVACANTTAGS_PATCH if (c->isfloating) - #if BAR_ACTIVETAGINDICATORBAR_PATCH - drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, c->isfixed, 0); - #elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH - drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, - #else drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0); - #endif // BAR_ACTIVETAGINDICATORBAR_PATCH - #endif // BAR_HIDEVACANTTAGS_PATCH x += ftw; w -= ftw; } } - #if BAR_VTCOLORS_PATCH - drw_setscheme(drw, scheme[SchemeTitleNorm]); - #else - drw_setscheme(drw, scheme[SchemeNorm]); - #endif // BAR_VTCOLORS_PATCH - drw_rect(drw, x, 0, w, bh, 1, 1); return x + w; } int -click_fancybar(Monitor *m, Arg *arg, BarClickArg *a) +click_fancybar(Bar *bar, Arg *arg, BarClickArg *a) { return ClkWinTitle; } diff --git a/patch/bar_fancybar.h b/patch/bar_fancybar.h index b7b2875..c90d189 100644 --- a/patch/bar_fancybar.h +++ b/patch/bar_fancybar.h @@ -1,3 +1,3 @@ -static int width_fancybar(Monitor *m, BarWidthArg *a); -static int draw_fancybar(Monitor *m, BarDrawArg *a); -static int click_fancybar(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file +static int width_fancybar(Bar *bar, BarWidthArg *a); +static int draw_fancybar(Bar *bar, BarDrawArg *a); +static int click_fancybar(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_ltsymbol.c b/patch/bar_ltsymbol.c index c3a7baf..65ce2da 100644 --- a/patch/bar_ltsymbol.c +++ b/patch/bar_ltsymbol.c @@ -1,21 +1,21 @@ int -width_ltsymbol(Monitor *m, BarWidthArg *a) +width_ltsymbol(Bar *bar, BarWidthArg *a) { - return TEXTW(m->ltsymbol); + return TEXTW(bar->mon->ltsymbol); } int -draw_ltsymbol(Monitor *m, BarDrawArg *a) +draw_ltsymbol(Bar *bar, BarDrawArg *a) { #if BAR_PANGO_PATCH - return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0, False); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0, False); #else - return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, m->ltsymbol, 0); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, bar->mon->ltsymbol, 0); #endif // BAR_PANGO_PATCH } int -click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a) +click_ltsymbol(Bar *bar, Arg *arg, BarClickArg *a) { return ClkLtSymbol; } \ No newline at end of file diff --git a/patch/bar_ltsymbol.h b/patch/bar_ltsymbol.h index 40f5c55..d9c79bf 100644 --- a/patch/bar_ltsymbol.h +++ b/patch/bar_ltsymbol.h @@ -1,3 +1,3 @@ -static int width_ltsymbol(Monitor *m, BarWidthArg *a); -static int draw_ltsymbol(Monitor *m, BarDrawArg *a); -static int click_ltsymbol(Monitor *m, Arg *arg, BarClickArg *a); +static int width_ltsymbol(Bar *bar, BarWidthArg *a); +static int draw_ltsymbol(Bar *bar, BarDrawArg *a); +static int click_ltsymbol(Bar *bar, Arg *arg, BarClickArg *a); diff --git a/patch/bar_status.c b/patch/bar_status.c index 2d7283b..9c3aafe 100644 --- a/patch/bar_status.c +++ b/patch/bar_status.c @@ -1,25 +1,25 @@ int -width_status(Monitor *m, BarWidthArg *a) +width_status(Bar *bar, BarWidthArg *a) { #if BAR_PANGO_PATCH - return TEXTWM(stext) - lrpad + 2; /* 2px right padding */ + return TEXTWM(stext); #else - return TEXTW(stext) - lrpad + 2; /* 2px right padding */ + return TEXTW(stext); #endif // BAR_PANGO_PATCH } int -draw_status(Monitor *m, BarDrawArg *a) +draw_status(Bar *bar, BarDrawArg *a) { #if BAR_PANGO_PATCH - return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0, True); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0, True); #else - return drw_text(drw, a->x, 0, a->w, bh, 0, stext, 0); + return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, stext, 0); #endif // BAR_PANGO_PATCH } int -click_status(Monitor *m, Arg *arg, BarClickArg *a) +click_status(Bar *bar, Arg *arg, BarClickArg *a) { return ClkStatusText; } diff --git a/patch/bar_status.h b/patch/bar_status.h index 97cf8b8..bd169d9 100644 --- a/patch/bar_status.h +++ b/patch/bar_status.h @@ -1,3 +1,3 @@ -static int width_status(Monitor *m, BarWidthArg *a); -static int draw_status(Monitor *m, BarDrawArg *a); -static int click_status(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file +static int width_status(Bar *bar, BarWidthArg *a); +static int draw_status(Bar *bar, BarDrawArg *a); +static int click_status(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c index 0adaadd..c4c7689 100644 --- a/patch/bar_status2d.c +++ b/patch/bar_status2d.c @@ -1,25 +1,25 @@ int -width_status2d(Monitor *m, BarWidthArg *a) +width_status2d(Bar *bar, BarWidthArg *a) { - return status2dtextlength(rawstext); + return status2dtextlength(rawstext) + lrpad; } int -draw_status2d(Monitor *m, BarDrawArg *a) +draw_status2d(Bar *bar, BarDrawArg *a) { - return drawstatusbar(m, a->x, a->w, rawstext); + return drawstatusbar(a->x, rawstext); } -#if !BAR_DWMBLOCKS_PATCH +#if !BAR_STATUSCMD_PATCH int -click_status2d(Monitor *m, Arg *arg, BarClickArg *a) +click_status2d(Bar *bar, Arg *arg, BarClickArg *a) { return ClkStatusText; } -#endif // BAR_DWMBLOCKS_PATCH +#endif // BAR_STATUSCMD_PATCH int -drawstatusbar(Monitor *m, int x, int ow, char* stext) +drawstatusbar(int x, char* stext) { int i, w, len; short isCode = 0; @@ -36,6 +36,8 @@ drawstatusbar(Monitor *m, int x, int ow, char* stext) memcpy(text, stext, len); #endif // BAR_STATUSCMD_PATCH + x += lrpad / 2; + /* process status text */ i = -1; while (text[++i]) { diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index fa9fbeb..555b093 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -1,7 +1,7 @@ -static int width_status2d(Monitor *m, BarWidthArg *a); -static int draw_status2d(Monitor *m, BarDrawArg *a); -#if !BAR_DWMBLOCKS_PATCH -static int click_status2d(Monitor *m, Arg *arg, BarClickArg *a); -#endif // BAR_DWMBLOCKS_PATCH -static int drawstatusbar(Monitor *m, int x, int w, char* text); +static int width_status2d(Bar *bar, BarWidthArg *a); +static int draw_status2d(Bar *bar, BarDrawArg *a); +#if !BAR_STATUSCMD_PATCH +static int click_status2d(Bar *bar, Arg *arg, BarClickArg *a); +#endif // BAR_STATUSCMD_PATCH +static int drawstatusbar(int x, char* text); static int status2dtextlength(char* stext); \ No newline at end of file diff --git a/patch/bar_status2d_eb.c b/patch/bar_status2d_eb.c index 3e98866..5d67b88 100644 --- a/patch/bar_status2d_eb.c +++ b/patch/bar_status2d_eb.c @@ -1,11 +1,11 @@ int -width_status2d_eb(Monitor *m, BarWidthArg *a) +width_status2d_eb(Bar *bar, BarWidthArg *a) { return status2dtextlength(rawestext); } int -draw_status2d_eb(Monitor *m, BarDrawArg *a) +draw_status2d_eb(Bar *bar, BarDrawArg *a) { - return drawstatusbar(m, a->x, a->w, rawestext); + return drawstatusbar(a->x, rawestext); } \ No newline at end of file diff --git a/patch/bar_status2d_eb.h b/patch/bar_status2d_eb.h index 2a43537..a20f8d5 100644 --- a/patch/bar_status2d_eb.h +++ b/patch/bar_status2d_eb.h @@ -1,2 +1,2 @@ -static int width_status2d_eb(Monitor *m, BarWidthArg *a); -static int draw_status2d_eb(Monitor *m, BarDrawArg *a); \ No newline at end of file +static int width_status2d_eb(Bar *bar, BarWidthArg *a); +static int draw_status2d_eb(Bar *bar, BarDrawArg *a); \ No newline at end of file diff --git a/patch/bar_status_eb.c b/patch/bar_status_eb.c new file mode 100644 index 0000000..71944b4 --- /dev/null +++ b/patch/bar_status_eb.c @@ -0,0 +1,19 @@ +int +width_status_eb(Bar *bar, BarWidthArg *a) +{ + #if BAR_PANGO_PATCH + return TEXTWM(estext) - lrpad; + #else + return TEXTW(estext) - lrpad; + #endif // BAR_PANGO_PATCH +} + +int +draw_status_eb(Bar *bar, BarDrawArg *a) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0, True); + #else + return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0); + #endif // BAR_PANGO_PATCH +} \ No newline at end of file diff --git a/patch/bar_status_eb.h b/patch/bar_status_eb.h new file mode 100644 index 0000000..c2ec004 --- /dev/null +++ b/patch/bar_status_eb.h @@ -0,0 +1,2 @@ +static int width_status_eb(Bar *bar, BarWidthArg *a); +static int draw_status_eb(Bar *bar, BarDrawArg *a); \ No newline at end of file diff --git a/patch/bar_statusbutton.c b/patch/bar_statusbutton.c index 5f60b76..f5c9c9d 100644 --- a/patch/bar_statusbutton.c +++ b/patch/bar_statusbutton.c @@ -1,11 +1,11 @@ int -width_stbutton(Monitor *m, BarWidthArg *a) +width_stbutton(Bar *bar, BarWidthArg *a) { return TEXTW(buttonbar); } int -draw_stbutton(Monitor *m, BarDrawArg *a) +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); @@ -15,7 +15,7 @@ draw_stbutton(Monitor *m, BarDrawArg *a) } int -click_stbutton(Monitor *m, Arg *arg, BarClickArg *a) +click_stbutton(Bar *bar, Arg *arg, BarClickArg *a) { return ClkButton; } diff --git a/patch/bar_statusbutton.h b/patch/bar_statusbutton.h index 47055ad..8e9d6fe 100644 --- a/patch/bar_statusbutton.h +++ b/patch/bar_statusbutton.h @@ -1,3 +1,3 @@ -static int width_stbutton(Monitor *m, BarWidthArg *a); -static int draw_stbutton(Monitor *m, BarDrawArg *a); -static int click_stbutton(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file +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/bar_statuscmd.c b/patch/bar_statuscmd.c index 14b4076..5825647 100644 --- a/patch/bar_statuscmd.c +++ b/patch/bar_statuscmd.c @@ -5,21 +5,21 @@ static int lastbutton; #endif // BAR_DWMBLOCKS_PATCH int -click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a) +click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a) { - return click_statuscmd_text(m, arg, a->rel_x, rawstext); + return click_statuscmd_text(arg, a->rel_x, rawstext); } #if BAR_EXTRABAR_PATCH int -click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a) +click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a) { - return click_statuscmd_text(m, arg, a->rel_x, rawestext); + return click_statuscmd_text(arg, a->rel_x, rawestext); } #endif // BAR_EXTRABAR_PATCH int -click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text) +click_statuscmd_text(Arg *arg, int rel_x, char *text) { int i = -1; int x = 0; diff --git a/patch/bar_statuscmd.h b/patch/bar_statuscmd.h index 7619ec3..bcbcb33 100644 --- a/patch/bar_statuscmd.h +++ b/patch/bar_statuscmd.h @@ -1,6 +1,6 @@ -static int click_statuscmd(Monitor *m, Arg *arg, BarClickArg *a); +static int click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a); #if BAR_EXTRABAR_PATCH -static int click_statuscmd_eb(Monitor *m, Arg *arg, BarClickArg *a); +static int click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a); #endif // BAR_EXTRABAR_PATCH -static int click_statuscmd_text(Monitor *m, Arg *arg, int rel_x, char *text); +static int click_statuscmd_text(Arg *arg, int rel_x, char *text); static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file diff --git a/patch/bar_systray.c b/patch/bar_systray.c index e9df765..0ff730d 100644 --- a/patch/bar_systray.c +++ b/patch/bar_systray.c @@ -1,11 +1,8 @@ static Systray *systray = NULL; static unsigned long systrayorientation = _NET_SYSTEM_TRAY_ORIENTATION_HORZ; -static int systraybaridx = -1; -static int systraybarrule = -1; -static int systrayxpos = 0; int -width_systray(Monitor *m, BarWidthArg *a) +width_systray(Bar *bar, BarWidthArg *a) { unsigned int w = 0; Client *i; @@ -13,87 +10,40 @@ width_systray(Monitor *m, BarWidthArg *a) return 1; if (showsystray) for (i = systray->icons; i; w += i->w + systrayspacing, i = i->next); - return w ? w + systrayspacing : 0; + return w ? w + lrpad - systrayspacing : 0; } int -draw_systray(Monitor *m, BarDrawArg *a) -{ - systrayxpos = a->x; - updatesystray(); - return systrayxpos + a->w; -} - -int -click_systray(Monitor *m, Arg *arg, BarClickArg *a) -{ - return -1; -} - -void -removesystrayicon(Client *i) -{ - Client **ii; - - if (!showsystray || !i) - return; - for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next); - if (ii) - *ii = i->next; - free(i); -} - -void -resizerequest(XEvent *e) -{ - XResizeRequestEvent *ev = &e->xresizerequest; - Client *i; - - if ((i = wintosystrayicon(ev->window))) { - updatesystrayicongeom(i, ev->width, ev->height); - updatesystray(); - } -} - -void -updatesystray(void) +draw_systray(Bar *bar, BarDrawArg *a) { if (!showsystray) - return; + return a->x; + XSetWindowAttributes wa; Client *i; - Monitor *m; - unsigned int w = 1, r, mi; - const BarRule *br; + unsigned int w; if (!systray) { /* init systray */ if (!(systray = (Systray *)calloc(1, sizeof(Systray)))) die("fatal: could not malloc() %u bytes\n", sizeof(Systray)); - /* Work out which bar the systray is to be displayed on */ - for (r = 0; r < LENGTH(barrules); r++) { - br = &barrules[r]; - if (br->drawfunc == &draw_systray) { - systraybaridx = br->bar; - systraybarrule = r; - if (br->monitor == -1 || br->monitor == 'A') - m = selmon; - else - for (m = mons, mi = 0; m && mi < br->monitor && m->next; m = m->next, mi++); - systray->win = m->bars[systraybaridx]->win; - systray->mon = m; - - break; - } - } - if (systraybaridx == -1) { - fprintf(stderr, "dwm: unable to obtain system tray, no draw_systray in bar rules.\n"); - free(systray); - systray = NULL; - return; - } + wa.override_redirect = True; + wa.event_mask = ButtonPressMask|ExposureMask; + wa.border_pixel = 0; + #if BAR_ALPHA_PATCH + wa.background_pixel = 0; + wa.colormap = cmap; + systray->win = XCreateWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by, MAX(a->w + 40, 1), bar->bh, 0, depth, + InputOutput, visual, + CWOverrideRedirect|CWBorderPixel|CWBackPixel|CWColormap|CWEventMask, &wa); // CWBackPixmap + #else + wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + systray->win = XCreateSimpleWindow(dpy, root, bar->bx + a->x + lrpad / 2, bar->by, MIN(a->w, 1), bar->bh, 0, 0, scheme[SchemeNorm][ColBg].pixel); + XChangeWindowAttributes(dpy, systray->win, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &wa); + #endif // BAR_ALPHA_PATCH + XSelectInput(dpy, systray->win, SubstructureNotifyMask); XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&systrayorientation, 1); #if BAR_ALPHA_PATCH @@ -111,21 +61,63 @@ updatesystray(void) fprintf(stderr, "dwm: unable to obtain system tray.\n"); free(systray); systray = NULL; - return; + return a->x; } } + systray->bar = bar; + + drw_setscheme(drw, scheme[SchemeNorm]); for (w = 0, i = systray->icons; i; i = i->next) { - /* make sure the background color stays the same */ + #if BAR_ALPHA_PATCH + wa.background_pixel = 0; + #else wa.background_pixel = scheme[SchemeNorm][ColBg].pixel; + #endif // BAR_ALPHA_PATCH XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa); XMapRaised(dpy, i->win); - w += systrayspacing; - i->x = systrayxpos + w; + i->x = w; XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h); w += i->w; - if (i->mon != systray->mon) - i->mon = systray->mon; + if (i->next) + w += systrayspacing; + if (i->mon != bar->mon) + i->mon = bar->mon; + } + + XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by : -bar->by), MAX(w, 1), bar->bh); + return a->x + a->w; +} + +int +click_systray(Bar *bar, Arg *arg, BarClickArg *a) +{ + return -1; +} + +void +removesystrayicon(Client *i) +{ + Client **ii; + + if (!showsystray || !i) + return; + for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next); + if (ii) + *ii = i->next; + free(i); + drawbarwin(systray->bar); +} + +void +resizerequest(XEvent *e) +{ + XResizeRequestEvent *ev = &e->xresizerequest; + Client *i; + + if ((i = wintosystrayicon(ev->window))) { + updatesystrayicongeom(i, ev->width, ev->height); + drawbarwin(systray->bar); } } @@ -185,8 +177,9 @@ updatesystrayiconstate(Client *i, XPropertyEvent *ev) Client * wintosystrayicon(Window w) { + if (!systray) + return NULL; Client *i = NULL; - if (!showsystray || !w) return i; for (i = systray->icons; i && i->win != w; i = i->next); diff --git a/patch/bar_systray.h b/patch/bar_systray.h index 5c4f387..5123a73 100644 --- a/patch/bar_systray.h +++ b/patch/bar_systray.h @@ -22,19 +22,18 @@ typedef struct Systray Systray; struct Systray { Window win; Client *icons; - Monitor *mon; + Bar *bar; }; /* bar integration */ -static int width_systray(Monitor *m, BarWidthArg *a); -static int draw_systray(Monitor *m, BarDrawArg *a); -static int click_systray(Monitor *m, Arg *arg, BarClickArg *a); +static int width_systray(Bar *bar, BarWidthArg *a); +static int draw_systray(Bar *bar, BarDrawArg *a); +static int click_systray(Bar *bar, Arg *arg, BarClickArg *a); /* function declarations */ static Atom getatomprop(Client *c, Atom prop); static void removesystrayicon(Client *i); static void resizerequest(XEvent *e); -static void updatesystray(void); static void updatesystrayicongeom(Client *i, int w, int h); static void updatesystrayiconstate(Client *i, XPropertyEvent *ev); static Client *wintosystrayicon(Window w); diff --git a/patch/bar_taggrid.c b/patch/bar_taggrid.c index 71379ba..dd439f7 100644 --- a/patch/bar_taggrid.c +++ b/patch/bar_taggrid.c @@ -1,43 +1,58 @@ int -width_taggrid(Monitor *m, BarWidthArg *a) +width_taggrid(Bar *bar, BarWidthArg *a) { - return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)); + return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)) + lrpad; } int -draw_taggrid(Monitor *m, BarDrawArg *a) +draw_taggrid(Bar *bar, BarDrawArg *a) { - unsigned int x, y, h, max_x, columns, occ = 0; + unsigned int x, y, h, max_x = 0, columns, occ = 0; int invert, i,j, k; Client *c; - for (c = m->clients; c; c = c->next) + for (c = bar->mon->clients; c; c = c->next) occ |= c->tags; + max_x = x = a->x + lrpad / 2; h = bh / tagrows; - x = max_x = a->x; y = 0; columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); /* Firstly we will fill the borders of squares */ + #if BAR_VTCOLORS_PATCH + XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel); + #else + XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel); + #endif // BAR_VTCOLORS_PATCH XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh); /* We will draw LENGTH(tags) squares in tagraws raws. */ for (j = 0, i = 0; j < tagrows; j++) { - x = a->x; + x = a->x + lrpad / 2; for (k = 0; k < columns; k++, i++) { if (i < LENGTH(tags)) { - invert = m->tagset[m->seltags] & 1 << i ? 0 : 1; + invert = bar->mon->tagset[bar->mon->seltags] & 1 << i ? 0 : 1; /* Select active color for current square */ + #if BAR_VTCOLORS_PATCH + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColBg].pixel : + scheme[SchemeTagsNorm][ColFg].pixel); + #else XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel : scheme[SchemeNorm][ColFg].pixel); + #endif // BAR_VTCOLORS_PATCH XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1); /* Mark square if tag has client */ if (occ & 1 << i) { + #if BAR_VTCOLORS_PATCH + XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColFg].pixel : + scheme[SchemeTagsNorm][ColBg].pixel); + #else XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel : scheme[SchemeNorm][ColBg].pixel); + #endif // BAR_VTCOLORS_PATCH XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1, h / 2, h / 2); } @@ -60,12 +75,12 @@ draw_taggrid(Monitor *m, BarDrawArg *a) } int -click_taggrid(Monitor *m, Arg *arg, BarClickArg *a) +click_taggrid(Bar *bar, Arg *arg, BarClickArg *a) { unsigned int i, columns; columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0); - i = (a->rel_x - 0) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows)); + i = (a->rel_x - lrpad / 2) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows)); if (i >= LENGTH(tags)) { i = LENGTH(tags) - 1; } diff --git a/patch/bar_taggrid.h b/patch/bar_taggrid.h index d284a07..c35b337 100644 --- a/patch/bar_taggrid.h +++ b/patch/bar_taggrid.h @@ -1,4 +1,4 @@ -static int width_taggrid(Monitor *m, BarWidthArg *a); -static int draw_taggrid(Monitor *m, BarDrawArg *a); -static int click_taggrid(Monitor *m, Arg *arg, BarClickArg *a); +static int width_taggrid(Bar *bar, BarWidthArg *a); +static int draw_taggrid(Bar *bar, BarDrawArg *a); +static int click_taggrid(Bar *bar, Arg *arg, BarClickArg *a); static void switchtag(const Arg *arg); \ No newline at end of file diff --git a/patch/bar_tags.c b/patch/bar_tags.c index 708e61d..1296853 100644 --- a/patch/bar_tags.c +++ b/patch/bar_tags.c @@ -1,5 +1,5 @@ int -width_tags(Monitor *m, BarWidthArg *a) +width_tags(Bar *bar, BarWidthArg *a) { int w, i; for (w = 0, i = 0; i < LENGTH(tags); i++) { @@ -9,14 +9,14 @@ width_tags(Monitor *m, BarWidthArg *a) w += TEXTW(tags[i]); #endif // BAR_ALTERNATIVE_TAGS_PATCH } - return w; + return w + lrpad; } int -draw_tags(Monitor *m, BarDrawArg *a) +draw_tags(Bar *bar, BarDrawArg *a) { int invert; - int w, x = a->x; + int w, x = a->x + lrpad / 2; #if BAR_ALTERNATIVE_TAGS_PATCH int wdelta; #endif // BAR_ALTERNATIVE_TAGS_PATCH @@ -36,6 +36,7 @@ draw_tags(Monitor *m, BarDrawArg *a) #endif // BAR_HIDEVACANTTAGS_PATCH unsigned int i, occ = 0, urg = 0; Client *c; + Monitor *m = bar->mon; for (c = m->clients; c; c = c->next) { #if BAR_HIDEVACANTTAGS_PATCH @@ -107,9 +108,9 @@ draw_tags(Monitor *m, BarDrawArg *a) } int -click_tags(Monitor *m, Arg *arg, BarClickArg *a) +click_tags(Bar *bar, Arg *arg, BarClickArg *a) { - int i = 0, x = 0; + int i = 0, x = lrpad / 2; do #if BAR_ALTERNATIVE_TAGS_PATCH x += selmon->alttag ? TEXTW(tagsalt[i]) : TEXTW(tags[i]); diff --git a/patch/bar_tags.h b/patch/bar_tags.h index 9961f1a..033130e 100644 --- a/patch/bar_tags.h +++ b/patch/bar_tags.h @@ -1,3 +1,3 @@ -static int width_tags(Monitor *m, BarWidthArg *a); -static int draw_tags(Monitor *m, BarDrawArg *a); -static int click_tags(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file +static int width_tags(Bar *bar, BarWidthArg *a); +static int draw_tags(Bar *bar, BarDrawArg *a); +static int click_tags(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_wintitle.c b/patch/bar_wintitle.c index 36889c1..70c42ce 100644 --- a/patch/bar_wintitle.c +++ b/patch/bar_wintitle.c @@ -1,11 +1,11 @@ int -width_wintitle(Monitor *m, BarWidthArg *a) +width_wintitle(Bar *bar, BarWidthArg *a) { return a->max_width; } int -draw_wintitle(Monitor *m, BarDrawArg *a) +draw_wintitle(Bar *bar, BarDrawArg *a) { #if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH #if BAR_PANGO_PATCH @@ -19,7 +19,17 @@ draw_wintitle(Monitor *m, BarDrawArg *a) #else int boxw = drw->fonts->h / 6 + 2; #endif // BAR_PANGO_PATCH + + #if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad; + #elif BAR_TITLE_LEFT_PAD + int x = a->x + lrpad / 2, w = a->w - lrpad / 2; + #elif BAR_TITLE_RIGHT_PAD + int x = a->x, w = a->w - lrpad / 2; + #else int x = a->x, w = a->w; + #endif // BAR_TITLE_LEFT_PAD | BAR_TITLE_RIGHT_PAD + Monitor *m = bar->mon; if (m->sel) { #if BAR_VTCOLORS_PATCH @@ -70,7 +80,7 @@ draw_wintitle(Monitor *m, BarDrawArg *a) } int -click_wintitle(Monitor *m, Arg *arg, BarClickArg *a) +click_wintitle(Bar *bar, Arg *arg, BarClickArg *a) { return ClkWinTitle; } diff --git a/patch/bar_wintitle.h b/patch/bar_wintitle.h index d79affe..6d055a6 100644 --- a/patch/bar_wintitle.h +++ b/patch/bar_wintitle.h @@ -1,3 +1,3 @@ -static int width_wintitle(Monitor *m, BarWidthArg *a); -static int draw_wintitle(Monitor *m, BarDrawArg *a); -static int click_wintitle(Monitor *m, Arg *arg, BarClickArg *a); \ No newline at end of file +static int width_wintitle(Bar *bar, BarWidthArg *a); +static int draw_wintitle(Bar *bar, BarDrawArg *a); +static int click_wintitle(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index e35033e..7fe397f 100644 --- a/patch/include.c +++ b/patch/include.c @@ -19,6 +19,9 @@ #endif #if BAR_STATUS_PATCH #include "bar_status.c" +#if BAR_EXTRABAR_PATCH +#include "bar_status_eb.c" +#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUS2D_PATCH #include "bar_status2d.c" diff --git a/patch/include.h b/patch/include.h index 9065c87..6e08d0e 100644 --- a/patch/include.h +++ b/patch/include.h @@ -19,6 +19,9 @@ #endif #if BAR_STATUS_PATCH #include "bar_status.h" +#if BAR_EXTRABAR_PATCH +#include "bar_status_eb.h" +#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUS2D_PATCH #include "bar_status2d.h" diff --git a/patch/vtcolors.c b/patch/vtcolors.c deleted file mode 100644 index 349970f..0000000 --- a/patch/vtcolors.c +++ /dev/null @@ -1,70 +0,0 @@ -void -get_vt_colors(void) -{ - char *cfs[3] = { - "/sys/module/vt/parameters/default_red", - "/sys/module/vt/parameters/default_grn", - "/sys/module/vt/parameters/default_blu", - }; - char vtcs[16][8]; - char tk[] = ","; - char cl[64]; - char *tp = NULL; - FILE *fp; - size_t r; - int i, c, n; - - for (i = 0; i < 16; i++) - strcpy(vtcs[i], "#000000"); - - for (i = 0, r = 0; i < 3; i++) { - if ((fp = fopen(cfs[i], "r")) == NULL) - continue; - while ((cl[r] = fgetc(fp)) != EOF && cl[r] != '\n') - r++; - cl[r] = '\0'; - for (c = 0, tp = cl, n = 0; c < 16; c++, tp++) { - if ((r = strcspn(tp, tk)) == -1) - break; - for (n = 0; r && *tp >= 48 && *tp < 58; r--, tp++) - n = n * 10 - 48 + *tp; - vtcs[c][i * 2 + 1] = n / 16 < 10 ? n / 16 + 48 : n / 16 + 87; - vtcs[c][i * 2 + 2] = n % 16 < 10 ? n % 16 + 48 : n % 16 + 87; - } - fclose(fp); - } - for (i = 0; i < LENGTH(colors); i++) { - #if FLOAT_BORDER_COLOR_PATCH - for (c = 0; c < 4; c++) - #else - for (c = 0; c < 3; c++) - #endif // FLOAT_BORDER_COLOR_PATCH - { - n = color_ptrs[i][c]; - if (n > -1 && strlen(colors[i][c]) >= strlen(vtcs[n])) - memcpy(colors[i][c], vtcs[n], 7); - } - } -} - -int get_luminance(char *r) -{ - char *c = r; - int n[3] = {0}; - int i = 0; - - while (*c) { - if (*c >= 48 && *c < 58) - n[i / 2] = n[i / 2] * 16 - 48 + *c; - else if (*c >= 65 && *c < 71) - n[i / 2] = n[i / 2] * 16 - 55 + *c; - else if (*c >= 97 && *c < 103) - n[i / 2] = n[i / 2] * 16 - 87 + *c; - else - i--; - i++; - c++; - } - - return (0.299 * n[0] + 0.587 * n[1] + 0.114 * n[2]) / 2.55; -} \ No newline at end of file diff --git a/patch/vtcolors.h b/patch/vtcolors.h deleted file mode 100644 index 7341e6a..0000000 --- a/patch/vtcolors.h +++ /dev/null @@ -1,2 +0,0 @@ -static void get_vt_colors(void); -static int get_luminance(char *rgb); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index a95e26e..537e042 100644 --- a/patches.def.h +++ b/patches.def.h @@ -79,6 +79,14 @@ /* Show window title in bar */ #define BAR_WINTITLE_PATCH 1 +/* Title bar modules such as wintitle (default), fancybar and awesomebar + * do not by default add left and/or right padding as they take up the + * remaining space. These options allow you explicitly add padding should + * you need it. + */ +#define BAR_TITLE_RIGHT_PAD 0 +#define BAR_TITLE_LEFT_PAD 1 + /** * Bar options */ @@ -191,20 +199,6 @@ */ #define BAR_PANGO_PATCH 0 -/* This patch allows the status text to be fixed to the bar on a specific - * monitor rather than being drawn on the focused monitor. - * The statusallmons patch takes precedence over this patch. - * NB: If used together with the systray patch then consider setting - * systraypinning to statmonval+1. - * https://dwm.suckless.org/patches/staticstatus/ - */ -#define BAR_STATICSTATUS_PATCH 0 - -/* This patch draws and updates the statusbar on all monitors. - * https://dwm.suckless.org/patches/statusallmons/ - */ -#define BAR_STATUSALLMONS_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. -- cgit v1.2.3 From aff7c0d8b8cd51b82df7d48c6db14af3353632cf Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Jul 2020 13:04:39 +0200 Subject: Revert config.mk uncommenting --- config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.mk b/config.mk index 8694c43..e92e380 100644 --- a/config.mk +++ b/config.mk @@ -21,7 +21,7 @@ FREETYPEINC = /usr/include/freetype2 #FREETYPEINC = ${X11INC}/freetype2 # Uncomment this for the alpha patch / BAR_ALPHA_PATCH -XRENDER = -lXrender +#XRENDER = -lXrender # Uncomment this for the mdpcontrol patch / MDPCONTROL_PATCH #MPDCLIENT = -lmpdclient @@ -34,7 +34,7 @@ XRENDER = -lXrender #XEXTLIB = -lXext # Uncomment this for the swallow patch / SWALLOW_PATCH -XCBLIBS = -lX11-xcb -lxcb -lxcb-res +#XCBLIBS = -lX11-xcb -lxcb -lxcb-res # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} ${PANGOINC} -- cgit v1.2.3 From 346d7f6b1dee89c7700dc43a9476367e6e5ff0dc Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Jul 2020 18:58:39 +0200 Subject: Making bars list into linked list --- dwm.c | 158 ++++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/dwm.c b/dwm.c index 1e0d51d..a14b48d 100644 --- a/dwm.c +++ b/dwm.c @@ -203,7 +203,9 @@ typedef struct Bar Bar; struct Bar { Window win; Monitor *mon; + Bar *next; int idx; + int topbar; int bx, by, bw, bh; /* bar geometry */ int w[BARRULES]; // width, array length == barrules, then use r index for lookup purposes int x[BARRULES]; // x position, array length == ^ @@ -355,16 +357,11 @@ struct Monitor { unsigned int sellt; unsigned int tagset[2]; int showbar; - int topbar; Client *clients; Client *sel; Client *stack; Monitor *next; - #if BAR_EXTRABAR_PATCH - Bar *bars[2]; - #else - Bar *bars[1]; - #endif // BAR_EXTRABAR_PATCH + Bar *bar; const Layout *lt[2]; #if BAR_ALTERNATIVE_TAGS_PATCH unsigned int alttag; @@ -878,10 +875,11 @@ attachstack(Client *c) void buttonpress(XEvent *e) { - int click, i, b, r, mi; + int click, i, r, mi; Arg arg = {0}; Client *c; Monitor *m; + Bar *bar; XButtonPressedEvent *ev = &e->xbutton; const BarRule *br; BarClickArg carg = { 0, 0, 0, 0 }; @@ -899,20 +897,20 @@ buttonpress(XEvent *e) } for (mi = 0, m = mons; m && m != selmon; m = m->next, mi++); // get the monitor index - for (b = 0; b < LENGTH(selmon->bars); b++) { - if (ev->window == selmon->bars[b]->win) { + for (bar = selmon->bar; bar; bar = bar->next) { + if (ev->window == bar->win) { for (r = 0; r < LENGTH(barrules); r++) { br = &barrules[r]; - if (br->bar != b || (br->monitor == 'A' && m != selmon) || br->clickfunc == NULL) + if (br->bar != bar->idx || (br->monitor == 'A' && m != selmon) || br->clickfunc == NULL) continue; if (br->monitor != 'A' && br->monitor != -1 && br->monitor != mi) continue; - if (selmon->bars[b]->x[r] <= ev->x && ev->x <= selmon->bars[b]->x[r] + selmon->bars[b]->w[r]) { - carg.rel_x = ev->x - selmon->bars[b]->x[r]; + if (bar->x[r] <= ev->x && ev->x <= bar->x[r] + bar->w[r]) { + carg.rel_x = ev->x - bar->x[r]; carg.rel_y = ev->y; - carg.rel_w = selmon->bars[b]->w[r]; - carg.rel_h = selmon->bars[b]->bh; - click = br->clickfunc(selmon->bars[b], &arg, &carg); + carg.rel_w = bar->w[r]; + carg.rel_h = bar->bh; + click = br->clickfunc(bar, &arg, &carg); if (click < 0) return; break; @@ -1005,7 +1003,7 @@ void cleanupmon(Monitor *mon) { Monitor *m; - int b; + Bar *bar; if (mon == mons) mons = mons->next; @@ -1013,12 +1011,11 @@ cleanupmon(Monitor *mon) for (m = mons; m && m->next != mon; m = m->next); m->next = mon->next; } - for (b = 0; b < LENGTH(mon->bars); b++) { - if (mon->bars[b]) { - XUnmapWindow(dpy, mon->bars[b]->win); - XDestroyWindow(dpy, mon->bars[b]->win); - } - free(mon->bars[b]); + for (bar = mon->bar; bar; bar = mon->bar) { + XUnmapWindow(dpy, bar->win); + XDestroyWindow(dpy, bar->win); + mon->bar = bar->next; + free(bar); } free(mon); } @@ -1047,11 +1044,7 @@ clientmessage(XEvent *e) return; } - #if BAR_SYSTRAY_WIN_PATCH c->mon = selmon; - #else - c->mon = systray->mon; - #endif // BAR_SYSTRAY_WIN_PATCH c->next = systray->icons; systray->icons = c; XGetWindowAttributes(dpy, c->win, &wa); @@ -1148,12 +1141,12 @@ void configurenotify(XEvent *e) { Monitor *m; + Bar *bar; #if !FAKEFULLSCREEN_PATCH Client *c; #endif // !FAKEFULLSCREEN_PATCH XConfigureEvent *ev = &e->xconfigure; int dirty; - int b; /* TODO: updategeom handling sucks, needs to be simplified */ if (ev->window == root) { @@ -1173,9 +1166,8 @@ configurenotify(XEvent *e) #endif // FAKEFULLSCREEN_CLIENT_PATCH resizeclient(c, m->mx, m->my, m->mw, m->mh); #endif // !FAKEFULLSCREEN_PATCH - for (b = 0; b < LENGTH(m->bars); b++) - if (m->bars[b]) - XMoveResizeWindow(dpy, m->bars[b]->win, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh); + for (bar = m->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); } focus(NULL); arrange(NULL); @@ -1243,9 +1235,12 @@ Monitor * createmon(void) { Monitor *m; - int i; + int i, n, mi, max_bars = 2, istopbar = topbar; + + const BarRule *br; + Bar *bar; #if MONITOR_RULES_PATCH - int mi, j; + int j; Monitor *mon; const MonitorRule *mr; #endif // MONITOR_RULES_PATCH @@ -1262,7 +1257,6 @@ createmon(void) m->nstack = nstack; #endif // FLEXTILE_DELUXE_LAYOUT m->showbar = showbar; - m->topbar = topbar; #if SETBORDERPX_PATCH m->borderpx = borderpx; #endif // SETBORDERPX_PATCH @@ -1273,19 +1267,8 @@ createmon(void) m->gappov = gappov; #endif // VANITYGAPS_PATCH - for (i = 0; i < LENGTH(m->bars); i++) { - fprintf(stderr, "creating bar, idx = %d\n", i); - m->bars[i] = ecalloc(1, sizeof(Bar)); - m->bars[i]->mon = m; - m->bars[i]->idx = i; - fprintf(stderr, "%s\n", "finished creating bar"); - } - // for (r = 0; r < LENGTH(barrules); r++) { - - // for (b = 0; b < LENGTH(selmon->bars); b++) { - - #if MONITOR_RULES_PATCH for (mi = 0, mon = mons; mon; mon = mon->next, mi++); // monitor index + #if MONITOR_RULES_PATCH for (j = 0; j < LENGTH(monrules); j++) { mr = &monrules[j]; if ((mr->monitor == -1 || mr->monitor == mi) @@ -1304,7 +1287,7 @@ createmon(void) if (mr->showbar > -1) m->showbar = mr->showbar; if (mr->topbar > -1) - m->topbar = mr->topbar; + istopbar = mr->topbar; break; } } @@ -1314,6 +1297,23 @@ createmon(void) strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); #endif // MONITOR_RULES_PATCH + /* Derive the number of bars for this monitor based on bar rules */ + for (n = -1, i = 0; i < LENGTH(barrules); i++) { + br = &barrules[i]; + if (br->monitor == 'A' || br->monitor == -1 || br->monitor == mi) + n = MAX(br->bar, n); + } + + for (i = 0; i <= n && i < max_bars; i++) { + bar = ecalloc(1, sizeof(Bar)); + bar->mon = m; + bar->idx = i; + bar->next = m->bar; + bar->topbar = istopbar; + m->bar = bar; + istopbar = !istopbar; + } + #if FLEXTILE_DELUXE_LAYOUT m->ltaxis[LAYOUT] = m->lt[0]->preset.layout; m->ltaxis[MASTER] = m->lt[0]->preset.masteraxis; @@ -1450,8 +1450,9 @@ dirtomon(int dir) void drawbar(Monitor *m) { - for (int b = 0; b < LENGTH(m->bars); b++) - drawbarwin(m->bars[b]); + Bar *bar; + for (bar = m->bar; bar; bar = bar->next) + drawbarwin(bar); } void @@ -1499,7 +1500,7 @@ drawbarwin(Bar *bar) w = br->widthfunc(bar, &warg); w = MIN(warg.max_width, w); - if (lw <= 0) { // if left is exhausted, switch to right side + if (lw <= 0) { // if left is exhausted then switch to right side, and vice versa lw = rw; lx = rx; } else if (rw <= 0) { @@ -1957,7 +1958,7 @@ manage(Window w, XWindowAttributes *wa) c->y = c->mon->my + c->mon->mh - HEIGHT(c); c->x = MAX(c->x, c->mon->mx); /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((c->mon->bars[0]->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) + c->y = MAX(c->y, ((c->mon->bar->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); #if !FLOATPOS_PATCH #if SETBORDERPX_PATCH @@ -2481,7 +2482,7 @@ restack(Monitor *m) XRaiseWindow(dpy, m->sel->win); if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; - wc.sibling = m->bars[0]->win; + wc.sibling = m->bar->win; for (c = m->stack; c; c = c->snext) if (!c->isfloating && ISVISIBLE(c)) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); @@ -3149,7 +3150,7 @@ tagmon(const Arg *arg) void togglebar(const Arg *arg) { - int b; + Bar *bar; #if BAR_HOLDBAR_PATCH && PERTAG_PATCH && PERTAGBAR_PATCH selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = (selmon->showbar == 2 ? 1 : !selmon->showbar); #elif BAR_HOLDBAR_PATCH @@ -3160,9 +3161,8 @@ togglebar(const Arg *arg) selmon->showbar = !selmon->showbar; #endif // BAR_HOLDBAR_PATCH | PERTAG_PATCH updatebarpos(selmon); - for (b = 0; b < LENGTH(selmon->bars); b++) - if (selmon->bars[b]->win) - XMoveResizeWindow(dpy, selmon->bars[b]->win, selmon->bars[b]->bx, selmon->bars[b]->by, selmon->bars[b]->bw, selmon->bars[b]->bh); + for (bar = selmon->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); arrange(selmon); } @@ -3425,7 +3425,7 @@ unmapnotify(XEvent *e) void updatebars(void) { - int b; + Bar *bar; Monitor *m; XSetWindowAttributes wa = { .override_redirect = True, @@ -3440,20 +3440,20 @@ updatebars(void) }; XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { - for (b = 0; b < LENGTH(m->bars); b++) { - if (!m->bars[b]->win) { // TODO add static status controls to not create / show extra bar? + for (bar = m->bar; bar; bar = bar->next) { + if (!bar->win) { // TODO add static status controls to not create / show extra bar? #if BAR_ALPHA_PATCH - m->bars[b]->win = XCreateWindow(dpy, root, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, 0, depth, + bar->win = XCreateWindow(dpy, root, bar->bx, bar->by, bar->bw, bar->bh, 0, depth, InputOutput, visual, CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); #else - m->bars[b]->win = XCreateWindow(dpy, root, m->bars[b]->bx, m->bars[b]->by, m->bars[b]->bw, m->bars[b]->bh, 0, DefaultDepth(dpy, screen), + bar->win = XCreateWindow(dpy, root, bar->bx, bar->by, bar->bw, bar->bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); #endif // BAR_ALPHA_PATCH - XDefineCursor(dpy, m->bars[b]->win, cursor[CurNormal]->cursor); - XMapRaised(dpy, m->bars[b]->win); - XSetClassHint(dpy, m->bars[b]->win, &ch); + XDefineCursor(dpy, bar->win, cursor[CurNormal]->cursor); + XMapRaised(dpy, bar->win); + XSetClassHint(dpy, bar->win, &ch); } } } @@ -3464,7 +3464,8 @@ updatebarpos(Monitor *m) { m->wy = m->my; m->wh = m->mh; - int num_bars, b; + int num_bars; + Bar *bar; #if BAR_PADDING_PATCH int y_pad = vertpad; int x_pad = sidepad; @@ -3473,20 +3474,22 @@ updatebarpos(Monitor *m) int x_pad = 0; #endif // BAR_PADDING_PATCH - num_bars = LENGTH(m->bars); - if (m->showbar) { + for (num_bars = 0, bar = m->bar; bar; bar = bar->next, num_bars++); + if (m->showbar) m->wh = m->wh - y_pad * num_bars - bh * num_bars; - m->wy = m->wy + bh + y_pad; - } - for (b = 0; b < num_bars; b++) { - m->bars[b]->bx = m->mx + x_pad; - m->bars[b]->bw = m->ww - 2 * x_pad; - m->bars[b]->bh = bh; + for (bar = m->bar; bar; bar = bar->next) { + bar->bx = m->mx + x_pad; + bar->bw = m->ww - 2 * x_pad; + bar->bh = bh; if (m->showbar) { - m->bars[b]->by = m->topbar == b ? m->wy + m->wh : m->wy - bh; + if (bar->topbar) { + m->wy = m->wy + bh + y_pad; + bar->by = m->wy - bh; + } else + bar->by = m->wy + m->wh; } else { - m->bars[b]->by = -bh - y_pad; + bar->by = -bh - y_pad; } } } @@ -3783,15 +3786,16 @@ wintoclient(Window w) Monitor * wintomon(Window w) { - int x, y, b; + int x, y; Client *c; Monitor *m; + Bar *bar; if (w == root && getrootptr(&x, &y)) return recttomon(x, y, 1, 1); for (m = mons; m; m = m->next) - for (b = 0; b < LENGTH(m->bars); b++) - if (w == m->bars[b]->win) + for (bar = m->bar; bar; bar = bar->next) + if (w == bar->win) return m; if ((c = wintoclient(w))) return c->mon; -- cgit v1.2.3 From 250fbbd2c77a36b1b7d22c252fb781cbab09ca79 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Jul 2020 18:59:03 +0200 Subject: holdbar: changes for new bar --- patch/bar_holdbar.c | 80 ++++++----------------------------------------------- patch/bar_holdbar.h | 3 +- patch/include.c | 6 ++-- patch/include.h | 6 ++-- 4 files changed, 16 insertions(+), 79 deletions(-) diff --git a/patch/bar_holdbar.c b/patch/bar_holdbar.c index 4be9af1..358cbec 100644 --- a/patch/bar_holdbar.c +++ b/patch/bar_holdbar.c @@ -3,25 +3,17 @@ holdbar(const Arg *arg) { if (selmon->showbar) return; + Bar *bar; selmon->showbar = 2; - updateholdbarpos(selmon); - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #endif // BAR_EXTRABAR_PATCH + updatebarpos(selmon); + for (bar = selmon->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); } void keyrelease(XEvent *e) { + Bar *bar; if (XEventsQueued(dpy, QueuedAfterReading)) { XEvent ne; XPeekEvent(dpy, &ne); @@ -34,66 +26,12 @@ keyrelease(XEvent *e) } if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY) && selmon->showbar == 2) { selmon->showbar = 0; - updateholdbarpos(selmon); - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx + sp, selmon->eby - vp, selmon->ww - 2 * sp, bh); - #else - XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon->eby, selmon->ww, bh); - #endif // BAR_PADDING_PATCH - #endif // BAR_EXTRABAR_PATCH + updatebarpos(selmon); + for (bar = selmon->bar; bar; bar = bar->next) + XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); arrange(selmon); } #if COMBO_PATCH combo = 0; #endif // COMBO_PATCH -} - -void -updateholdbarpos(Monitor *m) -{ - m->wy = m->my; - m->wh = m->mh; - #if BAR_EXTRABAR_PATCH - #if BAR_PADDING_PATCH - m->wh = m->wh - vertpad * m->showbar * 2 - bh * m->showbar * 2; - m->wy = m->showbar ? m->wy + bh + vertpad: m->wy; - if (m->showbar) { - m->by = m->topbar ? m->wy - bh - vertpad: m->wy + m->wh + vertpad; - m->eby = m->topbar ? m->wy + m->wh + vertpad: m->wy - bh - vertpad; - } else { - m->by = -bh - vertpad; - m->eby = -bh - vertpad; - } - #else - m->wh = m->wh - bh * m->showbar * 2; - m->wy = m->showbar ? m->wy + bh : m->wy; - if (m->showbar) { - m->by = m->topbar ? m->wy - bh : m->wy + m->wh; - m->eby = m->topbar ? m->wy + m->wh : m->wy - bh; - } else { - m->by = -bh; - m->eby = -bh; - } - #endif // BAR_PADDING_PATCH - #elif BAR_PADDING_PATCH - if (m->showbar) { - m->wh = m->wh - vertpad - bh; - m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad; - m->wy = m->topbar ? m->wy + bh + vp : m->wy; - } else - m->by = -bh - vp; - #else - if (m->showbar) { - m->wh -= bh; - m->by = m->topbar ? m->wy : m->wy + m->wh; - m->wy = m->topbar ? m->wy + bh : m->wy; - } else - m->by = -bh; - #endif // BAR_EXTRABAR_PATCH -} +} \ No newline at end of file diff --git a/patch/bar_holdbar.h b/patch/bar_holdbar.h index 719b9ea..5394425 100644 --- a/patch/bar_holdbar.h +++ b/patch/bar_holdbar.h @@ -1,3 +1,2 @@ static void keyrelease(XEvent *e); -static void holdbar(const Arg *arg); -static void updateholdbarpos(Monitor *m); \ No newline at end of file +static void holdbar(const Arg *arg); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 7fe397f..ec8f591 100644 --- a/patch/include.c +++ b/patch/include.c @@ -11,6 +11,9 @@ #if BAR_EWMHTAGS_PATCH #include "bar_ewmhtags.c" #endif +#if COMBO_PATCH +#include "combo.c" +#endif #if BAR_HOLDBAR_PATCH #include "bar_holdbar.c" #endif @@ -73,9 +76,6 @@ #if CMDCUSTOMIZE_PATCH #include "cmdcustomize.c" #endif -#if COMBO_PATCH -#include "combo.c" -#endif #if CYCLELAYOUTS_PATCH #include "cyclelayouts.c" #endif diff --git a/patch/include.h b/patch/include.h index 6e08d0e..e44bfbe 100644 --- a/patch/include.h +++ b/patch/include.h @@ -11,6 +11,9 @@ #if BAR_EWMHTAGS_PATCH #include "bar_ewmhtags.h" #endif +#if COMBO_PATCH +#include "combo.h" +#endif #if BAR_HOLDBAR_PATCH #include "bar_holdbar.h" #endif @@ -70,9 +73,6 @@ #if CMDCUSTOMIZE_PATCH #include "cmdcustomize.h" #endif -#if COMBO_PATCH -#include "combo.h" -#endif #if CYCLELAYOUTS_PATCH #include "cyclelayouts.h" #endif -- cgit v1.2.3 From 6961418d636985d96c0c3248752e642b0ec4c84b Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 18 Jul 2020 21:12:30 +0200 Subject: Extrabar --> extrastatus --- config.def.h | 16 ++++++++-------- dwm.c | 12 ++++++------ patch/bar_status.c | 24 ++++++++++++++++++++++++ patch/bar_status.h | 6 ++++++ patch/bar_status2d.c | 16 ++++++++++++++++ patch/bar_status2d.h | 6 ++++++ patch/bar_status2d_eb.c | 11 ----------- patch/bar_status_eb.c | 19 ------------------- patch/bar_status_eb.h | 2 -- patch/bar_statuscmd.c | 6 +++--- patch/bar_statuscmd.h | 6 +++--- patch/include.c | 6 ------ patch/include.h | 6 ------ patches.def.h | 8 ++++---- 14 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 patch/bar_status2d_eb.c delete mode 100644 patch/bar_status_eb.c delete mode 100644 patch/bar_status_eb.h diff --git a/config.def.h b/config.def.h index f7e2238..d957986 100644 --- a/config.def.h +++ b/config.def.h @@ -49,9 +49,9 @@ static const int showsystray = 1; /* 0 means no systray */ #if ONLYQUITONEMPTY_PATCH static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */ #endif // ONLYQUITONEMPTY_PATCH -#if BAR_EXTRABAR_PATCH +#if BAR_EXTRASTATUS_PATCH static const char statussep = ';'; /* separator between status bars */ -#endif // BAR_EXTRABAR_PATCH +#endif // BAR_EXTRASTATUS_PATCH #if BAR_PANGO_PATCH static const char font[] = "monospace 10"; #else @@ -405,17 +405,17 @@ static const BarRule barrules[] = { #elif BAR_WINTITLE_PATCH { -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" }, #endif // BAR_AWESOMEBAR_PATCH | BAR_FANCYBAR_PATCH BAR_WINTITLE_PATCH - #if BAR_EXTRABAR_PATCH + #if BAR_EXTRASTATUS_PATCH #if BAR_STATUS2D_PATCH && BAR_STATUSCMD_PATCH - { 'A', 1, BAR_ALIGN_CENTER, width_status2d_eb, draw_status2d_eb, click_statuscmd_eb, "status2d_eb" }, + { 'A', 1, BAR_ALIGN_CENTER, width_status2d_es, draw_status2d_es, click_statuscmd_es, "status2d_es" }, #elif BAR_STATUS2D_PATCH - { 'A', 1, BAR_ALIGN_CENTER, width_status2d_eb, draw_status2d_eb, click_status2d, "status2d_eb" }, + { 'A', 1, BAR_ALIGN_CENTER, width_status2d_es, draw_status2d_es, click_status2d, "status2d_es" }, #elif BAR_STATUSCMD_PATCH - { 'A', 1, BAR_ALIGN_CENTER, width_status_eb, draw_status_eb, click_statuscmd_eb, "status_eb" }, + { 'A', 1, BAR_ALIGN_CENTER, width_status_es, draw_status_es, click_statuscmd_es, "status_es" }, #elif BAR_STATUS_PATCH - { 'A', 1, BAR_ALIGN_CENTER, width_status_eb, draw_status_eb, click_status, "status_eb" }, + { 'A', 1, BAR_ALIGN_CENTER, width_status_es, draw_status_es, click_status, "status_es" }, #endif // BAR_STATUS2D_PATCH | BAR_STATUSCMD_PATCH - #endif // BAR_EXTRABAR_PATCH + #endif // BAR_EXTRASTATUS_PATCH }; #if DWMC_PATCH diff --git a/dwm.c b/dwm.c index a14b48d..9de4559 100644 --- a/dwm.c +++ b/dwm.c @@ -564,14 +564,14 @@ static char stext[1024]; #else static char stext[512]; #endif // BAR_STATUS2D_PATCH -#if BAR_EXTRABAR_PATCH || BAR_STATUSCMD_PATCH +#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH #if BAR_STATUS2D_PATCH static char rawstext[1024]; #else static char rawstext[512]; #endif // BAR_STATUS2D_PATCH -#endif // BAR_EXTRABAR_PATCH | BAR_STATUSCMD_PATCH -#if BAR_EXTRABAR_PATCH +#endif // BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH +#if BAR_EXTRASTATUS_PATCH #if BAR_STATUS2D_PATCH && !BAR_STATUSCOLORS_PATCH static char estext[1024]; #else @@ -582,7 +582,7 @@ static char rawestext[1024]; #else static char rawestext[512]; #endif // BAR_STATUSCMD_PATCH -#endif // BAR_EXTRABAR_PATCH +#endif // BAR_EXTRASTATUS_PATCH static int screen; static int sw, sh; /* X display screen geometry width, height */ @@ -3667,7 +3667,7 @@ void updatestatus(void) { Monitor *m; - #if BAR_EXTRABAR_PATCH + #if BAR_EXTRASTATUS_PATCH if (!gettextprop(root, XA_WM_NAME, rawstext, sizeof(rawstext))) { strcpy(stext, "dwm-"VERSION); estext[0] = '\0'; @@ -3698,7 +3698,7 @@ updatestatus(void) #else if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) strcpy(stext, "dwm-"VERSION); - #endif // BAR_EXTRABAR_PATCH + #endif // BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH for (m = mons; m; m = m->next) drawbar(m); } diff --git a/patch/bar_status.c b/patch/bar_status.c index 9c3aafe..0234276 100644 --- a/patch/bar_status.c +++ b/patch/bar_status.c @@ -8,6 +8,18 @@ width_status(Bar *bar, BarWidthArg *a) #endif // BAR_PANGO_PATCH } +#if BAR_EXTRASTATUS_PATCH +int +width_status_es(Bar *bar, BarWidthArg *a) +{ + #if BAR_PANGO_PATCH + return TEXTWM(estext) - lrpad; + #else + return TEXTW(estext) - lrpad; + #endif // BAR_PANGO_PATCH +} +#endif // BAR_EXTRASTATUS_PATCH + int draw_status(Bar *bar, BarDrawArg *a) { @@ -18,6 +30,18 @@ draw_status(Bar *bar, BarDrawArg *a) #endif // BAR_PANGO_PATCH } +#if BAR_EXTRASTATUS_PATCH +int +draw_status_es(Bar *bar, BarDrawArg *a) +{ + #if BAR_PANGO_PATCH + return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0, True); + #else + return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0); + #endif // BAR_PANGO_PATCH +} +#endif // BAR_EXTRASTATUS_PATCH + int click_status(Bar *bar, Arg *arg, BarClickArg *a) { diff --git a/patch/bar_status.h b/patch/bar_status.h index bd169d9..36fabbb 100644 --- a/patch/bar_status.h +++ b/patch/bar_status.h @@ -1,3 +1,9 @@ static int width_status(Bar *bar, BarWidthArg *a); +#if BAR_EXTRASTATUS_PATCH +static int width_status_es(Bar *bar, BarWidthArg *a); +#endif // BAR_EXTRASTATUS_PATCH static int draw_status(Bar *bar, BarDrawArg *a); +#if BAR_EXTRASTATUS_PATCH +static int draw_status_es(Bar *bar, BarDrawArg *a); +#endif // BAR_EXTRASTATUS_PATCH static int click_status(Bar *bar, Arg *arg, BarClickArg *a); \ No newline at end of file diff --git a/patch/bar_status2d.c b/patch/bar_status2d.c index c4c7689..e746ac6 100644 --- a/patch/bar_status2d.c +++ b/patch/bar_status2d.c @@ -4,12 +4,28 @@ width_status2d(Bar *bar, BarWidthArg *a) return status2dtextlength(rawstext) + lrpad; } +#if BAR_EXTRASTATUS_PATCH +int +width_status2d_es(Bar *bar, BarWidthArg *a) +{ + return status2dtextlength(rawestext); +} +#endif // BAR_EXTRASTATUS_PATCH + int draw_status2d(Bar *bar, BarDrawArg *a) { return drawstatusbar(a->x, rawstext); } +#if BAR_EXTRASTATUS_PATCH +int +draw_status2d_es(Bar *bar, BarDrawArg *a) +{ + return drawstatusbar(a->x, rawestext); +} +#endif // BAR_EXTRASTATUS_PATCH + #if !BAR_STATUSCMD_PATCH int click_status2d(Bar *bar, Arg *arg, BarClickArg *a) diff --git a/patch/bar_status2d.h b/patch/bar_status2d.h index 555b093..cdaa2a8 100644 --- a/patch/bar_status2d.h +++ b/patch/bar_status2d.h @@ -1,5 +1,11 @@ static int width_status2d(Bar *bar, BarWidthArg *a); +#if BAR_EXTRASTATUS_PATCH +static int width_status2d_es(Bar *bar, BarWidthArg *a); +#endif // BAR_EXTRASTATUS_PATCH static int draw_status2d(Bar *bar, BarDrawArg *a); +#if BAR_EXTRASTATUS_PATCH +static int draw_status2d_es(Bar *bar, BarDrawArg *a); +#endif // BAR_EXTRASTATUS_PATCH #if !BAR_STATUSCMD_PATCH static int click_status2d(Bar *bar, Arg *arg, BarClickArg *a); #endif // BAR_STATUSCMD_PATCH diff --git a/patch/bar_status2d_eb.c b/patch/bar_status2d_eb.c deleted file mode 100644 index 5d67b88..0000000 --- a/patch/bar_status2d_eb.c +++ /dev/null @@ -1,11 +0,0 @@ -int -width_status2d_eb(Bar *bar, BarWidthArg *a) -{ - return status2dtextlength(rawestext); -} - -int -draw_status2d_eb(Bar *bar, BarDrawArg *a) -{ - return drawstatusbar(a->x, rawestext); -} \ No newline at end of file diff --git a/patch/bar_status_eb.c b/patch/bar_status_eb.c deleted file mode 100644 index 71944b4..0000000 --- a/patch/bar_status_eb.c +++ /dev/null @@ -1,19 +0,0 @@ -int -width_status_eb(Bar *bar, BarWidthArg *a) -{ - #if BAR_PANGO_PATCH - return TEXTWM(estext) - lrpad; - #else - return TEXTW(estext) - lrpad; - #endif // BAR_PANGO_PATCH -} - -int -draw_status_eb(Bar *bar, BarDrawArg *a) -{ - #if BAR_PANGO_PATCH - return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0, True); - #else - return drw_text(drw, a->x, 0, a->w, bh, 0, estext, 0); - #endif // BAR_PANGO_PATCH -} \ No newline at end of file diff --git a/patch/bar_status_eb.h b/patch/bar_status_eb.h deleted file mode 100644 index c2ec004..0000000 --- a/patch/bar_status_eb.h +++ /dev/null @@ -1,2 +0,0 @@ -static int width_status_eb(Bar *bar, BarWidthArg *a); -static int draw_status_eb(Bar *bar, BarDrawArg *a); \ No newline at end of file diff --git a/patch/bar_statuscmd.c b/patch/bar_statuscmd.c index 5825647..0cd6013 100644 --- a/patch/bar_statuscmd.c +++ b/patch/bar_statuscmd.c @@ -10,13 +10,13 @@ click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a) return click_statuscmd_text(arg, a->rel_x, rawstext); } -#if BAR_EXTRABAR_PATCH +#if BAR_EXTRASTATUS_PATCH int -click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a) +click_statuscmd_es(Bar *bar, Arg *arg, BarClickArg *a) { return click_statuscmd_text(arg, a->rel_x, rawestext); } -#endif // BAR_EXTRABAR_PATCH +#endif // BAR_EXTRASTATUS_PATCH int click_statuscmd_text(Arg *arg, int rel_x, char *text) diff --git a/patch/bar_statuscmd.h b/patch/bar_statuscmd.h index bcbcb33..0e1e184 100644 --- a/patch/bar_statuscmd.h +++ b/patch/bar_statuscmd.h @@ -1,6 +1,6 @@ static int click_statuscmd(Bar *bar, Arg *arg, BarClickArg *a); -#if BAR_EXTRABAR_PATCH -static int click_statuscmd_eb(Bar *bar, Arg *arg, BarClickArg *a); -#endif // BAR_EXTRABAR_PATCH +#if BAR_EXTRASTATUS_PATCH +static int click_statuscmd_es(Bar *bar, Arg *arg, BarClickArg *a); +#endif // BAR_EXTRASTATUS_PATCH static int click_statuscmd_text(Arg *arg, int rel_x, char *text); static void copyvalidchars(char *text, char *rawtext); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index ec8f591..cef9234 100644 --- a/patch/include.c +++ b/patch/include.c @@ -22,15 +22,9 @@ #endif #if BAR_STATUS_PATCH #include "bar_status.c" -#if BAR_EXTRABAR_PATCH -#include "bar_status_eb.c" -#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUS2D_PATCH #include "bar_status2d.c" -#if BAR_EXTRABAR_PATCH -#include "bar_status2d_eb.c" -#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUSBUTTON_PATCH #include "bar_statusbutton.c" diff --git a/patch/include.h b/patch/include.h index e44bfbe..8b1d470 100644 --- a/patch/include.h +++ b/patch/include.h @@ -22,15 +22,9 @@ #endif #if BAR_STATUS_PATCH #include "bar_status.h" -#if BAR_EXTRABAR_PATCH -#include "bar_status_eb.h" -#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUS2D_PATCH #include "bar_status2d.h" -#if BAR_EXTRABAR_PATCH -#include "bar_status2d_eb.h" -#endif // BAR_EXTRABAR_PATCH #endif #if BAR_STATUSBUTTON_PATCH #include "bar_statusbutton.h" diff --git a/patches.def.h b/patches.def.h index 537e042..e758aad 100644 --- a/patches.def.h +++ b/patches.def.h @@ -136,12 +136,12 @@ */ #define BAR_DMENUMATCHTOP_PATCH 0 -/* This patch will enable an extra status bar in dwm in a similar manner to the dualstatus - * patch. If the primary status is at the top via topbar then the extra status bar will be - * placed at the bottom and vice versa. +/* Originally this was the extrabar patch, but as the handling of extra bars is now built-in + * only the splitting of the status by a designated separator remains. As such this has been + * renamed to more accurately reflect what it does - creating an extra status. * https://dwm.suckless.org/patches/extrabar/ */ -#define BAR_EXTRABAR_PATCH 0 +#define BAR_EXTRASTATUS_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 -- cgit v1.2.3