Bugfix: Warp pointer to the right window

This fixes ticket #20
This commit is contained in:
Michael Stapelberg 2009-04-11 11:36:58 +02:00
parent 3548abd48a
commit 0216e84327
1 changed files with 6 additions and 3 deletions

View File

@ -462,6 +462,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa
*/ */
void show_workspace(xcb_connection_t *conn, int workspace) { void show_workspace(xcb_connection_t *conn, int workspace) {
Client *client; Client *client;
bool need_warp = false;
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
/* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */ /* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */
Workspace *t_ws = &(workspaces[workspace-1]); Workspace *t_ws = &(workspaces[workspace-1]);
@ -491,7 +492,7 @@ void show_workspace(xcb_connection_t *conn, int workspace) {
current_col = c_ws->current_col; current_col = c_ws->current_col;
current_row = c_ws->current_row; current_row = c_ws->current_row;
if (CUR_CELL->currently_focused != NULL) if (CUR_CELL->currently_focused != NULL)
warp_pointer_into(conn, CUR_CELL->currently_focused); need_warp = true;
else { else {
Rect *dims = &(c_ws->screen->rect); Rect *dims = &(c_ws->screen->rect);
xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
@ -558,9 +559,11 @@ void show_workspace(xcb_connection_t *conn, int workspace) {
ignore_enter_notify_forall(conn, c_ws, false); ignore_enter_notify_forall(conn, c_ws, false);
/* Restore focus on the new workspace */ /* Restore focus on the new workspace */
if (CUR_CELL->currently_focused != NULL) if (CUR_CELL->currently_focused != NULL) {
set_focus(conn, CUR_CELL->currently_focused, true); set_focus(conn, CUR_CELL->currently_focused, true);
else xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); if (need_warp)
warp_pointer_into(conn, CUR_CELL->currently_focused);
} else xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
//xcb_ungrab_server(conn); //xcb_ungrab_server(conn);