aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Jason Nader <jason.nader@protonmail.com>2020-06-13 12:32:24 +0900
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2020-06-14 00:55:14 -0400
commit45859be03f14fa0506ab8518feaec5ddb157e318 (patch)
treee838990235ecf0a4f543999ea292c0c5167957df /sway
parentRemove view child surface_{map,unmap} listeners on destroy (diff)
downloadsway-45859be03f14fa0506ab8518feaec5ddb157e318.tar.gz
sway-45859be03f14fa0506ab8518feaec5ddb157e318.tar.zst
sway-45859be03f14fa0506ab8518feaec5ddb157e318.zip
i3-compat: add GET_BINDING_STATE IPC command
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-json.c7
-rw-r--r--sway/ipc-server.c10
-rw-r--r--sway/sway-ipc.7.scd20
3 files changed, 37 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 066fd8db..70b81ad1 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -1261,3 +1261,10 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
1261#endif 1261#endif
1262 return json; 1262 return json;
1263} 1263}
1264
1265json_object *ipc_json_get_binding_mode(void) {
1266 json_object *current_mode = json_object_new_object();
1267 json_object_object_add(current_mode, "name",
1268 json_object_new_string(config->current_mode->name));
1269 return current_mode;
1270}
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index bd9f40bc..62bdccb8 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -876,6 +876,16 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
876 goto exit_cleanup; 876 goto exit_cleanup;
877 } 877 }
878 878
879 case IPC_GET_BINDING_STATE:
880 {
881 json_object *current_mode = ipc_json_get_binding_mode();
882 const char *json_string = json_object_to_json_string(current_mode);
883 ipc_send_reply(client, payload_type, json_string,
884 (uint32_t)strlen(json_string));
885 json_object_put(current_mode); // free
886 goto exit_cleanup;
887 }
888
879 case IPC_GET_CONFIG: 889 case IPC_GET_CONFIG:
880 { 890 {
881 json_object *json = json_object_new_object(); 891 json_object *json = json_object_new_object();
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index 63e3ceb6..495e2e7d 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -75,6 +75,9 @@ supported. *For all replies, any properties not listed are subject to removal.*
75|- 11 75|- 11
76: SYNC 76: SYNC
77: Replies failure object for i3 compatibility 77: Replies failure object for i3 compatibility
78|- 12
79: GET_BINDING_STATE
80: Request the current binding state, e.g. the currently active binding mode name.
78|- 100 81|- 100
79: GET_INPUTS 82: GET_INPUTS
80: Get the list of input devices 83: Get the list of input devices
@@ -1067,6 +1070,23 @@ boolean value _false_.
1067} 1070}
1068``` 1071```
1069 1072
1073## 12. GET_BINDING_STATE
1074
1075*MESSAGE*++
1076Returns the currently active binding mode.
1077
1078*REPLY*++
1079A single object that contains the property _name_, which is set to the
1080currently active binding mode as a string.
1081
1082*Exact Reply:*
1083```
1084{
1085 "name": "default"
1086}
1087```
1088
1089
1070## 100. GET_INPUTS 1090## 100. GET_INPUTS
1071 1091
1072*MESSAGE*++ 1092*MESSAGE*++