sites

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

dwm-combo-6.0.diff (1754B)


      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,42 @@
     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 +		focus(NULL);
     53 +		arrange(selmon);
     54 +	}
     55 +}
     56 +
     57 +void
     58 +comboview(const Arg *arg) {
     59 +	unsigned newtags = arg->ui & TAGMASK;
     60 +	if (combo) {
     61 +		selmon->tagset[selmon->seltags] |= newtags;
     62 +	} else {
     63 +		selmon->seltags ^= 1;	/*toggle tagset*/
     64 +		combo = 1;
     65 +		if (newtags)
     66 +			selmon->tagset[selmon->seltags] = newtags;
     67 +	}
     68 +	focus(NULL);
     69 +	arrange(selmon);
     70 +}
     71 +
     72  void
     73  applyrules(Client *c) {
     74  	const char *class, *instance;