summaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/border.c2
-rw-r--r--sway/commands/floating.c2
-rw-r--r--sway/commands/focus.c3
-rw-r--r--sway/commands/fullscreen.c2
-rw-r--r--sway/commands/kill.c2
-rw-r--r--sway/commands/layout.c2
-rw-r--r--sway/commands/mark.c4
-rw-r--r--sway/commands/move.c4
-rw-r--r--sway/commands/resize.c12
-rw-r--r--sway/commands/split.c6
-rw-r--r--sway/commands/unmark.c2
11 files changed, 22 insertions, 19 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c
index 0211e40c..c888622e 100644
--- a/sway/commands/border.c
+++ b/sway/commands/border.c
@@ -20,7 +20,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
20 "Expected 'border <normal|pixel|none|toggle> [<n>]"); 20 "Expected 'border <normal|pixel|none|toggle> [<n>]");
21 } 21 }
22 22
23 swayc_t *view = get_focused_view(&root_container); 23 swayc_t *view = current_container;
24 enum swayc_border_types border = view->border_type; 24 enum swayc_border_types border = view->border_type;
25 int thickness = view->border_thickness; 25 int thickness = view->border_thickness;
26 26
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index 113c8b71..ccfde532 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -13,7 +13,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
13 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) { 13 if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
14 return error; 14 return error;
15 } 15 }
16 swayc_t *view = get_focused_container(&root_container); 16 swayc_t *view = current_container;
17 bool wants_floating; 17 bool wants_floating;
18 if (strcasecmp(argv[0], "enable") == 0) { 18 if (strcasecmp(argv[0], "enable") == 0) {
19 wants_floating = true; 19 wants_floating = true;
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 12c5d02c..defaba29 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -30,6 +30,9 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
30 } 30 }
31 } 31 }
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33 } else if (argc == 0) {
34 set_focused_container(current_container);
35 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33 } else if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1))) { 36 } else if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1))) {
34 return error; 37 return error;
35 } 38 }
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index 321d6f59..bfff82f9 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -14,7 +14,7 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
14 if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_LEAST, 0))) { 14 if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_LEAST, 0))) {
15 return error; 15 return error;
16 } 16 }
17 swayc_t *container = get_focused_view(&root_container); 17 swayc_t *container = current_container;
18 if(container->type != C_VIEW){ 18 if(container->type != C_VIEW){
19 return cmd_results_new(CMD_INVALID, "fullscreen", "Only views can fullscreen"); 19 return cmd_results_new(CMD_INVALID, "fullscreen", "Only views can fullscreen");
20 } 20 }
diff --git a/sway/commands/kill.c b/sway/commands/kill.c
index 2e94fb10..742e2b86 100644
--- a/sway/commands/kill.c
+++ b/sway/commands/kill.c
@@ -6,7 +6,7 @@ struct cmd_results *cmd_kill(int argc, char **argv) {
6 if (config->reading) return cmd_results_new(CMD_FAILURE, "kill", "Can't be used in config file."); 6 if (config->reading) return cmd_results_new(CMD_FAILURE, "kill", "Can't be used in config file.");
7 if (!config->active) return cmd_results_new(CMD_FAILURE, "kill", "Can only be used when sway is running."); 7 if (!config->active) return cmd_results_new(CMD_FAILURE, "kill", "Can only be used when sway is running.");
8 8
9 swayc_t *container = get_focused_container(&root_container); 9 swayc_t *container = current_container;
10 close_views(container); 10 close_views(container);
11 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 11 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
12} 12}
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index 570cd207..40ebd590 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -16,7 +16,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
16 if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { 16 if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) {
17 return error; 17 return error;
18 } 18 }
19 swayc_t *parent = get_focused_container(&root_container); 19 swayc_t *parent = current_container;
20 if (parent->is_floating) { 20 if (parent->is_floating) {
21 return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows"); 21 return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows");
22 } 22 }
diff --git a/sway/commands/mark.c b/sway/commands/mark.c
index 68a84af7..919883b0 100644
--- a/sway/commands/mark.c
+++ b/sway/commands/mark.c
@@ -8,11 +8,11 @@
8struct cmd_results *cmd_mark(int argc, char **argv) { 8struct cmd_results *cmd_mark(int argc, char **argv) {
9 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
10 if (config->reading) return cmd_results_new(CMD_FAILURE, "mark", "Can't be used in config file."); 10 if (config->reading) return cmd_results_new(CMD_FAILURE, "mark", "Can't be used in config file.");
11 if ((error = checkarg(argc, "floating", EXPECTED_AT_LEAST, 1))) { 11 if ((error = checkarg(argc, "mark", EXPECTED_AT_LEAST, 1))) {
12 return error; 12 return error;
13 } 13 }
14 14
15 swayc_t *view = get_focused_container(&root_container); 15 swayc_t *view = current_container;
16 bool add = false; 16 bool add = false;
17 bool toggle = false; 17 bool toggle = false;
18 18
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 97e10f10..3c47cfe7 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -20,7 +20,7 @@ struct cmd_results *cmd_move(int argc, char **argv) {
20 "'move <container|window> to workspace <name>' or " 20 "'move <container|window> to workspace <name>' or "
21 "'move <container|window|workspace> to output <name|direction>' or " 21 "'move <container|window|workspace> to output <name|direction>' or "
22 "'move position mouse'"; 22 "'move position mouse'";
23 swayc_t *view = get_focused_container(&root_container); 23 swayc_t *view = current_container;
24 24
25 if (argc == 2 || (argc == 3 && strcasecmp(argv[2], "px") == 0 )) { 25 if (argc == 2 || (argc == 3 && strcasecmp(argv[2], "px") == 0 )) {
26 char *inv; 26 char *inv;
@@ -125,7 +125,7 @@ struct cmd_results *cmd_move(int argc, char **argv) {
125 if (view->type != C_CONTAINER && view->type != C_VIEW) { 125 if (view->type != C_CONTAINER && view->type != C_VIEW) {
126 return cmd_results_new(CMD_FAILURE, "move scratchpad", "Can only move containers and views."); 126 return cmd_results_new(CMD_FAILURE, "move scratchpad", "Can only move containers and views.");
127 } 127 }
128 swayc_t *view = get_focused_container(&root_container); 128 swayc_t *view = current_container;
129 int i; 129 int i;
130 for (i = 0; i < scratchpad->length; i++) { 130 for (i = 0; i < scratchpad->length; i++) {
131 if (scratchpad->items[i] == view) { 131 if (scratchpad->items[i] == view) {
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 61af080c..ef52bb07 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -19,7 +19,7 @@ enum resize_dim_types {
19}; 19};
20 20
21static bool set_size_floating(int new_dimension, bool use_width) { 21static bool set_size_floating(int new_dimension, bool use_width) {
22 swayc_t *view = get_focused_float(swayc_active_workspace()); 22 swayc_t *view = current_container;
23 if (view) { 23 if (view) {
24 if (use_width) { 24 if (use_width) {
25 int current_width = view->width; 25 int current_width = view->width;
@@ -50,7 +50,7 @@ static bool set_size_floating(int new_dimension, bool use_width) {
50} 50}
51 51
52static bool resize_floating(int amount, bool use_width) { 52static bool resize_floating(int amount, bool use_width) {
53 swayc_t *view = get_focused_float(swayc_active_workspace()); 53 swayc_t *view = current_container;
54 54
55 if (view) { 55 if (view) {
56 if (use_width) { 56 if (use_width) {
@@ -64,7 +64,7 @@ static bool resize_floating(int amount, bool use_width) {
64} 64}
65 65
66static bool resize_tiled(int amount, bool use_width) { 66static bool resize_tiled(int amount, bool use_width) {
67 swayc_t *container = get_focused_view(swayc_active_workspace()); 67 swayc_t *container = current_container;
68 swayc_t *parent = container->parent; 68 swayc_t *parent = container->parent;
69 int idx_focused = 0; 69 int idx_focused = 0;
70 bool use_major = false; 70 bool use_major = false;
@@ -199,7 +199,7 @@ static bool resize_tiled(int amount, bool use_width) {
199 199
200static bool set_size_tiled(int amount, bool use_width) { 200static bool set_size_tiled(int amount, bool use_width) {
201 int desired; 201 int desired;
202 swayc_t *focused = get_focused_view(swayc_active_workspace()); 202 swayc_t *focused = current_container;
203 203
204 if (use_width) { 204 if (use_width) {
205 desired = amount - focused->width; 205 desired = amount - focused->width;
@@ -211,7 +211,7 @@ static bool set_size_tiled(int amount, bool use_width) {
211} 211}
212 212
213static bool set_size(int dimension, bool use_width) { 213static bool set_size(int dimension, bool use_width) {
214 swayc_t *focused = get_focused_view_include_floating(swayc_active_workspace()); 214 swayc_t *focused = current_container;
215 215
216 if (focused) { 216 if (focused) {
217 if (focused->is_floating) { 217 if (focused->is_floating) {
@@ -225,7 +225,7 @@ static bool set_size(int dimension, bool use_width) {
225} 225}
226 226
227static bool resize(int dimension, bool use_width, enum resize_dim_types dim_type) { 227static bool resize(int dimension, bool use_width, enum resize_dim_types dim_type) {
228 swayc_t *focused = get_focused_view_include_floating(swayc_active_workspace()); 228 swayc_t *focused = current_container;
229 229
230 // translate "10 ppt" (10%) to appropriate # of pixels in case we need it 230 // translate "10 ppt" (10%) to appropriate # of pixels in case we need it
231 float ppt_dim = (float)dimension / 100; 231 float ppt_dim = (float)dimension / 100;
diff --git a/sway/commands/split.c b/sway/commands/split.c
index e7da93d7..e3045a4f 100644
--- a/sway/commands/split.c
+++ b/sway/commands/split.c
@@ -17,7 +17,7 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) {
17 if ((error = checkarg(argc, name, EXPECTED_EQUAL_TO, 0))) { 17 if ((error = checkarg(argc, name, EXPECTED_EQUAL_TO, 0))) {
18 return error; 18 return error;
19 } 19 }
20 swayc_t *focused = get_focused_container(&root_container); 20 swayc_t *focused = current_container;
21 21
22 // Case of floating window, don't split 22 // Case of floating window, don't split
23 if (focused->is_floating) { 23 if (focused->is_floating) {
@@ -66,7 +66,7 @@ struct cmd_results *cmd_split(int argc, char **argv) {
66 } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { 66 } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) {
67 _do_split(argc - 1, argv + 1, L_HORIZ); 67 _do_split(argc - 1, argv + 1, L_HORIZ);
68 } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { 68 } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) {
69 swayc_t *focused = get_focused_container(&root_container); 69 swayc_t *focused = current_container;
70 if (focused->parent->layout == L_VERT) { 70 if (focused->parent->layout == L_VERT) {
71 _do_split(argc - 1, argv + 1, L_HORIZ); 71 _do_split(argc - 1, argv + 1, L_HORIZ);
72 } else { 72 } else {
@@ -89,7 +89,7 @@ struct cmd_results *cmd_splith(int argc, char **argv) {
89} 89}
90 90
91struct cmd_results *cmd_splitt(int argc, char **argv) { 91struct cmd_results *cmd_splitt(int argc, char **argv) {
92 swayc_t *focused = get_focused_container(&root_container); 92 swayc_t *focused = current_container;
93 if (focused->parent->layout == L_VERT) { 93 if (focused->parent->layout == L_VERT) {
94 return _do_split(argc, argv, L_HORIZ); 94 return _do_split(argc, argv, L_HORIZ);
95 } else { 95 } else {
diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c
index 34a2ae44..ac213261 100644
--- a/sway/commands/unmark.c
+++ b/sway/commands/unmark.c
@@ -5,7 +5,7 @@
5#include "stringop.h" 5#include "stringop.h"
6 6
7struct cmd_results *cmd_unmark(int argc, char **argv) { 7struct cmd_results *cmd_unmark(int argc, char **argv) {
8 swayc_t *view = get_focused_container(&root_container); 8 swayc_t *view = current_container;
9 9
10 if (view->marks) { 10 if (view->marks) {
11 if (argc) { 11 if (argc) {