diff options
author | MC <mc@brain.hack.org> | 2010-07-17 15:38:13 +0200 |
---|---|---|
committer | Michael Cardell Widerkrantz <mc@hack.org> | 2010-07-17 15:38:13 +0200 |
commit | 3b2183d7b97c72481d0ac2ad36b3d80fb17d3672 (patch) | |
tree | b3cf0ef958ddc2963e2a1c9990b96ec941ac03e1 /mcwm.c | |
parent | 925e0182d9476a0f1660446dc5663f38ff902e8e (diff) | |
download | mcwm-3b2183d7b97c72481d0ac2ad36b3d80fb17d3672.zip |
If we resize a window and the pointer just happens to be on top of
another window when we ungrab the pointer we get an EnterNotify to
that window and change focus. This is not what we want.
To get around this, we warp the pointer to the middle of the focused
window (that is, the window we just resize) just before ungrabbing.
Diffstat (limited to 'mcwm.c')
-rw-r--r-- | mcwm.c | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -1901,7 +1901,6 @@ void events(void) { xcb_generic_event_t *ev; xcb_drawable_t win; - xcb_get_geometry_reply_t *geom; int mode = 0; /* Internal mode. */ uint16_t mode_x; uint16_t mode_y; @@ -1971,7 +1970,8 @@ void events(void) case XCB_BUTTON_PRESS: { xcb_button_press_event_t *e; - + xcb_get_geometry_reply_t *geom; + e = ( xcb_button_press_event_t *) ev; PDEBUG("Button %d pressed in window %ld, subwindow %d " "coordinates (%d,%d)\n", @@ -2111,21 +2111,35 @@ void events(void) if (0 != mode) { - xcb_button_release_event_t *e = - (xcb_button_release_event_t *)ev; - - /* We're finished moving or resizing. */ + xcb_get_geometry_reply_t *geom; + int x = 0; + int y = 0; + + /* We're finished moving or resizing. + * + * We will get an EnterNotify and focus another window + * if the pointer just happens to be on top of another + * window when we ungrab the pointer, so we have to + * warp the pointer before to prevent this. + */ + geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), + NULL); + if (NULL != geom) + { + /* Move to middle of window. */ + x = geom->width / 2; + y = geom->height / 2; + free(geom); + } + xcb_warp_pointer(conn, XCB_NONE, focuswin->id, 0, 0, 0, 0, + x, y); + xcb_ungrab_pointer(conn, XCB_CURRENT_TIME); xcb_flush(conn); /* Important! */ mode = 0; - free(geom); - - setfocus(findclient(e->event)); - PDEBUG("mode now = %d\n", mode); - } break; |