]> git.sur5r.net Git - i3/i3/commitdiff
Introduced a new GET_BINDING_MODES message type and reply. (#2376)
authorIngo Bürk <admin@airblader.de>
Wed, 15 Jun 2016 20:25:22 +0000 (22:25 +0200)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Wed, 15 Jun 2016 20:25:22 +0000 (22:25 +0200)
This type dumps all currently configured binding modes.

fixes #2375

docs/ipc
i3-msg/main.c
include/i3/ipc.h
man/i3-msg.man
src/ipc.c

index 033d5018d666b69801d441293b1226b37dcca65c..ddadabc4627d5beb83316489181c9c601408c558 100644 (file)
--- a/docs/ipc
+++ b/docs/ipc
@@ -80,6 +80,8 @@ GET_BAR_CONFIG (6)::
 GET_VERSION (7)::
        Gets the version of i3. The reply will be a JSON-encoded dictionary
        with the major, minor, patch and human-readable version.
 GET_VERSION (7)::
        Gets the version of i3. The reply will be a JSON-encoded dictionary
        with the major, minor, patch and human-readable version.
+GET_BINDING_MODES (8)::
+        Gets a list of currently configured binding modes.
 
 So, a typical message could look like this:
 --------------------------------------------------
 
 So, a typical message could look like this:
 --------------------------------------------------
@@ -137,6 +139,8 @@ BAR_CONFIG (6)::
        Reply to the GET_BAR_CONFIG message.
 VERSION (7)::
        Reply to the GET_VERSION message.
        Reply to the GET_BAR_CONFIG message.
 VERSION (7)::
        Reply to the GET_VERSION message.
+BINDING_MODES (8)::
+        Reply to the GET_BINDING_MODES message.
 
 === COMMAND reply
 
 
 === COMMAND reply
 
@@ -604,6 +608,15 @@ loaded_config_file_name (string)::
 }
 -------------------
 
 }
 -------------------
 
+=== BINDING_MODES reply
+
+The reply consists of an array of all currently configured binding modes.
+
+*Example:*
+---------------------
+["default", "resize"]
+---------------------
+
 == Events
 
 [[events]]
 == Events
 
 [[events]]
