]> Pileus Git - wmpus/commitdiff
Resend mouse events instead of toggling grabs
authorAndy Spencer <andy753421@gmail.com>
Sun, 3 Jun 2012 04:00:17 +0000 (04:00 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 3 Jun 2012 05:58:33 +0000 (05:58 +0000)
sys-x11.c
wm-wmii.c

index a947e196747bf95ad765954e87126b3e04226611..9775cafcbc9df1f28193a9e27c6224a0095a3490 100644 (file)
--- a/sys-x11.c
+++ b/sys-x11.c
@@ -313,15 +313,8 @@ static void process_event(int type, XEvent *xe, win_t *root)
                if (wm_handle_event(win, xb2ev(xe->xbutton.button), mod, ptr))
                        XGrabPointer(dpy, xe->xbutton.root, True, PointerMotionMask|ButtonReleaseMask,
                                        GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
                if (wm_handle_event(win, xb2ev(xe->xbutton.button), mod, ptr))
                        XGrabPointer(dpy, xe->xbutton.root, True, PointerMotionMask|ButtonReleaseMask,
                                        GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
-               else {
-                       printf("resending event\n");
-                       XSendEvent(win->sys->dpy, xe->xbutton.window,    True,  NoEventMask, xe);
-                       XSendEvent(win->sys->dpy, xe->xbutton.window,    False, NoEventMask, xe);
-                       XSendEvent(win->sys->dpy, xe->xbutton.root,      True,  NoEventMask, xe);
-                       XSendEvent(win->sys->dpy, xe->xbutton.root,      False, NoEventMask, xe);
-                       XSendEvent(win->sys->dpy, xe->xbutton.subwindow, True,  NoEventMask, xe);
-                       XSendEvent(win->sys->dpy, xe->xbutton.subwindow, False, NoEventMask, xe);
-               }
+               else
+                       XAllowEvents(win->sys->dpy, ReplayPointer, CurrentTime);
        }
        else if (type == ButtonRelease) {
                XUngrabPointer(dpy, CurrentTime);
        }
        else if (type == ButtonRelease) {
                XUngrabPointer(dpy, CurrentTime);
@@ -332,7 +325,7 @@ static void process_event(int type, XEvent *xe, win_t *root)
                wm_handle_ptr(win, ptr);
        }
        else if (type == EnterNotify || type == LeaveNotify) {
                wm_handle_ptr(win, ptr);
        }
        else if (type == EnterNotify || type == LeaveNotify) {
-               printf("enter: %d\n", type);
+               printf("%s: %d\n", type==EnterNotify?"enter":"leave", type);
                event_t ev = EnterNotify ? EV_ENTER : EV_LEAVE;
                if ((win = win_find(dpy,xe->xcrossing.window,0)))
                        wm_handle_event(win, ev, MOD(), PTR());
                event_t ev = EnterNotify ? EV_ENTER : EV_LEAVE;
                if ((win = win_find(dpy,xe->xcrossing.window,0)))
                        wm_handle_event(win, ev, MOD(), PTR());
@@ -503,7 +496,7 @@ void sys_watch(win_t *win, event_t ev, mod_t mod)
        if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7)
                XGrabButton(win->sys->dpy, ev2xb(ev), mod2x(mod), win->sys->xid, False,
                                mod.up ? ButtonReleaseMask : ButtonPressMask,
        if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7)
                XGrabButton(win->sys->dpy, ev2xb(ev), mod2x(mod), win->sys->xid, False,
                                mod.up ? ButtonReleaseMask : ButtonPressMask,
-                               GrabModeAsync, GrabModeAsync, None, None);
+                               GrabModeSync, GrabModeAsync, None, None);
        else if (ev == EV_ENTER)
                XSelectInput(win->sys->dpy, win->sys->xid, EnterWindowMask|mask);
        else if (ev == EV_LEAVE)
        else if (ev == EV_ENTER)
                XSelectInput(win->sys->dpy, win->sys->xid, EnterWindowMask|mask);
        else if (ev == EV_LEAVE)
index 82fc223a4c8e9e6fe5ba7980460f6e3a6ae0ad86..0d842295e56a639af0afa49f802cd0e09cd2efde 100644 (file)
--- a/wm-wmii.c
+++ b/wm-wmii.c
@@ -212,16 +212,6 @@ static void set_focus(win_t *win)
                return;
        }
 
                return;
        }
 
-       /* - Only grab mouse button on unfocused window,
-        *   this prevents stealing all mouse clicks from client windows,
-        * - A better way may be to re-send mouse clicks to client windows
-        *   using the return value from wm_handle_key */
-       for (int i = EV_MOUSE1; i < EV_MOUSE7; i++) {
-               if (wm_focus)
-                       sys_watch(wm_focus, i, MOD());
-               sys_unwatch(win, i, MOD());
-       }
-
        dpy_t *dpy; col_t *col; row_t *row; flt_t *flt;
        switch (search(wm_tag, win, &dpy, &col, &row, &flt)) {
        case TILING:
        dpy_t *dpy; col_t *col; row_t *row; flt_t *flt;
        switch (search(wm_tag, win, &dpy, &col, &row, &flt)) {
        case TILING:
@@ -723,10 +713,10 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr)
        //      mod.shift ? 's' : '-',
        //      mod.win   ? 'w' : '-');
 
        //      mod.shift ? 's' : '-',
        //      mod.win   ? 'w' : '-');
 
-       /* Mouse movement */
-       if (ev == EV_MOUSE1)
-               raise_float(win);
+       /* Mouse events */
        if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7) {
        if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7) {
+               if (ev == EV_MOUSE1 && !mod.MODKEY && !mod.up)
+                       return raise_float(win),         0;
                if (ev == EV_MOUSE1 && mod.MODKEY && !mod.up)
                        return set_move(win,ptr,MOVE),   1;
                if (ev == EV_MOUSE3 && mod.MODKEY && !mod.up)
                if (ev == EV_MOUSE1 && mod.MODKEY && !mod.up)
                        return set_move(win,ptr,MOVE),   1;
                if (ev == EV_MOUSE3 && mod.MODKEY && !mod.up)
@@ -812,9 +802,6 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr)
        if (ev == EV_ENTER && win->state != ST_SHADE)
                return set_focus(win), 1;
 
        if (ev == EV_ENTER && win->state != ST_SHADE)
                return set_focus(win), 1;
 
-       if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7)
-               return set_focus(win), 0;
-
        /* Reset focus after after focus change,
         * not sure what is causing the focus change in the first place
         * but preventing that would be a better solution */
        /* Reset focus after after focus change,
         * not sure what is causing the focus change in the first place
         * but preventing that would be a better solution */
@@ -913,7 +900,7 @@ void wm_init(win_t *root)
        wm->tag     = tag_new(wm->screens, 1);
        wm->tags    = list_insert(NULL, wm->tag);
 
        wm->tag     = tag_new(wm->screens, 1);
        wm->tags    = list_insert(NULL, wm->tag);
 
-       event_t ev_e[] = {EV_ENTER, EV_FOCUS};
+       event_t ev_e[] = {EV_ENTER, EV_FOCUS, EV_MOUSE1};
        event_t ev_s[] = {'h', 'j', 'k', 'l', 'c', 'q', ' ',
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        event_t ev_m[] = {'h', 'j', 'k', 'l', 'd', 's', 'm', 't', ' ',
        event_t ev_s[] = {'h', 'j', 'k', 'l', 'c', 'q', ' ',
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        event_t ev_m[] = {'h', 'j', 'k', 'l', 'd', 's', 'm', 't', ' ',