dwm-focusonclick-20171030-6aa8e37.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-focusonclick-20171030-6aa8e37.diff (3819B)
---
1 diff --git a/config.def.h b/config.def.h
2 index a9ac303..1f8dc9a 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
6 static const unsigned int snap = 32; /* snap pixel */
7 static const int showbar = 1; /* 0 means no bar */
8 static const int topbar = 1; /* 0 means bottom bar */
9 +static const int focusonwheel = 0;
10 static const char *fonts[] = { "monospace:size=10" };
11 static const char dmenufont[] = "monospace:size=10";
12 static const char col_gray1[] = "#222222";
13 diff --git a/dwm.c b/dwm.c
14 index 4782343..4e9296d 100644
15 --- a/dwm.c
16 +++ b/dwm.c
17 @@ -164,7 +164,6 @@ static void detachstack(Client *c);
18 static Monitor *dirtomon(int dir);
19 static void drawbar(Monitor *m);
20 static void drawbars(void);
21 -static void enternotify(XEvent *e);
22 static void expose(XEvent *e);
23 static void focus(Client *c);
24 static void focusin(XEvent *e);
25 @@ -182,7 +181,6 @@ static void manage(Window w, XWindowAttributes *wa);
26 static void mappingnotify(XEvent *e);
27 static void maprequest(XEvent *e);
28 static void monocle(Monitor *m);
29 -static void motionnotify(XEvent *e);
30 static void movemouse(const Arg *arg);
31 static Client *nexttiled(Client *c);
32 static void pop(Client *);
33 @@ -250,13 +248,11 @@ static void (*handler[LASTEvent]) (XEvent *) = {
34 [ConfigureRequest] = configurerequest,
35 [ConfigureNotify] = configurenotify,
36 [DestroyNotify] = destroynotify,
37 - [EnterNotify] = enternotify,
38 [Expose] = expose,
39 [FocusIn] = focusin,
40 [KeyPress] = keypress,
41 [MappingNotify] = mappingnotify,
42 [MapRequest] = maprequest,
43 - [MotionNotify] = motionnotify,
44 [PropertyNotify] = propertynotify,
45 [UnmapNotify] = unmapnotify
46 };
47 @@ -425,7 +421,8 @@ buttonpress(XEvent *e)
48
49 click = ClkRootWin;
50 /* focus monitor if necessary */
51 - if ((m = wintomon(ev->window)) && m != selmon) {
52 + if ((m = wintomon(ev->window)) && m != selmon
53 + && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) {
54 unfocus(selmon->sel, 1);
55 selmon = m;
56 focus(NULL);
57 @@ -445,10 +442,10 @@ buttonpress(XEvent *e)
58 else
59 click = ClkWinTitle;
60 } else if ((c = wintoclient(ev->window))) {
61 - focus(c);
62 - restack(selmon);
63 - XAllowEvents(dpy, ReplayPointer, CurrentTime);
64 - click = ClkClientWin;
65 + if (focusonwheel || (ev->button != Button4 && ev->button != Button5))
66 + focus(c);
67 + XAllowEvents(dpy, ReplayPointer, CurrentTime);
68 + click = ClkClientWin;
69 }
70 for (i = 0; i < LENGTH(buttons); i++)
71 if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
72 @@ -753,25 +750,6 @@ drawbars(void)
73 }
74
75 void
76 -enternotify(XEvent *e)
77 -{
78 - Client *c;
79 - Monitor *m;
80 - XCrossingEvent *ev = &e->xcrossing;
81 -
82 - if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
83 - return;
84 - c = wintoclient(ev->window);
85 - m = c ? c->mon : wintomon(ev->window);
86 - if (m != selmon) {
87 - unfocus(selmon->sel, 1);
88 - selmon = m;
89 - } else if (!c || c == selmon->sel)
90 - return;
91 - focus(c);
92 -}
93 -
94 -void
95 expose(XEvent *e)
96 {
97 Monitor *m;
98 @@ -943,7 +921,7 @@ grabbuttons(Client *c, int focused)
99 XGrabButton(dpy, buttons[i].button,
100 buttons[i].mask | modifiers[j],
101 c->win, False, BUTTONMASK,
102 - GrabModeAsync, GrabModeSync, None, None);
103 + GrabModeSync, GrabModeSync, None, None);
104 }
105 }
106
107 @@ -1118,23 +1096,6 @@ monocle(Monitor *m)
108 }
109
110 void
111 -motionnotify(XEvent *e)
112 -{
113 - static Monitor *mon = NULL;
114 - Monitor *m;
115 - XMotionEvent *ev = &e->xmotion;
116 -
117 - if (ev->window != root)
118 - return;
119 - if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
120 - unfocus(selmon->sel, 1);
121 - selmon = m;
122 - focus(NULL);
123 - }
124 - mon = m;
125 -}
126 -
127 -void
128 movemouse(const Arg *arg)
129 {
130 int x, y, ocx, ocy, nx, ny;