index 36691cae471ddeb17cb20322a82f961891757b02..658c33b4d48ec118ab5d51eba24aa77c6840d8b0 100644 (file)
@@ -161,11 +161,13 @@ int main(int argc, char *argv[]) {
                 message_type = I3_IPC_MESSAGE_TYPE_GET_MARKS;
             else if (strcasecmp(optarg, "get_bar_config") == 0)
                 message_type = I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG;
                 message_type = I3_IPC_MESSAGE_TYPE_GET_MARKS;
             else if (strcasecmp(optarg, "get_bar_config") == 0)
                 message_type = I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG;
+            else if (strcasecmp(optarg, "get_binding_modes") == 0)
+                message_type = I3_IPC_MESSAGE_TYPE_GET_BINDING_MODES;
             else if (strcasecmp(optarg, "get_version") == 0)
                 message_type = I3_IPC_MESSAGE_TYPE_GET_VERSION;
             else {
                 printf("Unknown message type\n");
             else if (strcasecmp(optarg, "get_version") == 0)
                 message_type = I3_IPC_MESSAGE_TYPE_GET_VERSION;
             else {
                 printf("Unknown message type\n");
-                printf("Known types: command, get_workspaces, get_outputs, get_tree, get_marks, get_bar_config, get_version\n");
+                printf("Known types: command, get_workspaces, get_outputs, get_tree, get_marks, get_bar_config, get_binding_modes, get_version\n");
                 exit(EXIT_FAILURE);
             }
         } else if (o == 'q') {
                 exit(EXIT_FAILURE);
             }
         } else if (o == 'q') {
index 8912bf130a5daf877ccb2445821524599a581ad9..98ac35b0eb8b6fba24250e04ba86378234d02c04 100644 (file)
@@ -51,34 +51,22 @@ typedef struct i3_ipc_header {
 /** Request the i3 version */
 #define I3_IPC_MESSAGE_TYPE_GET_VERSION 7
 
 /** Request the i3 version */
 #define I3_IPC_MESSAGE_TYPE_GET_VERSION 7
 
+/** Request a list of configured binding modes. */
+#define I3_IPC_MESSAGE_TYPE_GET_BINDING_MODES 8
+
 /*
  * Messages from i3 to clients
  *
  */
 /*
  * Messages from i3 to clients
  *
  */
-
-/** Command reply type */
 #define I3_IPC_REPLY_TYPE_COMMAND 0
 #define I3_IPC_REPLY_TYPE_COMMAND 0
-
-/** Workspaces reply type */
 #define I3_IPC_REPLY_TYPE_WORKSPACES 1
 #define I3_IPC_REPLY_TYPE_WORKSPACES 1
-
-/** Subscription reply type */
 #define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
 #define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
-
-/** Outputs reply type */
 #define I3_IPC_REPLY_TYPE_OUTPUTS 3
 #define I3_IPC_REPLY_TYPE_OUTPUTS 3
-
-/** Tree reply type */
 #define I3_IPC_REPLY_TYPE_TREE 4
 #define I3_IPC_REPLY_TYPE_TREE 4
-
-/** Marks reply type */
 #define I3_IPC_REPLY_TYPE_MARKS 5
 #define I3_IPC_REPLY_TYPE_MARKS 5
-
-/** Bar config reply type */
 #define I3_IPC_REPLY_TYPE_BAR_CONFIG 6
 #define I3_IPC_REPLY_TYPE_BAR_CONFIG 6
-
-/** i3 version reply type */
 #define I3_IPC_REPLY_TYPE_VERSION 7
 #define I3_IPC_REPLY_TYPE_VERSION 7
+#define I3_IPC_REPLY_TYPE_BINDING_MODES 8
 
 /*
  * Events from i3 to clients. Events have the first bit set high.
 
 /*
  * Events from i3 to clients. Events have the first bit set high.
index 000d9bf2026ae79c61fef6f1e06c4747cf1d285b..e81a94ab6999ddab72182f49113686e6df8f107d 100644 (file)
@@ -62,6 +62,9 @@ get_bar_config::
 Gets the configuration (as JSON map) of the workspace bar with the given ID. If
 no ID is provided, an array with all configured bar IDs is returned instead.
 
 Gets the configuration (as JSON map) of the workspace bar with the given ID. If
 no ID is provided, an array with all configured bar IDs is returned instead.
 
+get_binding_modes::
+Gets a list of configured binding modes.
+
 get_version::
 Gets the version of i3. The reply will be a JSON-encoded dictionary with the
 major, minor, patch and human-readable version.
 get_version::
 Gets the version of i3. The reply will be a JSON-encoded dictionary with the
 major, minor, patch and human-readable version.
index 2bd5f59d0b243b8406b27d2b12a9376939840a43..a6c45ed15797b0848cf539a1ec6939d190f3669e 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -958,6 +958,28 @@ IPC_HANDLER(get_bar_config) {
     y(free);
 }
 
     y(free);
 }
 
+/*
+ * Returns a list of configured binding modes
+ *
+ */
+IPC_HANDLER(get_binding_modes) {
+    yajl_gen gen = ygenalloc();
+
+    y(array_open);
+    struct Mode *mode;
+    SLIST_FOREACH(mode, &modes, modes) {
+        ystr(mode->name);
+    }
+    y(array_close);
+
+    const unsigned char *payload;
+    ylength length;
+    y(get_buf, &payload, &length);
+
+    ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BINDING_MODES, payload);
+    y(free);
+}
+
 /*
  * Callback for the YAJL parser (will be called when a string is parsed).
  *
 /*
  * Callback for the YAJL parser (will be called when a string is parsed).
  *
@@ -1034,7 +1056,7 @@ IPC_HANDLER(subscribe) {
 
 /* The index of each callback function corresponds to the numeric
  * value of the message type (see include/i3/ipc.h) */
 
 /* The index of each callback function corresponds to the numeric
  * value of the message type (see include/i3/ipc.h) */
-handler_t handlers[8] = {
+handler_t handlers[9] = {
     handle_command,
     handle_get_workspaces,
     handle_subscribe,
     handle_command,
     handle_get_workspaces,
     handle_subscribe,
@@ -1043,6 +1065,7 @@ handler_t handlers[8] = {
     handle_get_marks,
     handle_get_bar_config,
     handle_get_version,
     handle_get_marks,
     handle_get_bar_config,
     handle_get_version,
+    handle_get_binding_modes,
 };
 
 /*
 };
 
 /*