Re: [hackers] [dwm] [PATCH] focusonclick

2017-01-04 Thread Markus Teich
Eric Pruitt wrote:
> I do not know much about X11 either, but try looking at the source of one of
> these patches which keeps / includes an XAllowEvents call:
> 
> - http://lists.suckless.org/dev/1212/13833.html
> - 
> https://github.com/ericpruitt/edge/blob/master/patches/dwm-00-click-to-focus.diff
> 
> The second link is just my personal variant of the first patch. Neither of
> them have bugs that prevent mouse shortcuts from being used.

Heyho,

thanks for the hint. It is not related to the XAllowEvents call I suspected in
the first place after all.

I now checked the original focusonclick[0] patch against the current git master,
6.1, 6.0 and 5.9 and the behavior is the same on all of them: MOD + Left-click +
drag to put a client into floating mode and move it does not work anymore. This
also is the case for MOD + Right-click + drag. So the patch has this regression
for quite a while now (as mentioned in the notes of your patch). It also does
not work with multiple monitors (they are still focused sloppily) which was my
original intention to fix.

Your own patch from the second link seems to fix the MOD-drag problem, so I'll
update it to also support multiple monitors (can test tonight when I have my
other monitor available again), add the switch to config.def.h and put it on the
wiki.

--Markus


0: http://dwm.suckless.org/patches/dwm-focusonclick-6.0.diff



Re: [hackers] [dwm] [PATCH] focusonclick

2017-01-04 Thread Eric Pruitt
On Wed, Jan 04, 2017 at 08:33:12PM +0100, Markus Teich wrote:
> while fixing the focusonclick patch I noticed that the latest version on the
> wiki[0] breaks some mouse-bindings. After applying the patch to the current 
> git
> master, I could not move or resize floating windows with the mouse anymore. I
> tried removing the line `XAllowEvents(dpy, ReplayPointer, CurrentTime);` and 
> it
> seems to work. I tried to understand why this call was needed in the first
> place, but could not figure it out. It would be nice if anyone with more X
> knowledge could approve that the removal of this call (as done in my attached
> version) is actually the correct solution.

I do not know much about X11 either, but try looking at the source of
one of these patches which keeps / includes an XAllowEvents call:

- http://lists.suckless.org/dev/1212/13833.html
- 
https://github.com/ericpruitt/edge/blob/master/patches/dwm-00-click-to-focus.diff

The second link is just my personal variant of the first patch. Neither
of them have bugs that prevent mouse shortcuts from being used.

Eric



[hackers] [dwm] [PATCH] focusonclick

2017-01-04 Thread Markus Teich
---


Heyho,

while fixing the focusonclick patch I noticed that the latest version on the
wiki[0] breaks some mouse-bindings. After applying the patch to the current git
master, I could not move or resize floating windows with the mouse anymore. I
tried removing the line `XAllowEvents(dpy, ReplayPointer, CurrentTime);` and it
seems to work. I tried to understand why this call was needed in the first
place, but could not figure it out. It would be nice if anyone with more X
knowledge could approve that the removal of this call (as done in my attached
version) is actually the correct solution.

0: http://dwm.suckless.org/patches/dwm-focusonclick-6.0.diff

--Markus


 config.def.h |  1 +
 dwm.c| 50 ++
 2 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/config.def.h b/config.def.h
index ab00f4c..897e852 100644
--- a/config.def.h
+++ b/config.def.h
@@ -5,6 +5,7 @@ static const unsigned int borderpx  = 1;/* border pixel 
of windows */
 static const unsigned int snap  = 32;   /* snap pixel */
 static const int showbar= 1;/* 0 means no bar */
 static const int topbar = 1;/* 0 means bottom bar */
+static const int focusonwheel   = 0;
 static const char *fonts[]  = { "monospace:size=10" };
 static const char dmenufont[]   = "monospace:size=10";
 static const char col_gray1[]   = "#22";
diff --git a/dwm.c b/dwm.c
index 7cd8d18..897e0fe 100644
--- a/dwm.c
+++ b/dwm.c
@@ -164,7 +164,6 @@ static void detachstack(Client *c);
 static Monitor *dirtomon(int dir);
 static void drawbar(Monitor *m);
 static void drawbars(void);
-static void enternotify(XEvent *e);
 static void expose(XEvent *e);
 static void focus(Client *c);
 static void focusin(XEvent *e);
