-
- if (c_ws->screen != t_ws->screen) {
- /* We need to switch to the other screen first */
- LOG("moving over to other screen.\n");
-
- /* Store the old client */
- Client *old_client = CUR_CELL->currently_focused;
-
- c_ws = &(workspaces[t_ws->screen->current_workspace]);
- current_col = c_ws->current_col;
- current_row = c_ws->current_row;
- if (CUR_CELL->currently_focused != NULL)
- need_warp = true;
- else {
- Rect *dims = &(c_ws->screen->rect);
- xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0,
- dims->x + (dims->width / 2), dims->y + (dims->height / 2));
- }
-
- /* Re-decorate the old client, it’s not focused anymore */
- if ((old_client != NULL) && !old_client->dock)
- redecorate_window(conn, old_client);
- else xcb_flush(conn);
- }
-
- /* Check if we need to change something or if we’re already there */
- if (c_ws->screen->current_workspace == (workspace-1)) {
- if (CUR_CELL->currently_focused != NULL) {
- set_focus(conn, CUR_CELL->currently_focused, true);
- if (need_warp) {
- warp_pointer_into(conn, CUR_CELL->currently_focused);
- xcb_flush(conn);
- }
- }
- return;
- }
-
- t_ws->screen->current_workspace = workspace-1;
-
- /* Unmap all clients of the current workspace */
- unmap_workspace(conn, c_ws);
-
- c_ws = &workspaces[workspace-1];
- current_row = c_ws->current_row;
- current_col = c_ws->current_col;
- LOG("new current row = %d, current col = %d\n", current_row, current_col);
-
- ignore_enter_notify_forall(conn, c_ws, true);
-
- /* Map all clients on the new workspace */
- FOR_TABLE(c_ws)
- CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients)
- xcb_map_window(conn, client->frame);
-
- /* Map all stack windows, if any */
- struct Stack_Window *stack_win;
- SLIST_FOREACH(stack_win, &stack_wins, stack_windows)
- if (stack_win->container->workspace == c_ws)
- xcb_map_window(conn, stack_win->window);
-
- ignore_enter_notify_forall(conn, c_ws, false);
-
- /* Restore focus on the new workspace */
- if (CUR_CELL->currently_focused != NULL) {
- set_focus(conn, CUR_CELL->currently_focused, true);
- if (need_warp) {
- warp_pointer_into(conn, CUR_CELL->currently_focused);
- xcb_flush(conn);
- }
- } else xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
-
- render_layout(conn);
-}
-
-/*
- * Checks if the given window class and title match the given client
- * Window title is passed as "normal" string and as UCS-2 converted string for
- * matching _NET_WM_NAME capable clients as well as those using legacy hints.
- *
- */
-static bool client_matches_class_name(Client *client, char *to_class, char *to_title,
- char *to_title_ucs, int to_title_ucs_len) {
- /* Check if the given class is part of the window class */
- if (strcasestr(client->window_class, to_class) == NULL)
- return false;
-
- /* If no title was given, we’re done */
- if (to_title == NULL)
- return true;
-
- if (client->name_len > -1) {
- /* UCS-2 converted window titles */
- if (memmem(client->name, (client->name_len * 2), to_title_ucs, (to_title_ucs_len * 2)) == NULL)
- return false;
- } else {
- /* Legacy hints */
- if (strcasestr(client->name, to_title) == NULL)
- return false;
- }
-
- return true;