aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2021-12-12 19:49:35 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2021-12-21 11:07:11 +0100
commitd9ce781d4c699d53942168edceb2562ce1f3debc (patch)
treee49be756f26df65bad8419beac0a5a7fc86728eb
parentbuild: bump wlroots dependency to 0.16.0 (diff)
downloadsway-d9ce781d4c699d53942168edceb2562ce1f3debc.tar.gz
sway-d9ce781d4c699d53942168edceb2562ce1f3debc.tar.zst
sway-d9ce781d4c699d53942168edceb2562ce1f3debc.zip
swaymsg: replace if with switch in pretty_print
-rw-r--r--swaymsg/main.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 0d9dc5a0..b58c673c 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -289,27 +289,25 @@ static void pretty_print_config(json_object *c) {
289} 289}
290 290
291static void pretty_print(int type, json_object *resp) { 291static void pretty_print(int type, json_object *resp) {
292 if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && 292 switch (type) {
293 type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && 293 case IPC_SEND_TICK:
294 type != IPC_GET_VERSION && type != IPC_GET_SEATS &&
295 type != IPC_GET_CONFIG && type != IPC_SEND_TICK) {
296 printf("%s\n", json_object_to_json_string_ext(resp,
297 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
298 return;
299 }
300
301 if (type == IPC_SEND_TICK) {
302 return; 294 return;
303 } 295 case IPC_GET_VERSION:
304
305 if (type == IPC_GET_VERSION) {
306 pretty_print_version(resp); 296 pretty_print_version(resp);
307 return; 297 return;
308 } 298 case IPC_GET_CONFIG:
309
310 if (type == IPC_GET_CONFIG) {
311 pretty_print_config(resp); 299 pretty_print_config(resp);
312 return; 300 return;
301 case IPC_COMMAND:
302 case IPC_GET_WORKSPACES:
303 case IPC_GET_INPUTS:
304 case IPC_GET_OUTPUTS:
305 case IPC_GET_SEATS:
306 break;
307 default:
308 printf("%s\n", json_object_to_json_string_ext(resp,
309 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
310 return;
313 } 311 }
314 312
315 json_object *obj; 313 json_object *obj;