aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-01-16 21:16:04 +0100
committerLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-01-22 07:26:37 +0100
commit5766f426aac11bf39234dcca4c479ee865081dad (patch)
tree0d1917761854db5d79c5d7478e46e3082bf14b8f /sway/config.c
parentcommands: add 'reload' command (diff)
downloadsway-5766f426aac11bf39234dcca4c479ee865081dad.tar.gz
sway-5766f426aac11bf39234dcca4c479ee865081dad.tar.zst
sway-5766f426aac11bf39234dcca4c479ee865081dad.zip
config reload: destroy old seat when removed from config
This adds new sway_seat_destroy and sway_cursor_destroy helpers and compare new and old config on free
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sway/config.c b/sway/config.c
index cb22f664..0f91cce6 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -21,6 +21,7 @@
21#endif 21#endif
22#include <wlr/types/wlr_output.h> 22#include <wlr/types/wlr_output.h>
23#include "sway/input/input-manager.h" 23#include "sway/input/input-manager.h"
24#include "sway/input/seat.h"
24#include "sway/commands.h" 25#include "sway/commands.h"
25#include "sway/config.h" 26#include "sway/config.h"
26#include "sway/layout.h" 27#include "sway/layout.h"
@@ -109,6 +110,23 @@ void free_config(struct sway_config *config) {
109 free(config); 110 free(config);
110} 111}
111 112
113static void destroy_removed_seats(struct sway_config *old_config,
114 struct sway_config *new_config) {
115 struct seat_config *seat_config;
116 struct sway_seat *seat;
117 int i;
118 for (i = 0; i < old_config->seat_configs->length; i++) {
119 seat_config = old_config->seat_configs->items[i];
120 /* Also destroy seats that aren't present in new config */
121 if (new_config && list_seq_find(new_config->seat_configs,
122 seat_name_cmp, seat_config->name) < 0) {
123 seat = input_manager_get_seat(input_manager,
124 seat_config->name);
125 sway_seat_destroy(seat);
126 }
127 }
128}
129
112static void config_defaults(struct sway_config *config) { 130static void config_defaults(struct sway_config *config) {
113 if (!(config->symbols = create_list())) goto cleanup; 131 if (!(config->symbols = create_list())) goto cleanup;
114 if (!(config->modes = create_list())) goto cleanup; 132 if (!(config->modes = create_list())) goto cleanup;
@@ -382,6 +400,7 @@ bool load_main_config(const char *file, bool is_active) {
382 } 400 }
383 401
384 if (old_config) { 402 if (old_config) {
403 destroy_removed_seats(old_config, config);
385 free_config(old_config); 404 free_config(old_config);
386 } 405 }
387 config->reading = false; 406 config->reading = false;