ignore internal containers when switching workspace

This commit is contained in:
minus 2015-08-22 22:51:45 +02:00
parent 6c1e7cdebd
commit 2f7269a3f1
3 changed files with 34 additions and 25 deletions

View file

@ -30,6 +30,9 @@ enum swayc_layouts{
struct sway_container {
wlc_handle handle;
// Internal container, e.g. scratchpad
bool internal;
enum swayc_types type;
enum swayc_layouts layout;

View file

@ -14,15 +14,26 @@ swayc_t root_container;
int min_sane_h = 60;
int min_sane_w = 100;
static swayc_t null_output;
static swayc_t *scratchpad = NULL;
void init_layout(void) {
root_container.type = C_ROOT;
root_container.layout = L_NONE;
null_output.name = "root";
root_container.children = create_list();
root_container.handle = -1;
scratchpad = new_workspace(&root_container, "__i3_scratch");
null_output.type = C_OUTPUT;
null_output.layout = L_NONE;
null_output.name = "__i3";
null_output.children = create_list();
null_output.handle = -1;
null_output.internal = true;
add_child(&root_container, &null_output);
scratchpad = new_workspace(&null_output, "__i3_scratch");
scratchpad->internal = true;
}
static int index_child(swayc_t *parent, swayc_t *child) {

View file

@ -113,20 +113,17 @@ void workspace_next() {
return;
}
}
if (root_container.children->length > 1) {
for (i = 0; i < root_container.children->length - 1; i++) {
if (root_container.children->items[i] == current_output) {
workspace_switch(((swayc_t *)root_container.children->items[i + 1])->focused);
workspace_output_next();
return;
for (i = 0; i < root_container.children->length; i++) {
if (root_container.children->items[i] == current_output) {
swayc_t *next_output = root_container.children->items[(i + 1)%root_container.children->length];
if (next_output->internal) {
next_output = root_container.children->items[(i + 2)%root_container.children->length];
}
workspace_switch(next_output->focused);
workspace_output_next();
return;
}
// If we're at the last output, then go to the first
workspace_switch(((swayc_t *)root_container.children->items[0])->focused);
workspace_output_next();
return;
} else {
workspace_switch(current_output->children->items[0]);
}
}
@ -157,20 +154,18 @@ void workspace_prev() {
return;
}
}
if (root_container.children->length > 1) {
for (i = 1; i < root_container.children->length; i++) {
if (root_container.children->items[i] == current_output) {
workspace_switch(((swayc_t *)root_container.children->items[i - 1])->focused);
workspace_output_next();
return;
int num_outputs = root_container.children->length;
for (i = 0; i < num_outputs; i++) {
if (root_container.children->items[i] == current_output) {
swayc_t *next_output = root_container.children->items[(num_outputs + i - 1)%num_outputs];
if (next_output->internal) {
next_output = root_container.children->items[(num_outputs + i - 2)%num_outputs];
}
workspace_switch(next_output->focused);
workspace_output_next();
return;
}
// If we're at the first output, then go to the last
workspace_switch(((swayc_t *)root_container.children->items[root_container.children->length-1])->focused);
workspace_output_next();
return;
} else {
workspace_switch(current_output->children->items[current_output->children->length - 1]);
}
}