summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2010-08-03 21:47:08 +0200
committerMichael Cardell Widerkrantz <mc@hack.org>2010-08-03 21:47:08 +0200
commitbbd5a23bb898cdcce3358e4bc5bc9d826db015a6 (patch)
treea7012f6d68ef725d81c7ce4faca7d47e17c96adb
parent65b7c71a5ca01d12f260d8290f7b4e488c7d40ee (diff)
downloadmcwm-bbd5a23bb898cdcce3358e4bc5bc9d826db015a6.zip
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.
-rw-r--r--mcwm.c23
1 files 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,