*** xev.c_orig	Thu Jul 27 04:00:56 2000
--- xev.c	Mon Aug  7 20:19:34 2000
***************
*** 26,27 ****
--- 26,28 ----
  #include <ctype.h>
+ #include <math.h>
  
***************
*** 63,64 ****
--- 64,66 ----
  "    -rv                                 reverse video",
+ "    -l                                  limit to Key and Button events",
  "",
***************
*** 110,111 ****
--- 112,114 ----
      Bool reverse = False;
+     Bool limit = False;
      unsigned long back, fore;
***************
*** 156,157 ****
--- 159,163 ----
  		continue;
+ 	      case 'l':			/* -l */
+ 		limit = True;
+ 		continue;
  	      case 's':			/* -s */
***************
*** 234,235 ****
--- 240,242 ----
  	XEvent event;
+ 	BOOL event_done = True; /* with BOOL limit */
  
***************
*** 254,255 ****
--- 261,267 ----
  	    break;
+ 	  default:
+ 	    event_done = False;
+ 	}
+ 	if ( !limit && !event_done) {
+ 	 switch (event.type) {
  	  case MotionNotify:
***************
*** 375,376 ****
--- 387,389 ----
  	}
+     }
  
***************
*** 398,402 ****
      char *ksname;
!     int nbytes;
      char str[256+1];
-     int i;
  
--- 411,414 ----
      char *ksname;
!     int nbytes, i;
      char str[256+1];
  
***************
*** 411,412 ****
--- 423,442 ----
  	    e->state, e->keycode, ks, ksname, e->same_screen ? Yes : No);
+     printf("    modifier: ");
+     if (e->state) {
+ 	if (e->state & (int)pow(2, 0)) printf("%s ", "shift");
+ 	if (e->state & (int)pow(2, 1)) printf("%s ", "lock");
+ 	if (e->state & (int)pow(2, 2)) printf("%s ", "control");
+ 	for (i=3; i<8; i++) {
+ 	    if (e->state & (int)pow(2, i)) {
+ 		printf("mod%d ", i-2);
+ 	    }
+ 	}
+ 	/* for the sake of completeness */
+ 	for (i=8; i<17; i++) {
+ 	    if (e->state & (int)pow(2, i)) {
+ 		printf("Button%d ", i-7);
+ 	    }
+ 	}
+     }
+     printf("\n");
      if (nbytes < 0) nbytes = 0;
***************
*** 429,430 ****
--- 459,461 ----
  {
+     int i;
      XButtonEvent *e = (XButtonEvent *) eventp;
***************
*** 435,437 ****
  	    e->state, e->button, e->same_screen ? Yes : No);
! 
      return;
--- 466,485 ----
  	    e->state, e->button, e->same_screen ? Yes : No);
!     printf("    modifier: ");
!     if (e->state) {
! 	if (e->state & (int)pow(2, 0)) printf("%s ", "shift");
! 	if (e->state & (int)pow(2, 1)) printf("%s ", "lock");
! 	if (e->state & (int)pow(2, 2)) printf("%s ", "control");
! 	for (i=3; i<8; i++) {
! 	    if (e->state & (int)pow(2, i)) {
! 		printf("mod%d ", i-2);
! 	    }
! 	}
! 	/* for the sake of completeness */
! 	for (i=8; i<17; i++) {
! 	    if (e->state & (int)pow(2, i)) {
! 		printf("Button%d ", i-7);
! 	    }
! 	}
!     }
!     printf("\n");
      return;
