summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-05 18:12:14 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-05 18:12:14 -0400
commit78c08fb0a281cbe74c56f0a2ea4b9370b9372661 (patch)
tree3fc34f67deb2988a1dcd1bf06f0798ada07333b8 /sway
parentMerge pull request #2185 from swaywm/update-wlroots-1076 (diff)
downloadsway-78c08fb0a281cbe74c56f0a2ea4b9370b9372661.tar.gz
sway-78c08fb0a281cbe74c56f0a2ea4b9370b9372661.tar.zst
sway-78c08fb0a281cbe74c56f0a2ea4b9370b9372661.zip
Implement mode --pango_markup
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/mode.c19
-rw-r--r--sway/ipc-server.c4
-rw-r--r--sway/sway.5.scd4
3 files changed, 22 insertions, 5 deletions
diff --git a/sway/commands/mode.c b/sway/commands/mode.c
index 00331ccc..d2c14468 100644
--- a/sway/commands/mode.c
+++ b/sway/commands/mode.c
@@ -26,7 +26,17 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
26 "mode", "Can only be used in config file."); 26 "mode", "Can only be used in config file.");
27 } 27 }
28 28
29 const char *mode_name = argv[0]; 29 bool pango = strcmp(*argv, "--pango_markup") == 0;
30 if (pango) {
31 argc--; argv++;
32 if (argc == 0) {
33 return cmd_results_new(CMD_FAILURE, "mode",
34 "Mode name is missing");
35 }
36 }
37
38 char *mode_name = *argv;
39 strip_quotes(mode_name);
30 struct sway_mode *mode = NULL; 40 struct sway_mode *mode = NULL;
31 // Find mode 41 // Find mode
32 for (int i = 0; i < config->modes->length; ++i) { 42 for (int i = 0; i < config->modes->length; ++i) {
@@ -46,6 +56,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
46 mode->name = strdup(mode_name); 56 mode->name = strdup(mode_name);
47 mode->keysym_bindings = create_list(); 57 mode->keysym_bindings = create_list();
48 mode->keycode_bindings = create_list(); 58 mode->keycode_bindings = create_list();
59 mode->pango = pango;
49 list_add(config->modes, mode); 60 list_add(config->modes, mode);
50 } 61 }
51 if (!mode) { 62 if (!mode) {
@@ -54,13 +65,15 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
54 return error; 65 return error;
55 } 66 }
56 if ((config->reading && argc > 1) || (!config->reading && argc == 1)) { 67 if ((config->reading && argc > 1) || (!config->reading && argc == 1)) {
57 wlr_log(L_DEBUG, "Switching to mode `%s'",mode->name); 68 wlr_log(L_DEBUG, "Switching to mode `%s' (pango=%d)",
69 mode->name, mode->pango);
58 } 70 }
59 // Set current mode 71 // Set current mode
60 config->current_mode = mode; 72 config->current_mode = mode;
61 if (argc == 1) { 73 if (argc == 1) {
62 // trigger IPC mode event 74 // trigger IPC mode event
63 ipc_event_mode(config->current_mode->name); 75 ipc_event_mode(config->current_mode->name,
76 config->current_mode->pango);
64 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 77 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
65 } 78 }
66 79
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index abc2d7cb..8cfd9f26 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -332,13 +332,15 @@ void ipc_event_barconfig_update(struct bar_config *bar) {
332 json_object_put(json); 332 json_object_put(json);
333} 333}
334 334
335void ipc_event_mode(const char *mode) { 335void ipc_event_mode(const char *mode, bool pango) {
336 if (!ipc_has_event_listeners(IPC_EVENT_MODE)) { 336 if (!ipc_has_event_listeners(IPC_EVENT_MODE)) {
337 return; 337 return;
338 } 338 }
339 wlr_log(L_DEBUG, "Sending mode::%s event", mode); 339 wlr_log(L_DEBUG, "Sending mode::%s event", mode);
340 json_object *obj = json_object_new_object(); 340 json_object *obj = json_object_new_object();
341 json_object_object_add(obj, "change", json_object_new_string(mode)); 341 json_object_object_add(obj, "change", json_object_new_string(mode));
342 json_object_object_add(obj, "pango_markup",
343 json_object_new_boolean(pango));
342 344
343 const char *json_string = json_object_to_json_string(obj); 345 const char *json_string = json_object_to_json_string(obj);
344 ipc_send_event(json_string, IPC_EVENT_MODE); 346 ipc_send_event(json_string, IPC_EVENT_MODE);
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 5ce6bf06..7c553d3f 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -413,10 +413,12 @@ The default colors are:
413*mode* <mode> 413*mode* <mode>
414 Switches to the specified mode. The default mode _default_. 414 Switches to the specified mode. The default mode _default_.
415 415
416*mode* <mode> *{* <commands...> *}* 416*mode* [--pango\_markup] <mode> *{* <commands...> *}*
417 _commands..._ after *{* will be added to the specified mode. A newline is 417 _commands..._ after *{* will be added to the specified mode. A newline is
418 required between *{* and the first command, and *}* must be alone on a 418 required between *{* and the first command, and *}* must be alone on a
419 line. Only *bindsym* and *bindcode* commands are permitted in mode blocks. 419 line. Only *bindsym* and *bindcode* commands are permitted in mode blocks.
420 If _--pango\_markup_ is given, then _mode_ will be interpreted as pango
421 markup.
420 422
421*mouse\_warping* output|none 423*mouse\_warping* output|none
422 If _output_ is specified, the mouse will be moved to new outputs as you 424 If _output_ is specified, the mouse will be moved to new outputs as you