commit 33d0574818216b8ea141d6b6c0131e6a872b2c6c
Author: Xarchus <[email protected]>
Date:   Thu Nov 19 18:04:38 2015 -0800

    [dmenu][PATCH] Mouse support, with multiselect
    
    - mouse support: includes all the functionality of the existing patch
      from the wiki and ...
    - in addition, Ctrl-Button1 will do what Ctrl-Return does (multisel)
    - can be applied cleanly to 4.6

diff --git a/tools.suckless.org/dmenu/patches/dmenu-4.6-mouse-support-msel.diff 
b/tools.suckless.org/dmenu/patches/dmenu-4.6-mouse-support-msel.diff
new file mode 100644
index 0000000..74490ba
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/dmenu-4.6-mouse-support-msel.diff
@@ -0,0 +1,154 @@
+diff --git a/dmenu.c b/dmenu.c
+index a07f8e3..1de62c1 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -277,6 +277,129 @@ nextrune(int inc)
+       return n;
+ }
+ 
++void
++buttonpress(XEvent *e)
++{
++      struct item *item;
++      XButtonPressedEvent *ev = &e->xbutton;
++      int xpos, ypos, wpos, hpos;
++
++      if(ev->window != win)
++              return;
++
++      /* right-click: exit */
++      if(ev->button == Button3)
++              exit(EXIT_FAILURE);
++
++      xpos = 0;
++      ypos = 0;
++      hpos = bh;
++
++      if(prompt && *prompt) {
++              wpos = promptw;
++              xpos = wpos;
++      }
++      /* input field */
++      wpos = (lines > 0 || !matches) ? mw - xpos : inputw;
++
++      /* left-click on input: clear input,
++       * NOTE: if there is no left-arrow the space for < is reserved so
++       *       add that to the input width */
++      if(ev->button == Button1 &&
++         ((lines <= 0 && ev->x >= 0 && ev->x <= xpos + wpos +
++         ((!prev || !curr->left) ? TEXTW("<") : 0)) ||
++         (lines > 0 && ev->y >= ypos && ev->y <= ypos + hpos))) {
++              insert(NULL, 0 - cursor);
++              drawmenu();
++              return;
++      }
++      /* middle-mouse click: paste selection */
++      if(ev->button == Button2) {
++              XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : 
XA_PRIMARY,
++                                utf8, utf8, win, CurrentTime);
++              drawmenu();
++              return;
++      }
++      /* scroll up */
++      if(ev->button == Button4 && prev) {
++              sel = curr = prev;
++              calcoffsets();
++              drawmenu();
++              return;
++      }
++      /* scroll down */
++      if(ev->button == Button5 && next) {
++              sel = curr = next;
++              calcoffsets();
++              drawmenu();
++              return;
++      }
++      if(ev->button != Button1)
++              return;
++      if(ev->state & ~ControlMask)
++              return;
++      if(lines > 0) {
++              /* vertical list: (ctrl-)left-click on item */
++              wpos = mw - xpos;
++              for(item = curr; item != next; item = item->right) {
++                      ypos += hpos;
++                      if(ev->y >= ypos && ev->y <= (ypos + hpos)) {
++                              puts(item->text);
++                              sel=item;
++                              if (!(ev->state & ControlMask)) {
++                                      cleanup();
++                                      exit(EXIT_SUCCESS);
++                              }
++                              if (sel) {
++                                      sel->out = 1;
++                                      drawmenu();
++                              }
++                              return;
++                      }
++              }
++      }
++      else if(matches) {
++              /* left-click on left arrow */
++              xpos += inputw;
++              wpos = TEXTW("<");
++              if(prev && curr->left) {
++                      if(ev->x >= xpos && ev->x <= xpos + wpos) {
++                              sel = curr = prev;
++                              calcoffsets();
++                              drawmenu();
++                              return;
++                      }
++              }
++              /* horizontal list: (ctrl-)left-click on item */
++              for(item = curr; item != next; item = item->right) {
++                      xpos += wpos;
++                      wpos = MIN(TEXTW(item->text), mw - xpos - TEXTW(">"));
++                      if(ev->x >= xpos && ev->x <= (xpos + wpos)) {
++                              puts(item->text);
++                              sel=item;
++                              if (!(ev->state & ControlMask)) {
++                                      cleanup();
++                                      exit(EXIT_SUCCESS);
++                              }
++                              if (sel) {
++                                      sel->out = 1;
++                                      drawmenu();
++                              }
++                              return;
++                      }
++              }
++              /* left-click on right arrow */
++              wpos = TEXTW(">");
++              xpos = mw - wpos;
++              if(next && ev->x >= xpos && ev->x <= xpos + wpos) {
++                      sel = curr = next;
++                      calcoffsets();
++                      drawmenu();
++                      return;
++              }
++      }
++}
++
+ static void
+ keypress(XKeyEvent *ev)
+ {
+@@ -502,6 +625,9 @@ run(void)
+                       if (ev.xexpose.count == 0)
+                               drw_map(drw, win, 0, 0, mw, mh);
+                       break;
++              case ButtonPress:
++                      buttonpress(&ev);
++                      break;
+               case KeyPress:
+                       keypress(&ev.xkey);
+                       break;
+@@ -589,7 +715,8 @@ setup(void)
+       /* create menu window */
+       swa.override_redirect = True;
+       swa.background_pixel = scheme[SchemeNorm].bg->pix;
+-      swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
++      swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask |
++                       ButtonPressMask;
+       win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
+                           DefaultDepth(dpy, screen), CopyFromParent,
+                           DefaultVisual(dpy, screen),
diff --git a/tools.suckless.org/dmenu/patches/mouse-support-msel.md 
b/tools.suckless.org/dmenu/patches/mouse-support-msel.md
new file mode 100644
index 0000000..01ac8c7
--- /dev/null
+++ b/tools.suckless.org/dmenu/patches/mouse-support-msel.md
@@ -0,0 +1,19 @@
+Mouse support with multisel
+===========================
+
+This provides the basic mouse support described in the 'mouse support' patch,
+but against 4.6 (32f2564dbbbf5aeafb7190a3d35066142f34448f).
+
+In addition, multisel is supported via Ctrl-leftclick.
+(i.e. Ctrl-leftclick does for mouse operation what Ctrl-Return does for
+keyboard, as described in the 'multisel' patch; however, the 'multisel' patch
+itself is no longer needed in 4.6 because its functionality has been previously
+merged in and now it's part of the master)
+
+Download
+--------
+* [dmenu-4.6-mouse-support-msel.diff](dmenu-4.6-mouse-support-msel.diff)
+
+Author
+------
+* Xarchus


Reply via email to