From a3f144f642ec49354624a1cc06cb6ddeeb45deeb Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 28 Mar 2009 19:17:46 +0100 Subject: [PATCH] Event buttonpress: Fix bug #9 opened by Cheaterman. --- src/event.c | 18 ++++++++++++++---- src/init.c | 3 ++- src/util.c | 8 +++++--- src/wmfs.h | 1 + 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/event.c b/src/event.c index 8822ec8..36fd7f6 100644 --- a/src/event.c +++ b/src/event.c @@ -62,12 +62,22 @@ buttonpress(XButtonEvent *ev) mouse_resize(c); /* Client */ - if((c = client_gb_win(ev->window))) + if((c = client_gb_win(ev->window)) && c == sel) for(i = 0; i < conf.client.nmouse; ++i) if(ev->button == conf.client.mouse[i].button) if(conf.client.mouse[i].func) conf.client.mouse[i].func(conf.client.mouse[i].cmd); + /* If the mouse is on a client that is not selected + and you click on it. */ + if((c = client_gb_win(ev->window)) && c != sel + && ev->button == Button1) + { + client_focus(c); + if(conf.raisefocus) + client_raise(c); + } + /* Root */ if(ev->window == ROOT) for(i = 0; i < conf.root.nmouse; ++i) @@ -315,9 +325,9 @@ enternotify(XCrossingEvent *ev) Client *c; int n; - if((ev->mode != NotifyNormal - || ev->detail == NotifyInferior) - && ev->window != ROOT) + if((ev->mode != NotifyNormal)) + // || ev->detail == NotifyInferior) + // && ev->window != ROOT) return; if((c = client_gb_win(ev->window)) diff --git a/src/init.c b/src/init.c index 5f1feeb..8f2365e 100644 --- a/src/init.c +++ b/src/init.c @@ -136,10 +136,11 @@ init_root(void) XSetWindowAttributes at; at.event_mask = KeyMask | ButtonMask | MouseMask - | SubstructureRedirectMask | SubstructureNotifyMask |StructureNotifyMask; + | SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask; at.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, ROOT, CWEventMask | CWCursor, &at); + if(conf.root.background_command) uicb_spawn(conf.root.background_command); diff --git a/src/util.c b/src/util.c index acbaf30..9239e85 100644 --- a/src/util.c +++ b/src/util.c @@ -217,10 +217,12 @@ spawn(const char *format, ...) vsprintf(cmd, format, ap); va_end(ap); - if(!(sh = getenv("SHELL"))) - sh = "/bin/sh"; if(!strlen(cmd)) return; + + if(!(sh = getenv("SHELL"))) + sh = "/bin/sh"; + if(fork() == 0) { if(fork() == 0) @@ -229,7 +231,7 @@ spawn(const char *format, ...) close(ConnectionNumber(dpy)); setsid(); execl(sh, sh, "-c", cmd, (char*)NULL); - exit(EXIT_FAILURE); + exit(EXIT_SUCCESS); } exit(EXIT_SUCCESS); } diff --git a/src/wmfs.h b/src/wmfs.h index 3620896..30c79d9 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -234,6 +234,7 @@ char* alias_to_str(char *conf_choice); /* }}} */ XRectangle get_mouse_pos(void); void spawn(const char *str, ...); +Pixmap get_root_pixmap(void); void uicb_spawn(uicb_t); /* tag.c */