Introduction
Introduction Statistics Contact Development Disclaimer Help
dmenu-mousesupporthoverbgcol-5.0.diff - sites - public wiki contents of suckles…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dmenu-mousesupporthoverbgcol-5.0.diff (4278B)
---
1 Only in .: config.h
2 diff -up ../dmenu-5.0/dmenu.c ./dmenu.c
3 --- ../dmenu-5.0/dmenu.c Wed Sep 2 18:37:07 2020
4 +++ ./dmenu.c Wed Nov 4 15:25:27 2020
5 @@ -501,6 +501,156 @@ draw:
6 }
7
8 static void
9 +buttonpress(XEvent *e)
10 +{
11 + struct item *item;
12 + XButtonPressedEvent *ev = &e->xbutton;
13 + int x = 0, y = 0, h = bh, w;
14 +
15 + if (ev->window != win)
16 + return;
17 +
18 + /* right-click: exit */
19 + if (ev->button == Button3)
20 + exit(1);
21 +
22 + if (prompt && *prompt)
23 + x += promptw;
24 +
25 + /* input field */
26 + w = (lines > 0 || !matches) ? mw - x : inputw;
27 +
28 + /* left-click on input: clear input,
29 + * NOTE: if there is no left-arrow the space for < is reserved …
30 + * add that to the input width */
31 + if (ev->button == Button1 &&
32 + ((lines <= 0 && ev->x >= 0 && ev->x <= x + w +
33 + ((!prev || !curr->left) ? TEXTW("<") : 0)) ||
34 + (lines > 0 && ev->y >= y && ev->y <= y + h))) {
35 + insert(NULL, -cursor);
36 + drawmenu();
37 + return;
38 + }
39 + /* middle-mouse click: paste selection */
40 + if (ev->button == Button2) {
41 + XConvertSelection(dpy, (ev->state & ShiftMask) ? clip :…
42 + utf8, utf8, win, CurrentTime);
43 + drawmenu();
44 + return;
45 + }
46 + /* scroll up */
47 + if (ev->button == Button4 && prev) {
48 + sel = curr = prev;
49 + calcoffsets();
50 + drawmenu();
51 + return;
52 + }
53 + /* scroll down */
54 + if (ev->button == Button5 && next) {
55 + sel = curr = next;
56 + calcoffsets();
57 + drawmenu();
58 + return;
59 + }
60 + if (ev->button != Button1)
61 + return;
62 + /* disabled below, needs to be fixed */
63 + /*
64 + if (ev->state & ~ControlMask)
65 + return;
66 + */
67 + if (lines > 0) {
68 + /* vertical list: (ctrl)left-click on item */
69 + w = mw - x;
70 + for (item = curr; item != next; item = item->right) {
71 + y += h;
72 + if (ev->y >= y && ev->y <= (y + h)) {
73 + puts(item->text);
74 + if (!(ev->state & ControlMask))
75 + exit(0);
76 + sel = item;
77 + if (sel) {
78 + sel->out = 1;
79 + drawmenu();
80 + }
81 + return;
82 + }
83 + }
84 + } else if (matches) {
85 + /* left-click on left arrow */
86 + x += inputw;
87 + w = TEXTW("<");
88 + if (prev && curr->left) {
89 + if (ev->x >= x && ev->x <= x + w) {
90 + sel = curr = prev;
91 + calcoffsets();
92 + drawmenu();
93 + return;
94 + }
95 + }
96 + /* horizontal list: (ctrl)left-click on item */
97 + for (item = curr; item != next; item = item->right) {
98 + x += w;
99 + w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
100 + if (ev->x >= x && ev->x <= x + w) {
101 + puts(item->text);
102 + if (!(ev->state & ControlMask))
103 + exit(0);
104 + sel = item;
105 + if (sel) {
106 + sel->out = 1;
107 + drawmenu();
108 + }
109 + return;
110 + }
111 + }
112 + /* left-click on right arrow */
113 + w = TEXTW(">");
114 + x = mw - w;
115 + if (next && ev->x >= x && ev->x <= x + w) {
116 + sel = curr = next;
117 + calcoffsets();
118 + drawmenu();
119 + return;
120 + }
121 + }
122 +}
123 +
124 +static void
125 +mousemove(XEvent *e)
126 +{
127 + struct item *item;
128 + XPointerMovedEvent *ev = &e->xmotion;
129 + int x = 0, y = 0, h = bh, w;
130 +
131 + if (lines > 0) {
132 + w = mw - x;
133 + for (item = curr; item != next; item = item->right) {
134 + y += h;
135 + if (ev->y >= y && ev->y <= (y + h)) {
136 + sel = item;
137 + calcoffsets();
138 + drawmenu();
139 + return;
140 + }
141 + }
142 + } else if (matches) {
143 + x += inputw;
144 + w = TEXTW("<");
145 + for (item = curr; item != next; item = item->right) {
146 + x += w;
147 + w = MIN(TEXTW(item->text), mw - x - TEXTW(">"));
148 + if (ev->x >= x && ev->x <= x + w) {
149 + sel = item;
150 + calcoffsets();
151 + drawmenu();
152 + return;
153 + }
154 + }
155 + }
156 +}
157 +
158 +static void
159 paste(void)
160 {
161 char *p, *q;
162 @@ -561,6 +711,12 @@ run(void)
163 break;
164 cleanup();
165 exit(1);
166 + case ButtonPress:
167 + buttonpress(&ev);
168 + break;
169 + case MotionNotify:
170 + mousemove(&ev);
171 + break;
172 case Expose:
173 if (ev.xexpose.count == 0)
174 drw_map(drw, win, 0, 0, mw, mh);
175 @@ -658,7 +814,8 @@ setup(void)
176 /* create menu window */
177 swa.override_redirect = True;
178 swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
179 - swa.event_mask = ExposureMask | KeyPressMask | VisibilityChange…
180 + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChange…
181 + ButtonPressMask | PointerMotionMask;
182 win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
183 CopyFromParent, CopyFromParent, CopyFromPar…
184 CWOverrideRedirect | CWBackPixel | CWEventM…
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.