mirror of
https://github.com/swaywm/sway.git
synced 2026-04-28 06:46:26 -04:00
ignore internal containers when switching workspace
This commit is contained in:
parent
6c1e7cdebd
commit
2f7269a3f1
3 changed files with 34 additions and 25 deletions
|
|
@ -30,6 +30,9 @@ enum swayc_layouts{
|
||||||
struct sway_container {
|
struct sway_container {
|
||||||
wlc_handle handle;
|
wlc_handle handle;
|
||||||
|
|
||||||
|
// Internal container, e.g. scratchpad
|
||||||
|
bool internal;
|
||||||
|
|
||||||
enum swayc_types type;
|
enum swayc_types type;
|
||||||
enum swayc_layouts layout;
|
enum swayc_layouts layout;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,26 @@ swayc_t root_container;
|
||||||
int min_sane_h = 60;
|
int min_sane_h = 60;
|
||||||
int min_sane_w = 100;
|
int min_sane_w = 100;
|
||||||
|
|
||||||
|
static swayc_t null_output;
|
||||||
static swayc_t *scratchpad = NULL;
|
static swayc_t *scratchpad = NULL;
|
||||||
|
|
||||||
void init_layout(void) {
|
void init_layout(void) {
|
||||||
root_container.type = C_ROOT;
|
root_container.type = C_ROOT;
|
||||||
root_container.layout = L_NONE;
|
root_container.layout = L_NONE;
|
||||||
|
null_output.name = "root";
|
||||||
root_container.children = create_list();
|
root_container.children = create_list();
|
||||||
root_container.handle = -1;
|
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) {
|
static int index_child(swayc_t *parent, swayc_t *child) {
|
||||||
|
|
|
||||||
|
|
@ -113,20 +113,17 @@ void workspace_next() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root_container.children->length > 1) {
|
|
||||||
for (i = 0; i < root_container.children->length - 1; i++) {
|
for (i = 0; i < root_container.children->length; i++) {
|
||||||
if (root_container.children->items[i] == current_output) {
|
if (root_container.children->items[i] == current_output) {
|
||||||
workspace_switch(((swayc_t *)root_container.children->items[i + 1])->focused);
|
swayc_t *next_output = root_container.children->items[(i + 1)%root_container.children->length];
|
||||||
workspace_output_next();
|
if (next_output->internal) {
|
||||||
return;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root_container.children->length > 1) {
|
|
||||||
for (i = 1; i < root_container.children->length; i++) {
|
int num_outputs = root_container.children->length;
|
||||||
if (root_container.children->items[i] == current_output) {
|
for (i = 0; i < num_outputs; i++) {
|
||||||
workspace_switch(((swayc_t *)root_container.children->items[i - 1])->focused);
|
if (root_container.children->items[i] == current_output) {
|
||||||
workspace_output_next();
|
swayc_t *next_output = root_container.children->items[(num_outputs + i - 1)%num_outputs];
|
||||||
return;
|
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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue