sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-multimon-3-reset_view-6.4.patch (7758B)


      1 From a69526cdfa0f3c15ac60e290cbd1282cd02a59c5 Mon Sep 17 00:00:00 2001
      2 From: "Gary B. Genett" <me@garybgenett.net>
      3 Date: Sun, 19 Feb 2023 08:58:02 -0800
      4 Subject: added reset_view function
      5 MIME-Version: 1.0
      6 Content-Type: multipart/mixed; boundary="------------2.37.4"
      7 
      8 This is a multi-part message in MIME format.
      9 --------------2.37.4
     10 Content-Type: text/plain; charset=UTF-8; format=fixed
     11 Content-Transfer-Encoding: 8bit
     12 
     13 ---
     14  config.def.h |  9 +++++++++
     15  dwm.c        | 30 ++++++++++++++++++++++++++++++
     16  2 files changed, 39 insertions(+)
     17 
     18 
     19 --------------2.37.4
     20 Content-Type: text/x-patch; name="0003-added-reset_view-function.patch"
     21 Content-Transfer-Encoding: 8bit
     22 Content-Disposition: attachment; filename="0003-added-reset_view-function.patch"
     23 
     24 diff --git a/config.def.h b/config.def.h
     25 index c59d27597a62ddf884baacded2830a318db1b45c..a664c793845c4c7c0ebe8ac69c96885c76193819 100644
     26 --- a/config.def.h
     27 +++ b/config.def.h
     28 @@ -27,23 +27,31 @@ static const Rule rules[] = {
     29  	 *	WM_NAME(STRING) = title
     30  	 */
     31  	/* class      instance    title       tags mask     isfloating   monitor */
     32  	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     33  	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     34  };
     35  
     36  /* layout(s) */
     37  static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
     38  static const int nmaster     = 1;    /* number of clients in master area */
     39 +static const int nviews      = 3;    /* mask of tags highlighted by default (tags 1-4) */
     40  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
     41  static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
     42  
     43 +static const float facts[1];    //static const float facts[]     = {     0,     0.5 }; // = mfact   // 50%
     44 +static const int masters[1];    //static const int masters[]     = {     0,      -1 }; // = nmaster // vertical stacking (for rotated monitor)
     45 +static const int views[1];      //static const int views[]       = {     0,      ~0 }; // = nviews  // all tags
     46 +/* invert tags after nviews */  /* array dimentions can both be as big as needed */  // final highlighted tags
     47 +static const int toggles[1][1]; //static const int toggles[2][2] = { {0,8}, {~0,~0} }; // 2-4+9     // all (leave as views above)
     48 +static const int toggles[1][1] = {{~0}};
     49 +
     50  static const Layout layouts[] = {
     51  	/* symbol     arrange function */
     52  	{ "[]=",      tile },    /* first entry is default */
     53  	{ "><>",      NULL },    /* no layout function means floating behavior */
     54  	{ "[M]",      monocle },
     55  };
     56  
     57  /* key definitions */
     58  #define WINKEY Mod4Mask
     59  #define MODKEY Mod1Mask
     60 @@ -90,30 +97,32 @@ static const Key keys[] = {
     61  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     62  	TAGKEYS(                        XK_1,                      0)
     63  	TAGKEYS(                        XK_2,                      1)
     64  	TAGKEYS(                        XK_3,                      2)
     65  	TAGKEYS(                        XK_4,                      3)
     66  	TAGKEYS(                        XK_5,                      4)
     67  	TAGKEYS(                        XK_6,                      5)
     68  	TAGKEYS(                        XK_7,                      6)
     69  	TAGKEYS(                        XK_8,                      7)
     70  	TAGKEYS(                        XK_9,                      8)
     71 +	{ MODKEY,                       XK_grave,  reset_view,     {0} },
     72  	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} },
     73  };
     74  
     75  /* button definitions */
     76  /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
     77  static const Button buttons[] = {
     78  	/* click                event mask      button          function        argument */
     79  	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
     80  	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
     81  	{ ClkMonNum,            0,              Button1,        focusmon,       {.i = +1} },
     82 +	{ ClkMonNum,            0,              Button2,        reset_view,     {0} },
     83  	{ ClkMonNum,            0,              Button3,        focusmon,       {.i = -1} },
     84  	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
     85  	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
     86  	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
     87  	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
     88  	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
     89  	{ ClkTagBar,            0,              Button1,        view,           {0} },
     90  	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
     91  	{ ClkTagBar,            MODKEY|WINKEY,  Button1,        nview,          {0} },
     92  	{ ClkTagBar,            MODKEY|WINKEY,  Button3,        ntoggleview,    {0} },
     93 diff --git a/dwm.c b/dwm.c
     94 index 2cf8d78c22c64ff26eda6195b6bd503f213a4d5f..93da0f4565d7a17ef96a1b167cfcb2c9f0ac6ad3 100644
     95 --- a/dwm.c
     96 +++ b/dwm.c
     97 @@ -229,20 +229,21 @@ static void updatetitle(Client *c);
     98  static void updatewindowtype(Client *c);
     99  static void updatewmhints(Client *c);
    100  static void nview(const Arg *arg);
    101  static void view(const Arg *arg);
    102  static Client *wintoclient(Window w);
    103  static Monitor *wintomon(Window w);
    104  static int xerror(Display *dpy, XErrorEvent *ee);
    105  static int xerrordummy(Display *dpy, XErrorEvent *ee);
    106  static int xerrorstart(Display *dpy, XErrorEvent *ee);
    107  static void zoom(const Arg *arg);
    108 +static void reset_view(const Arg *arg);
    109  
    110  /* variables */
    111  static const char broken[] = "broken";
    112  static char stext[256];
    113  static int screen;
    114  static int sw, sh;           /* X display screen geometry width, height */
    115  static int bh;               /* bar height */
    116  static int lrpad;            /* sum of left and right padding for text */
    117  static int (*xerrorxlib)(Display *, XErrorEvent *);
    118  static unsigned int numlockmask = 0;
    119 @@ -2161,33 +2162,62 @@ zoom(const Arg *arg)
    120  {
    121  	Client *c = selmon->sel;
    122  
    123  	if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
    124  		return;
    125  	if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
    126  		return;
    127  	pop(c);
    128  }
    129  
    130 +void
    131 +reset_view(const Arg *arg) {
    132 +	const int mon = selmon->num;
    133 +	Arg n = {.i = +1};	// focusmon(next monitor)
    134 +	Arg m = {.f = 0};	// mfact -> facts[]
    135 +	Arg i = {.i = 0};	// nmaster -> masters[]
    136 +	Arg v = {.ui = 0};	// nviews -> views[]
    137 +	Arg t = {.ui = 0};	// toggles[] -> toggleview()
    138 +	unsigned int x;
    139 +	do {
    140 +		focusmon(&n);
    141 +		m.f = (facts[selmon->num] ? facts[selmon->num] : mfact) +1;
    142 +		i.i = (masters[selmon->num] ? masters[selmon->num] : nmaster) - selmon->nmaster;
    143 +		v.ui = (views[selmon->num] == ~0 ? ~0 : ((1 << (views[selmon->num] ? (views[selmon->num] +1) : (nviews +1))) -1));
    144 +		setmfact(&m);
    145 +		incnmaster(&i);
    146 +		view(&v);
    147 +		for (x = 0; x < LENGTH(toggles[selmon->num]); x++) {
    148 +			if ((toggles[selmon->num][x] || toggles[selmon->num][x] == 0) && toggles[selmon->num][x] != ~0) {
    149 +				t.ui = (1 << toggles[selmon->num][x]);
    150 +				toggleview(&t);
    151 +			};
    152 +		}
    153 +	}
    154 +	while (selmon->num != mon);
    155 +}
    156 +
    157  int
    158  main(int argc, char *argv[])
    159  {
    160  	if (argc == 2 && !strcmp("-v", argv[1]))
    161  		die("dwm-"VERSION);
    162  	else if (argc != 1)
    163  		die("usage: dwm [-v]");
    164  	if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
    165  		fputs("warning: no locale support\n", stderr);
    166  	if (!(dpy = XOpenDisplay(NULL)))
    167  		die("dwm: cannot open display");
    168  	checkotherwm();
    169  	setup();
    170  #ifdef __OpenBSD__
    171  	if (pledge("stdio rpath proc exec", NULL) == -1)
    172  		die("pledge");
    173  #endif /* __OpenBSD__ */
    174  	scan();
    175 +	const Arg r = {0};
    176 +	reset_view(&r);
    177  	run();
    178  	cleanup();
    179  	XCloseDisplay(dpy);
    180  	return EXIT_SUCCESS;
    181  }
    182 
    183 --------------2.37.4--
    184 
    185