aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-11-26 19:43:06 -0500
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-27 02:04:13 +0100
commit1a5797803a48fb71515e6bd6335d684a6cae6b6d (patch)
tree528f75121271960a271709f495a75754916ee42f
parentinput/keyboard: check keyboard group before remove (diff)
downloadsway-1a5797803a48fb71515e6bd6335d684a6cae6b6d.tar.gz
sway-1a5797803a48fb71515e6bd6335d684a6cae6b6d.tar.zst
sway-1a5797803a48fb71515e6bd6335d684a6cae6b6d.zip
config: improvements to the reload validation
For the validation pass of reloading, there is no need to touch swaybg, swaynag, inputs, outputs, or seats. This drastically improves the speed of a reload by skipping over the expensive I/O configuration and handling of wayland clients. As long as the syntax is valid, the CMD_FAILURE's can be relayed during the actual reload.
-rw-r--r--sway/commands/input.c22
-rw-r--r--sway/config.c23
-rw-r--r--sway/input/input-manager.c19
3 files changed, 37 insertions, 27 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c
index a11ad79a..53db9a16 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -44,23 +44,6 @@ static struct cmd_handler input_config_handlers[] = {
44 { "xkb_numlock", input_cmd_xkb_numlock }, 44 { "xkb_numlock", input_cmd_xkb_numlock },
45}; 45};
46 46
47/**
48 * Re-translate keysyms if a change in the input config could affect them.
49 */
50static void retranslate_keysyms(struct input_config *input_config) {
51 for (int i = 0; i < config->input_configs->length; ++i) {
52 struct input_config *ic = config->input_configs->items[i];
53 if (ic->xkb_layout || ic->xkb_file) {
54 // this is the first config with xkb_layout or xkb_file
55 if (ic->identifier == input_config->identifier) {
56 translate_keysyms(ic);
57 }
58
59 return;
60 }
61 }
62}
63
64struct cmd_results *cmd_input(int argc, char **argv) { 47struct cmd_results *cmd_input(int argc, char **argv) {
65 struct cmd_results *error = NULL; 48 struct cmd_results *error = NULL;
66 if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) { 49 if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) {
@@ -106,8 +89,9 @@ struct cmd_results *cmd_input(int argc, char **argv) {
106 return res; 89 return res;
107 } 90 }
108 91
109 input_manager_apply_input_config(ic); 92 if (!config->reloading) {
110 retranslate_keysyms(ic); 93 input_manager_apply_input_config(ic);
94 }
111 } else { 95 } else {
112 free_input_config(config->handler_context.input_config); 96 free_input_config(config->handler_context.input_config);
113 } 97 }
diff --git a/sway/config.c b/sway/config.c
index 1f03610a..553cba2b 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -447,15 +447,17 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
447 old_config->xwayland ? "enabled" : "disabled"); 447 old_config->xwayland ? "enabled" : "disabled");
448 config->xwayland = old_config->xwayland; 448 config->xwayland = old_config->xwayland;
449 449
450 if (old_config->swaybg_client != NULL) { 450 if (!config->validating) {
451 wl_client_destroy(old_config->swaybg_client); 451 if (old_config->swaybg_client != NULL) {
452 } 452 wl_client_destroy(old_config->swaybg_client);
453 }
453 454
454 if (old_config->swaynag_config_errors.client != NULL) { 455 if (old_config->swaynag_config_errors.client != NULL) {
455 wl_client_destroy(old_config->swaynag_config_errors.client); 456 wl_client_destroy(old_config->swaynag_config_errors.client);
456 } 457 }
457 458
458 input_manager_reset_all_inputs(); 459 input_manager_reset_all_inputs();
460 }
459 } 461 }
460 462
461 config->current_config_path = path; 463 config->current_config_path = path;
@@ -520,8 +522,13 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
520 return success; 522 return success;
521 } 523 }
522 524
523 if (is_active) { 525 if (is_active && !validating) {
524 input_manager_verify_fallback_seat(); 526 input_manager_verify_fallback_seat();
527
528 for (int i = 0; i < config->input_configs->length; i++) {
529 input_manager_apply_input_config(config->input_configs->items[i]);
530 }
531
525 for (int i = 0; i < config->seat_configs->length; i++) { 532 for (int i = 0; i < config->seat_configs->length; i++) {
526 input_manager_apply_seat_config(config->seat_configs->items[i]); 533 input_manager_apply_seat_config(config->seat_configs->items[i]);
527 } 534 }
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index cfd39bab..3d7f9e8b 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -359,6 +359,23 @@ void input_manager_set_focus(struct sway_node *node) {
359 } 359 }
360} 360}
361 361
362/**
363 * Re-translate keysyms if a change in the input config could affect them.
364 */
365static void retranslate_keysyms(struct input_config *input_config) {
366 for (int i = 0; i < config->input_configs->length; ++i) {
367 struct input_config *ic = config->input_configs->items[i];
368 if (ic->xkb_layout || ic->xkb_file) {
369 // this is the first config with xkb_layout or xkb_file
370 if (ic->identifier == input_config->identifier) {
371 translate_keysyms(ic);
372 }
373
374 return;
375 }
376 }
377}
378
362void input_manager_apply_input_config(struct input_config *input_config) { 379void input_manager_apply_input_config(struct input_config *input_config) {
363 struct sway_input_device *input_device = NULL; 380 struct sway_input_device *input_device = NULL;
364 bool wildcard = strcmp(input_config->identifier, "*") == 0; 381 bool wildcard = strcmp(input_config->identifier, "*") == 0;
@@ -376,6 +393,8 @@ void input_manager_apply_input_config(struct input_config *input_config) {
376 } 393 }
377 } 394 }
378 } 395 }
396
397 retranslate_keysyms(input_config);
379} 398}
380 399
381void input_manager_reset_input(struct sway_input_device *input_device) { 400void input_manager_reset_input(struct sway_input_device *input_device) {