Implement a command to travel the focusstack. This can be used like a jumpback.

However, it is a bit more flexible obviously. You can specify the
offset of the window you want to go to, to implement workflows like
the following:
 * Jump to mutt
 * Jump to irssi
 * Jump back ("focus 2" would be the command)
This commit is contained in:
Michael Stapelberg
2009-05-05 17:25:56 +02:00
parent 56d637a665
commit 3a2b546c9e
3 changed files with 71 additions and 32 deletions

View File

@ -648,10 +648,11 @@ static void jump_to_window(xcb_connection_t *conn, const char *arguments) {
CIRCLEQ_FOREACH(client, &(con->clients), clients) {
LOG("Checking client with class=%s, name=%s\n", client->window_class, client->name);
if (client_matches_class_name(client, to_class, to_title, to_title_ucs, to_title_ucs_len)) {
set_focus(conn, client);
goto done;
}
if (!client_matches_class_name(client, to_class, to_title, to_title_ucs, to_title_ucs_len))
continue;
set_focus(conn, client, true);
goto done;
}
}
}
@ -695,7 +696,37 @@ static void jump_to_container(xcb_connection_t *conn, const char *arguments) {
LOG("Jumping to col %d, row %d\n", col, row);
if (c_ws->table[col][row]->currently_focused != NULL)
set_focus(conn, c_ws->table[col][row]->currently_focused);
set_focus(conn, c_ws->table[col][row]->currently_focused, true);
}
/*
* Travels the focus stack by the given number of times (or once, if no argument
* was specified). That is, selects the window you were in before you focused
* the current window.
*
*/
static void travel_focus_stack(xcb_connection_t *conn, const char *arguments) {
/* Start count at -1 to always skip the first element */
int times, count = -1;
Client *current;
if (sscanf(arguments, "%u", &times) != 1) {
LOG("No or invalid argument given (\"%s\"), using default of 1 times\n", arguments);
times = 1;
}
Workspace *ws = CUR_CELL->workspace;
SLIST_FOREACH(current, &(ws->focus_stack), focus_clients) {
if (++count < times) {
LOG("Skipping\n");
continue;
}
LOG("Focussing\n");
set_focus(conn, current, true);
break;
}
}
/*
@ -739,7 +770,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
return;
}
/* Is it a jump to a specified workspae,row,col? */
/* Is it a jump to a specified workspae, row, col? */
if (STARTS_WITH(command, "jump ")) {
const char *arguments = command + strlen("jump ");
if (arguments[0] == '"')
@ -748,6 +779,13 @@ void parse_command(xcb_connection_t *conn, const char *command) {
return;
}
/* Should we travel the focus stack? */
if (STARTS_WITH(command, "focus")) {
const char *arguments = command + strlen("focus");
travel_focus_stack(conn, arguments);
return;
}
/* Is it 'f' for fullscreen? */
if (command[0] == 'f') {
if (CUR_CELL->currently_focused == NULL)