void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message);
char *convert_utf8_to_ucs2(char *input, int *real_strlen);
void remove_client_from_container(xcb_connection_t *conn, Client *client, Container *container);
-void set_focus(xcb_connection_t *conn, Client *client);
+void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways);
void leave_stack_mode(xcb_connection_t *conn, Container *container);
void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
void warp_pointer_into(xcb_connection_t *conn, Client *client);
return false;
/* Set focus */
- set_focus(conn, candidate);
+ set_focus(conn, candidate, true);
return true;
}
new_row = (t_ws->rows - 1);
if (t_ws->table[new_col][new_row]->currently_focused != NULL)
- set_focus(conn, t_ws->table[new_col][new_row]->currently_focused);
+ set_focus(conn, t_ws->table[new_col][new_row]->currently_focused, true);
}
/*
render_layout(conn);
- set_focus(conn, current_client);
+ set_focus(conn, current_client, true);
}
static void move_current_container(xcb_connection_t *conn, direction_t direction) {
/* Restore focus on the new workspace */
if (CUR_CELL->currently_focused != NULL)
- set_focus(conn, CUR_CELL->currently_focused);
+ set_focus(conn, CUR_CELL->currently_focused, true);
else xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
//xcb_ungrab_server(conn);
return 1;
}
- set_focus(conn, client);
+ set_focus(conn, client, false);
return 1;
}
LOG("Click on stack_win for client %d\n", destination);
CIRCLEQ_FOREACH(client, &(stack_win->container->clients), clients)
if (c++ == destination) {
- set_focus(conn, client);
+ set_focus(conn, client, true);
return true;
}
xcb_screen_t *root_screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
/* Set focus in any case */
- set_focus(conn, client);
+ set_focus(conn, client, true);
/* Let’s see if this was on the borders (= resize). If not, we’re done */
LOG("press button on x=%d, y=%d\n", event->event_x, event->event_y);
con->currently_focused = focus_client;
/* Only if this is the active container, we need to really change focus */
if (con == CUR_CELL)
- set_focus(conn, focus_client);
+ set_focus(conn, focus_client, false);
break;
}
}
current_row = c_ws->rows-1;
if (CUR_CELL->currently_focused != NULL)
- set_focus(conn, CUR_CELL->currently_focused);
+ set_focus(conn, CUR_CELL->currently_focused, true);
}
/*
* the user the new focus situation)
*
*/
-void set_focus(xcb_connection_t *conn, Client *client) {
+void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
/* The dock window cannot be focused, but enter notifies are still handled correctly */
if (client->dock)
return;
/* Store the old client */
Client *old_client = CUR_CELL->currently_focused;
- /* TODO: check if the focus needs to be changed at all */
+ /* Check if the focus needs to be changed at all */
+ if (!set_anyways && (old_client == client)) {
+ LOG("old_client == client, not changing focus\n");
+ return;
+ }
+
/* Store current_row/current_col */
c_ws->current_row = current_row;
c_ws->current_col = current_col;