@@ -182,7 +181,6 @@ static void manage(Window w, XWindowAttributes *wa);
 static void mappingnotify(XEvent *e);
 static void maprequest(XEvent *e);
 static void monocle(Monitor *m);
-static void motionnotify(XEvent *e);
 static void movemouse(const Arg *arg);
 static Client *nexttiled(Client *c);
 static void pop(Client *);
@@ -252,13 +250,11 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[ConfigureRequest] = configurerequest,
[ConfigureNotify] = configurenotify,
[DestroyNotify] = destroynotify,
-   [EnterNotify] = enternotify,
[Expose] = expose,
[FocusIn] = focusin,
[KeyPress] = keypress,
[MappingNotify] = mappingnotify,
[MapRequest] = maprequest,
-   [MotionNotify] = motionnotify,
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify
 };
@@ -427,7 +423,8 @@ buttonpress(XEvent *e)
 
click = ClkRootWin;
/* focus monitor if necessary */
-   if ((m = wintomon(ev->window)) && m != selmon) {
+   if ((m = wintomon(ev->window)) && m != selmon
+   && (focusonwheel || (ev->button != Button4 && ev->button != 
Button5))) {
unfocus(selmon->sel, 1);
selmon = m;
focus(NULL);
@@ -447,7 +444,8 @@ buttonpress(XEvent *e)
else
click = ClkWinTitle;
} else if ((c = wintoclient(ev->window))) {
-   focus(c);
+   if (focusonwheel || (ev->button != Button4 && ev->button != 
Button5))
+   focus(c);
click = ClkClientWin;
}
for (i = 0; i < LENGTH(buttons); i++)
@@ -755,25 +753,6 @@ drawbars(void)
 }
 
 void
-enternotify(XEvent *e)
-{
-   Client *c;
-   Monitor *m;
-   XCrossingEvent *ev = &e->xcrossing;
-
-   if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && 
ev->window != root)
-   return;
-   c = wintoclient(ev->window);
-   m = c ? c->mon : wintomon(ev->window);
-   if (m != selmon) {
-   unfocus(selmon->sel, 1);
-   selmon = m;
-   } else if (!c || c == selmon->sel)
-   return;
-   focus(c);
-}
-
-void
 expose(XEvent *e)
 {
Monitor *m;
@@ -945,10 +924,10 @@ grabbuttons(Client *c, int focused)
XGrabButton(dpy, 
buttons[i].button,
buttons[i].mask | 
modifiers[j],
c->win, False, 
BUTTONMASK,
-   GrabModeAsync, 
GrabModeSync, None, None);
+   GrabModeSync, 
GrabModeSync, None, None);
} else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
-   BUTTONMASK, GrabModeAsync, GrabModeSync, 
None, None);
+   BUTTONMASK, GrabModeSync, GrabModeSync, 
None, None);
}
 }
 
@@ -1123,23 +1102,6 @@ monocle(Monitor *m)
 }
 
 void
-motionnotify(XEvent *e)
-{
-   static

[hackers] [PATCH] whitespace alignment

2017-01-04 Thread Markus Teich
---
 config.def.h | 2 +-
 dwm.c| 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h
index ba9a240..a9ac303 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,7 +15,7 @@ static const char col_cyan[]= "#005577";
 static const char *colors[][3]  = {
/*   fg bg border   */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
-   [SchemeSel] =  { col_gray4, col_cyan,  col_cyan  },
+   [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
 };
 
 /* tagging */
diff --git a/dwm.c b/dwm.c
index d27cb67..4eba952 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1881,8 +1881,8 @@ updategeom(void)
}
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
if (i >= n
-   || (unique[i].x_org != m->mx || unique[i].y_org 
!= m->my
-   || unique[i].width != m->mw || 
unique[i].height != m->mh))
+   || unique[i].x_org != m->mx || 
unique[i].y_org != m->my
+   || unique[i].width != m->mw || 
unique[i].height != m->mh)
{
dirty = 1;
m->num = i;
-- 
2.10.2




[hackers] [PATCH] simplify client moving on monitor count decrease

2017-01-04 Thread Markus Teich
---
 dwm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dwm.c b/dwm.c
index 4eba952..88d49d7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1896,9 +1896,8 @@ updategeom(void)
/* less monitors available nn < n */
for (i = nn; i < n; i++) {
for (m = mons; m && m->next; m = m->next);
-   while (m->clients) {
+   while ((c = m->clients)) {
dirty = 1;
-   c = m->clients;
m->clients = c->next;
detachstack(c);
c->mon = mons;
-- 
2.10.2