aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 23:34:14 -0400
committerLibravatar GitHub <noreply@github.com>2018-03-29 23:34:14 -0400
commit472e81f35d689d67cda241acafda91c688d61046 (patch)
treeb8b52173a9791e3b13a0316ab9d316a80a6adc20 /sway/commands
parentMerge pull request #1647 from acrisci/refactor-tree (diff)
parentRevert "Refactor tree" (diff)
downloadsway-472e81f35d689d67cda241acafda91c688d61046.tar.gz
sway-472e81f35d689d67cda241acafda91c688d61046.tar.zst
sway-472e81f35d689d67cda241acafda91c688d61046.zip
Merge pull request #1653 from swaywm/revert-1647-refactor-tree
Revert "Refactor tree"
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/exec_always.c4
-rw-r--r--sway/commands/focus.c9
-rw-r--r--sway/commands/kill.c4
-rw-r--r--sway/commands/layout.c20
-rw-r--r--sway/commands/output.c2
-rw-r--r--sway/commands/reload.c2
-rw-r--r--sway/commands/workspace.c14
7 files changed, 27 insertions, 28 deletions
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c
index 954950e7..61870c51 100644
--- a/sway/commands/exec_always.c
+++ b/sway/commands/exec_always.c
@@ -6,8 +6,8 @@
6#include <unistd.h> 6#include <unistd.h>
7#include "sway/commands.h" 7#include "sway/commands.h"
8#include "sway/config.h" 8#include "sway/config.h"
9#include "sway/tree/container.h" 9#include "sway/container.h"
10#include "sway/tree/workspace.h" 10#include "sway/workspace.h"
11#include "log.h" 11#include "log.h"
12#include "stringop.h" 12#include "stringop.h"
13 13
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 64f079f4..f1a8078f 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -3,11 +3,10 @@
3#include "log.h" 3#include "log.h"
4#include "sway/input/input-manager.h" 4#include "sway/input/input-manager.h"
5#include "sway/input/seat.h" 5#include "sway/input/seat.h"
6#include "sway/tree/view.h" 6#include "sway/view.h"
7#include "sway/commands.h" 7#include "sway/commands.h"
8 8
9static bool parse_movement_direction(const char *name, 9static bool parse_movement_direction(const char *name, enum movement_direction *out) {
10 enum movement_direction *out) {
11 if (strcasecmp(name, "left") == 0) { 10 if (strcasecmp(name, "left") == 0) {
12 *out = MOVE_LEFT; 11 *out = MOVE_LEFT;
13 } else if (strcasecmp(name, "right") == 0) { 12 } else if (strcasecmp(name, "right") == 0) {
@@ -32,7 +31,7 @@ static bool parse_movement_direction(const char *name,
32} 31}
33 32
34struct cmd_results *cmd_focus(int argc, char **argv) { 33struct cmd_results *cmd_focus(int argc, char **argv) {
35 struct sway_container *con = config->handler_context.current_container; 34 swayc_t *con = config->handler_context.current_container;
36 struct sway_seat *seat = config->handler_context.seat; 35 struct sway_seat *seat = config->handler_context.seat;
37 if (con->type < C_WORKSPACE) { 36 if (con->type < C_WORKSPACE) {
38 return cmd_results_new(CMD_FAILURE, "focus", 37 return cmd_results_new(CMD_FAILURE, "focus",
@@ -51,7 +50,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
51 "Expected 'focus <direction|parent|child|mode_toggle>' or 'focus output <direction|name>'"); 50 "Expected 'focus <direction|parent|child|mode_toggle>' or 'focus output <direction|name>'");
52 } 51 }
53 52
54 struct sway_container *next_focus = container_get_in_direction(con, seat, direction); 53 swayc_t *next_focus = get_swayc_in_direction(con, seat, direction);
55 if (next_focus) { 54 if (next_focus) {
56 sway_seat_set_focus(seat, next_focus); 55 sway_seat_set_focus(seat, next_focus);
57 } 56 }
diff --git a/sway/commands/kill.c b/sway/commands/kill.c
index f6774767..f408ce2a 100644
--- a/sway/commands/kill.c
+++ b/sway/commands/kill.c
@@ -2,11 +2,11 @@
2#include "log.h" 2#include "log.h"
3#include "sway/input/input-manager.h" 3#include "sway/input/input-manager.h"
4#include "sway/input/seat.h" 4#include "sway/input/seat.h"
5#include "sway/tree/view.h" 5#include "sway/view.h"
6#include "sway/commands.h" 6#include "sway/commands.h"
7 7
8struct cmd_results *cmd_kill(int argc, char **argv) { 8struct cmd_results *cmd_kill(int argc, char **argv) {
9 enum sway_container_type type = config->handler_context.current_container->type; 9 enum swayc_types type = config->handler_context.current_container->type;
10 if (type != C_VIEW && type != C_CONTAINER) { 10 if (type != C_VIEW && type != C_CONTAINER) {
11 return cmd_results_new(CMD_INVALID, NULL, 11 return cmd_results_new(CMD_INVALID, NULL,
12 "Can only kill views and containers with this command"); 12 "Can only kill views and containers with this command");
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index ebab2a48..b0fc5d66 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -1,8 +1,8 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "sway/tree/container.h" 4#include "sway/container.h"
5#include "sway/tree/layout.h" 5#include "sway/layout.h"
6#include "log.h" 6#include "log.h"
7 7
8struct cmd_results *cmd_layout(int argc, char **argv) { 8struct cmd_results *cmd_layout(int argc, char **argv) {
@@ -10,7 +10,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
10 if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { 10 if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) {
11 return error; 11 return error;
12 } 12 }
13 struct sway_container *parent = config->handler_context.current_container; 13 swayc_t *parent = config->handler_context.current_container;
14 14
15 // TODO: floating 15 // TODO: floating
16 /* 16 /*
@@ -26,10 +26,10 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
26 // TODO: stacks and tabs 26 // TODO: stacks and tabs
27 27
28 if (strcasecmp(argv[0], "default") == 0) { 28 if (strcasecmp(argv[0], "default") == 0) {
29 container_set_layout(parent, parent->prev_layout); 29 swayc_change_layout(parent, parent->prev_layout);
30 if (parent->layout == L_NONE) { 30 if (parent->layout == L_NONE) {
31 struct sway_container *output = container_parent(parent, C_OUTPUT); 31 swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT);
32 container_set_layout(parent, container_get_default_layout(output)); 32 swayc_change_layout(parent, default_layout(output));
33 } 33 }
34 } else { 34 } else {
35 if (parent->layout != L_TABBED && parent->layout != L_STACKED) { 35 if (parent->layout != L_TABBED && parent->layout != L_STACKED) {
@@ -37,15 +37,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
37 } 37 }
38 38
39 if (strcasecmp(argv[0], "splith") == 0) { 39 if (strcasecmp(argv[0], "splith") == 0) {
40 container_set_layout(parent, L_HORIZ); 40 swayc_change_layout(parent, L_HORIZ);
41 } else if (strcasecmp(argv[0], "splitv") == 0) { 41 } else if (strcasecmp(argv[0], "splitv") == 0) {
42 container_set_layout(parent, L_VERT); 42 swayc_change_layout(parent, L_VERT);
43 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { 43 } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) {
44 if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE 44 if (parent->layout == L_HORIZ && (parent->workspace_layout == L_NONE
45 || parent->workspace_layout == L_HORIZ)) { 45 || parent->workspace_layout == L_HORIZ)) {
46 container_set_layout(parent, L_VERT); 46 swayc_change_layout(parent, L_VERT);
47 } else { 47 } else {
48 container_set_layout(parent, L_HORIZ); 48 swayc_change_layout(parent, L_HORIZ);
49 } 49 }
50 } 50 }
51 } 51 }
diff --git a/sway/commands/output.c b/sway/commands/output.c
index f7e3372c..35bc8099 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -296,7 +296,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
296 char identifier[128]; 296 char identifier[128];
297 bool all = strcmp(output->name, "*") == 0; 297 bool all = strcmp(output->name, "*") == 0;
298 for (int i = 0; i < root_container.children->length; ++i) { 298 for (int i = 0; i < root_container.children->length; ++i) {
299 struct sway_container *cont = root_container.children->items[i]; 299 swayc_t *cont = root_container.children->items[i];
300 if (cont->type != C_OUTPUT) { 300 if (cont->type != C_OUTPUT) {
301 continue; 301 continue;
302 } 302 }
diff --git a/sway/commands/reload.c b/sway/commands/reload.c
index 8cef789b..d54d40db 100644
--- a/sway/commands/reload.c
+++ b/sway/commands/reload.c
@@ -1,6 +1,6 @@
1#include "sway/commands.h" 1#include "sway/commands.h"
2#include "sway/config.h" 2#include "sway/config.h"
3#include "sway/tree/layout.h" 3#include "sway/layout.h"
4 4
5struct cmd_results *cmd_reload(int argc, char **argv) { 5struct cmd_results *cmd_reload(int argc, char **argv) {
6 struct cmd_results *error = NULL; 6 struct cmd_results *error = NULL;
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 8f39e5fc..fa891398 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -4,7 +4,7 @@
4#include "sway/commands.h" 4#include "sway/commands.h"
5#include "sway/config.h" 5#include "sway/config.h"
6#include "sway/input/seat.h" 6#include "sway/input/seat.h"
7#include "sway/tree/workspace.h" 7#include "sway/workspace.h"
8#include "list.h" 8#include "list.h"
9#include "log.h" 9#include "log.h"
10#include "stringop.h" 10#include "stringop.h"
@@ -17,15 +17,15 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
17 17
18 int output_location = -1; 18 int output_location = -1;
19 19
20 struct sway_container *current_container = config->handler_context.current_container; 20 swayc_t *current_container = config->handler_context.current_container;
21 struct sway_container *old_workspace = NULL, *old_output = NULL; 21 swayc_t *old_workspace = NULL, *old_output = NULL;
22 if (current_container) { 22 if (current_container) {
23 if (current_container->type == C_WORKSPACE) { 23 if (current_container->type == C_WORKSPACE) {
24 old_workspace = current_container; 24 old_workspace = current_container;
25 } else { 25 } else {
26 old_workspace = container_parent(current_container, C_WORKSPACE); 26 old_workspace = swayc_parent_by_type(current_container, C_WORKSPACE);
27 } 27 }
28 old_output = container_parent(current_container, C_OUTPUT); 28 old_output = swayc_parent_by_type(current_container, C_OUTPUT);
29 } 29 }
30 30
31 for (int i = 0; i < argc; ++i) { 31 for (int i = 0; i < argc; ++i) {
@@ -57,7 +57,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
57 if (config->reading || !config->active) { 57 if (config->reading || !config->active) {
58 return cmd_results_new(CMD_DEFER, "workspace", NULL); 58 return cmd_results_new(CMD_DEFER, "workspace", NULL);
59 } 59 }
60 struct sway_container *ws = NULL; 60 swayc_t *ws = NULL;
61 if (strcasecmp(argv[0], "number") == 0) { 61 if (strcasecmp(argv[0], "number") == 0) {
62 if (!(ws = workspace_by_number(argv[1]))) { 62 if (!(ws = workspace_by_number(argv[1]))) {
63 char *name = join_args(argv + 1, argc - 1); 63 char *name = join_args(argv + 1, argc - 1);
@@ -92,7 +92,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
92 workspace_switch(ws); 92 workspace_switch(ws);
93 current_container = 93 current_container =
94 sway_seat_get_focus(config->handler_context.seat); 94 sway_seat_get_focus(config->handler_context.seat);
95 struct sway_container *new_output = container_parent(current_container, C_OUTPUT); 95 swayc_t *new_output = swayc_parent_by_type(current_container, C_OUTPUT);
96 96
97 if (config->mouse_warping && old_output != new_output) { 97 if (config->mouse_warping && old_output != new_output) {
98 // TODO: Warp mouse 98 // TODO: Warp mouse