sites

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

dmenu-mousesupport-motion-5.2.diff (1380B)


      1 diff --git a/dmenu.c b/dmenu.c
      2 index 48d4980..7677401 100644
      3 --- a/dmenu.c
      4 +++ b/dmenu.c
      5 @@ -641,6 +641,29 @@ buttonpress(XEvent *e)
      6  	}
      7  }
      8  
      9 +static void
     10 +motionevent(XButtonEvent *ev)
     11 +{
     12 +	struct item *it;
     13 +	int xy, ev_xy;
     14 +
     15 +	if (ev->window != win || matches == 0)
     16 +		return;
     17 +
     18 +	xy = lines > 0 ? bh : inputw + promptw + TEXTW("<");
     19 +	ev_xy = lines > 0 ? ev->y : ev->x;
     20 +	for (it = curr; it && it != next; it = it->right) {
     21 +		int wh = lines > 0 ? bh : textw_clamp(it->text, mw - xy - TEXTW(">"));
     22 +		if (ev_xy >= xy && ev_xy < (xy + wh)) {
     23 +			sel = it;
     24 +			calcoffsets();
     25 +			drawmenu();
     26 +			break;
     27 +		}
     28 +		xy += wh;
     29 +	}
     30 +}
     31 +
     32  static void
     33  paste(void)
     34  {
     35 @@ -702,6 +725,9 @@ run(void)
     36  		case ButtonPress:
     37  			buttonpress(&ev);
     38  			break;
     39 +		case MotionNotify:
     40 +			motionevent(&ev.xbutton);
     41 +			break;
     42  		case Expose:
     43  			if (ev.xexpose.count == 0)
     44  				drw_map(drw, win, 0, 0, mw, mh);
     45 @@ -800,7 +826,7 @@ setup(void)
     46  	swa.override_redirect = True;
     47  	swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
     48  	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask |
     49 -	                 ButtonPressMask;
     50 +	                 ButtonPressMask | PointerMotionMask;
     51  	win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
     52  	                    CopyFromParent, CopyFromParent, CopyFromParent,
     53  	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);