sites

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

dwm-combo-5.9.diff (1723B)


      1 diff -r c361034c5a1c dwm.c
      2 --- a/dwm.c	Sat Sep 11 19:00:18 2010 +0000
      3 +++ b/dwm.c	Thu Nov 25 22:54:04 2010 -0800
      4 @@ -243,6 +243,11 @@
      5  static int xerrorstart(Display *dpy, XErrorEvent *ee);
      6  static void zoom(const Arg *arg);
      7  
      8 +static void keyrelease(XEvent *e);
      9 +static void combotag(const Arg *arg);
     10 +static void comboview(const Arg *arg);
     11 +
     12 +
     13  /* variables */
     14  static const char broken[] = "broken";
     15  static char stext[256];
     16 @@ -253,6 +258,7 @@
     17  static unsigned int numlockmask = 0;
     18  static void (*handler[LASTEvent]) (XEvent *) = {
     19  	[ButtonPress] = buttonpress,
     20 +	[ButtonRelease] = keyrelease,
     21  	[ClientMessage] = clientmessage,
     22  	[ConfigureRequest] = configurerequest,
     23  	[ConfigureNotify] = configurenotify,
     24 @@ -260,6 +266,7 @@
     25  	[EnterNotify] = enternotify,
     26  	[Expose] = expose,
     27  	[FocusIn] = focusin,
     28 +	[KeyRelease] = keyrelease,
     29  	[KeyPress] = keypress,
     30  	[MappingNotify] = mappingnotify,
     31  	[MapRequest] = maprequest,
     32 @@ -282,6 +289,40 @@
     33  struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
     34  
     35  /* function implementations */
     36 +static int combo = 0;
     37 +
     38 +void
     39 +keyrelease(XEvent *e) {
     40 +	combo = 0;
     41 +}
     42 +
     43 +void
     44 +combotag(const Arg *arg) {
     45 +	if(selmon->sel && arg->ui & TAGMASK) {
     46 +		if (combo) {
     47 +			selmon->sel->tags |= arg->ui & TAGMASK;
     48 +		} else {
     49 +			combo = 1;
     50 +			selmon->sel->tags = arg->ui & TAGMASK;
     51 +		}
     52 +		arrange(selmon);
     53 +	}
     54 +}
     55 +
     56 +void
     57 +comboview(const Arg *arg) {
     58 +	unsigned newtags = arg->ui & TAGMASK;
     59 +	if (combo) {
     60 +		selmon->tagset[selmon->seltags] |= newtags;
     61 +	} else {
     62 +		selmon->seltags ^= 1;	/*toggle tagset*/
     63 +		combo = 1;
     64 +		if (newtags)
     65 +			selmon->tagset[selmon->seltags] = newtags;
     66 +	}
     67 +	arrange(selmon);
     68 +}
     69 +
     70  void
     71  applyrules(Client *c) {
     72  	const char *class, *instance;