Only warp pointer once during x_push_changes()

- Introduce warp_to static variable in x.c that stores the coordinates
  to warp to as a Rect.

- Add x_set_warp_to function to set this variable.  Use in _tree_next,
  workspace_show, and con_move_to_workspace.

- In x_push_chanages, if warp_to is set, then call xcb_warp_pointer_rect
  and then reset it to NULL.

This fixes all know bugs for pointer warping for me.
This commit is contained in:
Peter Bui
2011-08-11 21:54:59 -04:00
committed by Michael Stapelberg
parent 637d2a3d62
commit 36224f86d1
6 changed files with 41 additions and 5 deletions

View File

@ -367,7 +367,9 @@ bool xcb_reply_contains_atom(xcb_get_property_reply_t *prop, xcb_atom_t atom) {
*
*/
void xcb_warp_pointer_rect(xcb_connection_t *conn, Rect *rect) {
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
rect->x + (rect->width / 2),
rect->y + (rect->height / 2));
int mid_x = rect->x + (rect->width / 2);
int mid_y = rect->y + (rect->height / 2);
LOG("warp pointer to: %d %d\n", mid_x, mid_y);
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y);
}