aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/focus.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-10 18:27:21 -0500
committerLibravatar M Stoeckl <code@mstoeckl.com>2019-01-14 08:05:29 -0500
commit2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0 (patch)
tree56332b9c150459beb5aef94605372ef179ec8854 /sway/commands/focus.c
parentRemove 'input' field of IPC command return json (diff)
downloadsway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.tar.gz
sway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.tar.zst
sway-2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0.zip
Remove now-unused "input" argument of cmd_results_new
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))` applied to `cmd_results_new`. String usage constants have been converted from pointers to arrays when encountered. General handler format strings were sometimes modified to include the old input string, especially for unknown command errors.
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r--sway/commands/focus.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c
index 97ffe91c..8564f3ff 100644
--- a/sway/commands/focus.c
+++ b/sway/commands/focus.c
@@ -179,17 +179,17 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
179 seat_set_focus_container(seat, new_focus); 179 seat_set_focus_container(seat, new_focus);
180 seat_consider_warp_to_focus(seat); 180 seat_consider_warp_to_focus(seat);
181 } else { 181 } else {
182 return cmd_results_new(CMD_FAILURE, "focus", 182 return cmd_results_new(CMD_FAILURE,
183 "Failed to find a %s container in workspace", 183 "Failed to find a %s container in workspace",
184 floating ? "floating" : "tiling"); 184 floating ? "floating" : "tiling");
185 } 185 }
186 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 186 return cmd_results_new(CMD_SUCCESS, NULL);
187} 187}
188 188
189static struct cmd_results *focus_output(struct sway_seat *seat, 189static struct cmd_results *focus_output(struct sway_seat *seat,
190 int argc, char **argv) { 190 int argc, char **argv) {
191 if (!argc) { 191 if (!argc) {
192 return cmd_results_new(CMD_INVALID, "focus", 192 return cmd_results_new(CMD_INVALID,
193 "Expected 'focus output <direction|name>'"); 193 "Expected 'focus output <direction|name>'");
194 } 194 }
195 char *identifier = join_args(argv, argc); 195 char *identifier = join_args(argv, argc);
@@ -199,7 +199,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
199 enum wlr_direction direction; 199 enum wlr_direction direction;
200 if (!parse_direction(identifier, &direction)) { 200 if (!parse_direction(identifier, &direction)) {
201 free(identifier); 201 free(identifier);
202 return cmd_results_new(CMD_INVALID, "focus", 202 return cmd_results_new(CMD_INVALID,
203 "There is no output with that name"); 203 "There is no output with that name");
204 } 204 }
205 struct sway_workspace *ws = seat_get_focused_workspace(seat); 205 struct sway_workspace *ws = seat_get_focused_workspace(seat);
@@ -223,21 +223,21 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
223 seat_consider_warp_to_focus(seat); 223 seat_consider_warp_to_focus(seat);
224 } 224 }
225 225
226 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 226 return cmd_results_new(CMD_SUCCESS, NULL);
227} 227}
228 228
229static struct cmd_results *focus_parent(void) { 229static struct cmd_results *focus_parent(void) {
230 struct sway_seat *seat = config->handler_context.seat; 230 struct sway_seat *seat = config->handler_context.seat;
231 struct sway_container *con = config->handler_context.container; 231 struct sway_container *con = config->handler_context.container;
232 if (!con || con->is_fullscreen) { 232 if (!con || con->is_fullscreen) {
233 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 233 return cmd_results_new(CMD_SUCCESS, NULL);
234 } 234 }
235 struct sway_node *parent = node_get_parent(&con->node); 235 struct sway_node *parent = node_get_parent(&con->node);
236 if (parent) { 236 if (parent) {
237 seat_set_focus(seat, parent); 237 seat_set_focus(seat, parent);
238 seat_consider_warp_to_focus(seat); 238 seat_consider_warp_to_focus(seat);
239 } 239 }
240 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 240 return cmd_results_new(CMD_SUCCESS, NULL);
241} 241}
242 242
243static struct cmd_results *focus_child(void) { 243static struct cmd_results *focus_child(void) {
@@ -248,15 +248,15 @@ static struct cmd_results *focus_child(void) {
248 seat_set_focus(seat, focus); 248 seat_set_focus(seat, focus);
249 seat_consider_warp_to_focus(seat); 249 seat_consider_warp_to_focus(seat);
250 } 250 }
251 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 251 return cmd_results_new(CMD_SUCCESS, NULL);
252} 252}
253 253
254struct cmd_results *cmd_focus(int argc, char **argv) { 254struct cmd_results *cmd_focus(int argc, char **argv) {
255 if (config->reading || !config->active) { 255 if (config->reading || !config->active) {
256 return cmd_results_new(CMD_DEFER, NULL, NULL); 256 return cmd_results_new(CMD_DEFER, NULL);
257 } 257 }
258 if (!root->outputs->length) { 258 if (!root->outputs->length) {
259 return cmd_results_new(CMD_INVALID, "focus", 259 return cmd_results_new(CMD_INVALID,
260 "Can't run this command while there's no outputs connected."); 260 "Can't run this command while there's no outputs connected.");
261 } 261 }
262 struct sway_node *node = config->handler_context.node; 262 struct sway_node *node = config->handler_context.node;
@@ -264,7 +264,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
264 struct sway_workspace *workspace = config->handler_context.workspace; 264 struct sway_workspace *workspace = config->handler_context.workspace;
265 struct sway_seat *seat = config->handler_context.seat; 265 struct sway_seat *seat = config->handler_context.seat;
266 if (node->type < N_WORKSPACE) { 266 if (node->type < N_WORKSPACE) {
267 return cmd_results_new(CMD_FAILURE, "focus", 267 return cmd_results_new(CMD_FAILURE,
268 "Command 'focus' cannot be used above the workspace level"); 268 "Command 'focus' cannot be used above the workspace level");
269 } 269 }
270 270
@@ -274,7 +274,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
274 } 274 }
275 seat_set_focus_container(seat, container); 275 seat_set_focus_container(seat, container);
276 seat_consider_warp_to_focus(seat); 276 seat_consider_warp_to_focus(seat);
277 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 277 return cmd_results_new(CMD_SUCCESS, NULL);
278 } 278 }
279 279
280 if (strcmp(argv[0], "floating") == 0) { 280 if (strcmp(argv[0], "floating") == 0) {
@@ -300,7 +300,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
300 300
301 enum wlr_direction direction = 0; 301 enum wlr_direction direction = 0;
302 if (!parse_direction(argv[0], &direction)) { 302 if (!parse_direction(argv[0], &direction)) {
303 return cmd_results_new(CMD_INVALID, "focus", 303 return cmd_results_new(CMD_INVALID,
304 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' " 304 "Expected 'focus <direction|parent|child|mode_toggle|floating|tiling>' "
305 "or 'focus output <direction|name>'"); 305 "or 'focus output <direction|name>'");
306 } 306 }
@@ -310,14 +310,14 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
310 struct sway_output *new_output = 310 struct sway_output *new_output =
311 output_get_in_direction(workspace->output, direction); 311 output_get_in_direction(workspace->output, direction);
312 if (!new_output) { 312 if (!new_output) {
313 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 313 return cmd_results_new(CMD_SUCCESS, NULL);
314 } 314 }
315 315
316 struct sway_node *node = 316 struct sway_node *node =
317 get_node_in_output_direction(new_output, direction); 317 get_node_in_output_direction(new_output, direction);
318 seat_set_focus(seat, node); 318 seat_set_focus(seat, node);
319 seat_consider_warp_to_focus(seat); 319 seat_consider_warp_to_focus(seat);
320 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 320 return cmd_results_new(CMD_SUCCESS, NULL);
321 } 321 }
322 322
323 struct sway_node *next_focus = 323 struct sway_node *next_focus =
@@ -327,5 +327,5 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
327 seat_consider_warp_to_focus(seat); 327 seat_consider_warp_to_focus(seat);
328 } 328 }
329 329
330 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 330 return cmd_results_new(CMD_SUCCESS, NULL);
331} 331}