sites

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

dwm-5.8-gestures.diff (2356B)


      1 diff dwm-5.8.2/config.h dwm-5.8.2mod/config.h
      2 92a93
      3 > 	{ ClkWinTitle,          0,              Button3,        startgesture,   {0} },
      4 100a102,113
      5 > };
      6 > 
      7 > //may want to reuse the architecture present in buttons[] and keys[]
      8 > static Gesture gestures[] = {
      9 > 	{"dl", spawn, SHCMD("konqueror") },
     10 > 	{"dr", spawn, SHCMD("pidgin" ) },
     11 > 	{"l",  spawn, SHCMD("xterm") },
     12 > 	{"ld", spawn, SHCMD("gimp" ) },
     13 > 	{"lr", spawn, SHCMD("google-chrome") },
     14 > 	{"r" , spawn, SHCMD("firefox") },
     15 > 	{"rl", spawn, SHCMD("pavucontrol") },
     16 > 	{"du", spawn, SHCMD("kate") },
     17 Only in dwm-5.8.2mod: config.h~
     18 Binary files dwm-5.8.2/dwm and dwm-5.8.2mod/dwm differ
     19 diff dwm-5.8.2/dwm.c dwm-5.8.2mod/dwm.c
     20 73a74,79
     21 > 	char *name;
     22 > 	void (*func)(const Arg *arg);
     23 > 	const Arg arg;
     24 > } Gesture;
     25 > 
     26 > typedef struct {
     27 244a251
     28 > static void startgesture(const Arg *arg);
     29 1248a1256,1318
     30 > 
     31 > void
     32 > startgesture(const Arg *arg) {
     33 > 	int x, y, dx, dy, q;
     34 > 	int valid=0, listpos=0, gestpos=0, count=0;
     35 > 	char move, currGest[10];
     36 > 	XEvent ev;
     37 > 	
     38 > 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
     39 > 		None, cursor[CurMove], CurrentTime) != GrabSuccess)
     40 > 		return;
     41 > 	if(!getrootptr(&x, &y))
     42 > 		return;
     43 > 	do {
     44 > 		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
     45 > 		switch (ev.type) {
     46 > 			case ConfigureRequest:
     47 > 			case Expose:
     48 > 			case MapRequest:
     49 > 				handler[ev.type](&ev);
     50 > 				break;
     51 > 			case MotionNotify:
     52 > 				if(count++ < 10)
     53 > 					break;
     54 > 				count = 0;
     55 > 				dx = ev.xmotion.x - x;
     56 > 				dy = ev.xmotion.y - y;
     57 > 				x = ev.xmotion.x;
     58 > 				y = ev.xmotion.y;
     59 > 				
     60 > 				if( abs(dx)/(abs(dy)+1) == 0 )
     61 > 					move = dy<0?'u':'d';
     62 > 				else
     63 > 					move = dx<0?'l':'r';
     64 > 				
     65 > 				if(move!=currGest[gestpos-1])
     66 > 				{	
     67 > 					if(gestpos>9)
     68 > 					{	ev.type++;
     69 > 						break;
     70 > 					}
     71 > 					
     72 > 					currGest[gestpos] = move;
     73 > 					currGest[++gestpos] = '\0';
     74 > 					
     75 > 					valid = 0;
     76 > 					for(q = 0; q<LENGTH(gestures); q++)
     77 > 					{	if(!strcmp(currGest, gestures[q].name))
     78 > 						{	valid++;
     79 > 							listpos = q;	
     80 > 						}
     81 > 					}
     82 > 				}
     83 > 				
     84 > 		}
     85 > 	} while(ev.type != ButtonRelease);
     86 > 	
     87 > 	if(valid)
     88 > 		gestures[listpos].func(&(gestures[listpos].arg));
     89 > 	
     90 > 	XUngrabPointer(dpy, CurrentTime);
     91 > }
     92 > 
     93 Only in dwm-5.8.2mod: dwm.c~
     94 Binary files dwm-5.8.2/dwm.o and dwm-5.8.2mod/dwm.o differ