From bbd5a23bb898cdcce3358e4bc5bc9d826db015a6 Mon Sep 17 00:00:00 2001 From: Michael Cardell Widerkrantz <mc@hack.org> Date: Tue, 3 Aug 2010 21:47:08 +0200 Subject: [PATCH] If we don't have a focused window at the end of a resize or move, remember to ungrab the pointer and reset the mode! We *do* need EnterNotify events with mode Ungrab! Users might do strange things, like not letting go of a mouse button or a grabbed key until they have entered a window, and we still want to change focus if they do. --- mcwm.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mcwm.c b/mcwm.c index 70a5924..6faac0e 100644 --- a/mcwm.c +++ b/mcwm.c @@ -1264,6 +1264,8 @@ void setfocus(struct client *client) */ if (NULL == client) { + PDEBUG("setfocus: client was NULL!\n"); + focuswin = NULL; xcb_set_input_focus(conn, XCB_NONE, XCB_INPUT_FOCUS_POINTER_ROOT, @@ -2544,11 +2546,16 @@ void events(void) if (NULL == focuswin) { /* - * Something's seriously wrong. We don't seem to - * have a focused window! + * We don't seem to have a focused window! Just + * ungrab and reset the mode. */ PDEBUG("No focused window when finished moving or " "resizing!"); + + xcb_ungrab_pointer(conn, XCB_CURRENT_TIME); + xcb_flush(conn); /* Important! */ + + mode = 0; break; } @@ -2629,13 +2636,19 @@ void events(void) /* * If this isn't a normal enter notify, don't bother. * + * We also need ungrab events, since these will be + * generated on button and key grabs and if the user for + * some reason presses a button on the root and then moves + * the pointer to our window and releases the button, we + * get an Ungrab EnterNotify. + * * The other cases means the pointer is grabbed and that * either means someone is using it for menu selections or * that we're moving or resizing. We don't want to change - * focus in these cases. - * + * focus in those cases. */ - if (e->mode == XCB_NOTIFY_MODE_NORMAL) + if (e->mode == XCB_NOTIFY_MODE_NORMAL + || e->mode == XCB_NOTIFY_MODE_UNGRAB) { /* * If we're entering the same window we focus now, -- GitLab