diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-08-06 11:47:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-06 11:47:00 -0400 |
commit | 639f3368e101b697aaf3715b1213ea30766ff4ed (patch) | |
tree | 67dfb7bc19eb3dd27252d8b0f493436250b4fdea /sway/tree | |
parent | Move workspace moving code out of container_move_to (diff) | |
parent | Merge pull request #2268 from emersion/server-decoration-borders (diff) | |
download | sway-639f3368e101b697aaf3715b1213ea30766ff4ed.tar.gz sway-639f3368e101b697aaf3715b1213ea30766ff4ed.tar.zst sway-639f3368e101b697aaf3715b1213ea30766ff4ed.zip |
Merge branch 'master' into workspace-move-to-output
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/layout.c | 4 | ||||
-rw-r--r-- | sway/tree/view.c | 18 | ||||
-rw-r--r-- | sway/tree/workspace.c | 11 |
3 files changed, 27 insertions, 6 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 9485e675..20815654 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -843,7 +843,7 @@ struct sway_container *container_split(struct sway_container *child, | |||
843 | } | 843 | } |
844 | if (child->type == C_WORKSPACE && child->children->length == 0) { | 844 | if (child->type == C_WORKSPACE && child->children->length == 0) { |
845 | // Special case: this just behaves like splitt | 845 | // Special case: this just behaves like splitt |
846 | child->prev_layout = child->layout; | 846 | child->prev_split_layout = child->layout; |
847 | child->layout = layout; | 847 | child->layout = layout; |
848 | return child; | 848 | return child; |
849 | } | 849 | } |
@@ -854,7 +854,7 @@ struct sway_container *container_split(struct sway_container *child, | |||
854 | 854 | ||
855 | remove_gaps(child); | 855 | remove_gaps(child); |
856 | 856 | ||
857 | cont->prev_layout = L_NONE; | 857 | cont->prev_split_layout = L_NONE; |
858 | cont->width = child->width; | 858 | cont->width = child->width; |
859 | cont->height = child->height; | 859 | cont->height = child->height; |
860 | cont->x = child->x; | 860 | cont->x = child->x; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 9465b3a1..faaa53a1 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <strings.h> | ||
3 | #include <wayland-server.h> | 4 | #include <wayland-server.h> |
4 | #include <wlr/render/wlr_renderer.h> | 5 | #include <wlr/render/wlr_renderer.h> |
5 | #include <wlr/types/wlr_buffer.h> | 6 | #include <wlr/types/wlr_buffer.h> |
@@ -456,7 +457,13 @@ static struct sway_container *select_workspace(struct sway_view *view) { | |||
456 | if (criteria->type == CT_ASSIGN_WORKSPACE) { | 457 | if (criteria->type == CT_ASSIGN_WORKSPACE) { |
457 | ws = workspace_by_name(criteria->target); | 458 | ws = workspace_by_name(criteria->target); |
458 | if (!ws) { | 459 | if (!ws) { |
459 | ws = workspace_create(NULL, criteria->target); | 460 | if (strcasecmp(criteria->target, "back_and_forth") == 0) { |
461 | if (prev_workspace_name) { | ||
462 | ws = workspace_create(NULL, prev_workspace_name); | ||
463 | } | ||
464 | } else { | ||
465 | ws = workspace_create(NULL, criteria->target); | ||
466 | } | ||
460 | } | 467 | } |
461 | break; | 468 | break; |
462 | } else { | 469 | } else { |
@@ -891,6 +898,15 @@ static bool find_by_mark_iterator(struct sway_container *con, | |||
891 | return con->type == C_VIEW && view_has_mark(con->sway_view, mark); | 898 | return con->type == C_VIEW && view_has_mark(con->sway_view, mark); |
892 | } | 899 | } |
893 | 900 | ||
901 | struct sway_view *view_find_mark(char *mark) { | ||
902 | struct sway_container *container = container_find(&root_container, | ||
903 | find_by_mark_iterator, mark); | ||
904 | if (!container) { | ||
905 | return NULL; | ||
906 | } | ||
907 | return container->sway_view; | ||
908 | } | ||
909 | |||
894 | bool view_find_and_unmark(char *mark) { | 910 | bool view_find_and_unmark(char *mark) { |
895 | struct sway_container *container = container_find(&root_container, | 911 | struct sway_container *container = container_find(&root_container, |
896 | find_by_mark_iterator, mark); | 912 | find_by_mark_iterator, mark); |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index cc225e79..3fcad631 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -59,7 +59,7 @@ struct sway_container *workspace_create(struct sway_container *output, | |||
59 | workspace->width = output->width; | 59 | workspace->width = output->width; |
60 | workspace->height = output->height; | 60 | workspace->height = output->height; |
61 | workspace->name = !name ? NULL : strdup(name); | 61 | workspace->name = !name ? NULL : strdup(name); |
62 | workspace->prev_layout = L_NONE; | 62 | workspace->prev_split_layout = L_NONE; |
63 | workspace->layout = container_get_default_layout(output); | 63 | workspace->layout = container_get_default_layout(output); |
64 | 64 | ||
65 | struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace)); | 65 | struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace)); |
@@ -250,6 +250,7 @@ struct sway_container *workspace_by_name(const char *name) { | |||
250 | current_workspace = container_parent(focus, C_WORKSPACE); | 250 | current_workspace = container_parent(focus, C_WORKSPACE); |
251 | current_output = container_parent(focus, C_OUTPUT); | 251 | current_output = container_parent(focus, C_OUTPUT); |
252 | } | 252 | } |
253 | |||
253 | if (strcmp(name, "prev") == 0) { | 254 | if (strcmp(name, "prev") == 0) { |
254 | return workspace_prev(current_workspace); | 255 | return workspace_prev(current_workspace); |
255 | } else if (strcmp(name, "prev_on_output") == 0) { | 256 | } else if (strcmp(name, "prev_on_output") == 0) { |
@@ -260,6 +261,9 @@ struct sway_container *workspace_by_name(const char *name) { | |||
260 | return workspace_output_next(current_output); | 261 | return workspace_output_next(current_output); |
261 | } else if (strcmp(name, "current") == 0) { | 262 | } else if (strcmp(name, "current") == 0) { |
262 | return current_workspace; | 263 | return current_workspace; |
264 | } else if (strcasecmp(name, "back_and_forth") == 0) { | ||
265 | return prev_workspace_name ? container_find(&root_container, | ||
266 | _workspace_by_name, (void *)prev_workspace_name) : NULL; | ||
263 | } else { | 267 | } else { |
264 | return container_find(&root_container, _workspace_by_name, | 268 | return container_find(&root_container, _workspace_by_name, |
265 | (void *)name); | 269 | (void *)name); |
@@ -364,7 +368,8 @@ struct sway_container *workspace_prev(struct sway_container *current) { | |||
364 | return workspace_prev_next_impl(current, false); | 368 | return workspace_prev_next_impl(current, false); |
365 | } | 369 | } |
366 | 370 | ||
367 | bool workspace_switch(struct sway_container *workspace) { | 371 | bool workspace_switch(struct sway_container *workspace, |
372 | bool no_auto_back_and_forth) { | ||
368 | if (!workspace) { | 373 | if (!workspace) { |
369 | return false; | 374 | return false; |
370 | } | 375 | } |
@@ -379,7 +384,7 @@ bool workspace_switch(struct sway_container *workspace) { | |||
379 | active_ws = container_parent(focus, C_WORKSPACE); | 384 | active_ws = container_parent(focus, C_WORKSPACE); |
380 | } | 385 | } |
381 | 386 | ||
382 | if (config->auto_back_and_forth | 387 | if (!no_auto_back_and_forth && config->auto_back_and_forth |
383 | && active_ws == workspace | 388 | && active_ws == workspace |
384 | && prev_workspace_name) { | 389 | && prev_workspace_name) { |
385 | struct sway_container *new_ws = workspace_by_name(prev_workspace_name); | 390 | struct sway_container *new_ws = workspace_by_name(prev_workspace_name); |