aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-10 15:37:24 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-02-11 10:22:53 -0500
commita4d7ee1923e5847829367d741bea8c954034c312 (patch)
treef76005c6ef9cd50c253c62a1aee992d0ecce6f04
parentview: remove pointer constraints on unmap (diff)
downloadsway-a4d7ee1923e5847829367d741bea8c954034c312.tar.gz
sway-a4d7ee1923e5847829367d741bea8c954034c312.tar.zst
sway-a4d7ee1923e5847829367d741bea8c954034c312.zip
ipc: handle unnamed xkb_active_layout_name
If the active xkb_layout does not have a name, use `NULL` instead of `json_object_new_string(NULL)`. This also makes it so swaymsg will pretty print this as `(unnamed)`.
-rw-r--r--sway/ipc-json.c2
-rw-r--r--swaymsg/main.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index e1098942..23016dbd 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -597,7 +597,7 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
597 const char *layout = 597 const char *layout =
598 xkb_keymap_layout_get_name(keymap, layout_idx); 598 xkb_keymap_layout_get_name(keymap, layout_idx);
599 json_object_object_add(object, "xkb_active_layout_name", 599 json_object_object_add(object, "xkb_active_layout_name",
600 json_object_new_string(layout)); 600 layout ? json_object_new_string(layout) : NULL);
601 break; 601 break;
602 } 602 }
603 } 603 }
diff --git a/swaymsg/main.c b/swaymsg/main.c
index c84f5671..716d2d2e 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -135,8 +135,8 @@ static void pretty_print_input(json_object *i) {
135 json_object_get_int(vendor)); 135 json_object_get_int(vendor));
136 136
137 if (json_object_object_get_ex(i, "xkb_active_layout_name", &kbdlayout)) { 137 if (json_object_object_get_ex(i, "xkb_active_layout_name", &kbdlayout)) {
138 printf(" Active Keyboard Layout: %s\n", 138 const char *layout = json_object_get_string(kbdlayout);
139 json_object_get_string(kbdlayout)); 139 printf(" Active Keyboard Layout: %s\n", layout ? layout : "(unnamed)");
140 } 140 }
141 141
142 if (json_object_object_get_ex(i, "libinput_send_events", &events)) { 142 if (json_object_object_get_ex(i, "libinput_send_events", &events)) {