Implement switching focus across screens.

Modify _tree_next() so that when we reach the workspace container:

1. Find the next corresponding output (screen) using the added
get_output_next().

2. If there is another output, find the visible workspace.

3. Call workspace_show on found workspace.

4. Find the appropriate window to focus (leftmost/rightmost, etc.) using
con_descend_direction, and then focus it.

I've only tested on horizontal monitors (left/right).
This commit is contained in:
Peter Bui
2011-08-06 12:28:05 -04:00
committed by Michael Stapelberg
parent 865c193971
commit a547365a88
5 changed files with 136 additions and 2 deletions

View File

@ -143,6 +143,48 @@ Output *get_output_most(direction_t direction, Output *current) {
return candidate;
}
/*
* Gets the output which is the next one in the given direction.
*
*/
Output *get_output_next(direction_t direction, Output *current) {
Output *output, *candidate = NULL;
TAILQ_FOREACH(output, &outputs, outputs) {
if (!output->active)
continue;
if (((direction == D_UP) || (direction == D_DOWN)) &&
(current->rect.x != output->rect.x))
continue;
if (((direction == D_LEFT) || (direction == D_RIGHT)) &&
(current->rect.y != output->rect.y))
continue;
switch (direction) {
case D_UP:
if (current->rect.y < output->rect.y && (!candidate || output->rect.y < candidate->rect.y))
candidate = output;
break;
case D_DOWN:
if (current->rect.y > output->rect.y && (!candidate || output->rect.y > candidate->rect.y))
candidate = output;
break;
case D_LEFT:
if (current->rect.x > output->rect.x && (!candidate || output->rect.x > candidate->rect.x))
candidate = output;
break;
case D_RIGHT:
if (current->rect.x < output->rect.x && (!candidate || output->rect.x < candidate->rect.x))
candidate = output;
break;
}
}
return candidate;
}
/*
* Disables RandR support by creating exactly one output with the size of the
* X11 screen.