aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-06-26 15:13:03 +0100
committerLibravatar GitHub <noreply@github.com>2018-06-26 15:13:03 +0100
commitecd748d240f58961581b06272d85b5bd150b9a29 (patch)
tree298f8a97f96710a88ed4e43957c5839594cacfd2 /sway
parentxdg_shell: make view floating if a parent has been set (diff)
parentMerge pull request #2164 from ael-code/background_fixes (diff)
downloadsway-ecd748d240f58961581b06272d85b5bd150b9a29.tar.gz
sway-ecd748d240f58961581b06272d85b5bd150b9a29.tar.zst
sway-ecd748d240f58961581b06272d85b5bd150b9a29.zip
Merge branch 'master' into float_xdg_shell
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/output/background.c56
-rw-r--r--sway/desktop/layer_shell.c9
-rw-r--r--sway/desktop/output.c3
3 files changed, 41 insertions, 27 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c
index 82bccf68..55cbdff0 100644
--- a/sway/commands/output/background.c
+++ b/sway/commands/output/background.c
@@ -62,46 +62,56 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
62 wordexp_t p; 62 wordexp_t p;
63 char *src = join_args(argv, j); 63 char *src = join_args(argv, j);
64 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { 64 if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
65 return cmd_results_new(CMD_INVALID, "output", 65 struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output",
66 "Invalid syntax (%s).", src); 66 "Invalid syntax (%s)", src);
67 free(src);
68 wordfree(&p);
69 return cmd_res;
67 } 70 }
68 free(src); 71 free(src);
69 src = p.we_wordv[0]; 72 src = strdup(p.we_wordv[0]);
73 wordfree(&p);
74 if (!src) {
75 wlr_log(L_ERROR, "Failed to duplicate string");
76 return cmd_results_new(CMD_FAILURE, "output",
77 "Unable to allocate resource");
78 }
79
70 if (config->reading && *src != '/') { 80 if (config->reading && *src != '/') {
81 // src file is inside configuration dir
82
71 char *conf = strdup(config->current_config); 83 char *conf = strdup(config->current_config);
72 if (conf) { 84 if(!conf) {
73 char *conf_path = dirname(conf); 85 wlr_log(L_ERROR, "Failed to duplicate string");
74 src = malloc(strlen(conf_path) + strlen(src) + 2); 86 return cmd_results_new(CMD_FAILURE, "output",
75 if (!src) {
76 free(conf);
77 wordfree(&p);
78 wlr_log(L_ERROR,
79 "Unable to allocate resource: Not enough memory");
80 return cmd_results_new(CMD_FAILURE, "output",
81 "Unable to allocate resources"); 87 "Unable to allocate resources");
82 } 88 }
83 sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); 89
90 char *conf_path = dirname(conf);
91 char *rel_path = src;
92 src = malloc(strlen(conf_path) + strlen(src) + 2);
93 if (!src) {
94 free(rel_path);
84 free(conf); 95 free(conf);
85 } else { 96 wlr_log(L_ERROR, "Unable to allocate memory");
86 wlr_log(L_ERROR, "Unable to allocate background source"); 97 return cmd_results_new(CMD_FAILURE, "output",
98 "Unable to allocate resources");
87 } 99 }
100
101 sprintf(src, "%s/%s", conf_path, rel_path);
102 free(rel_path);
103 free(conf);
88 } 104 }
89 105
90 if (access(src, F_OK) == -1) { 106 if (access(src, F_OK) == -1) {
91 struct cmd_results *cmd_res = cmd_results_new(CMD_FAILURE, "output", 107 struct cmd_results *cmd_res = cmd_results_new(CMD_FAILURE, "output",
92 "Unable to access background file '%s': %s", src, strerror(errno)); 108 "Unable to access background file '%s': %s", src, strerror(errno));
93 free(src); 109 free(src);
94 wordfree(&p);
95 return cmd_res; 110 return cmd_res;
96 } 111 }
97 112
98 output->background = strdup(src); 113 output->background = src;
99 output->background_option = strdup(mode); 114 output->background_option = strdup(mode);
100 if (src != p.we_wordv[0]) {
101 free(src);
102 }
103 wordfree(&p);
104
105 argc -= j + 1; argv += j + 1; 115 argc -= j + 1; argv += j + 1;
106 } 116 }
107 117
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 3accdefb..b57d1ee6 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -219,6 +219,8 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
219 struct sway_layer_surface *sway_layer = 219 struct sway_layer_surface *sway_layer =
220 wl_container_of(listener, sway_layer, output_destroy); 220 wl_container_of(listener, sway_layer, output_destroy);
221 wl_list_remove(&sway_layer->output_destroy.link); 221 wl_list_remove(&sway_layer->output_destroy.link);
222 wl_list_remove(&sway_layer->link);
223 wl_list_init(&sway_layer->link);
222 sway_layer->layer_surface->output = NULL; 224 sway_layer->layer_surface->output = NULL;
223 wlr_layer_surface_close(sway_layer->layer_surface); 225 wlr_layer_surface_close(sway_layer->layer_surface);
224} 226}
@@ -350,10 +352,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
350 wl_signal_add(&layer_surface->surface->events.commit, 352 wl_signal_add(&layer_surface->surface->events.commit,
351 &sway_layer->surface_commit); 353 &sway_layer->surface_commit);
352 354
353 sway_layer->output_destroy.notify = handle_output_destroy;
354 wl_signal_add(&layer_surface->output->events.destroy,
355 &sway_layer->output_destroy);
356
357 sway_layer->destroy.notify = handle_destroy; 355 sway_layer->destroy.notify = handle_destroy;
358 wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); 356 wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy);
359 sway_layer->map.notify = handle_map; 357 sway_layer->map.notify = handle_map;
@@ -366,6 +364,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
366 layer_surface->data = sway_layer; 364 layer_surface->data = sway_layer;
367 365
368 struct sway_output *output = layer_surface->output->data; 366 struct sway_output *output = layer_surface->output->data;
367 sway_layer->output_destroy.notify = handle_output_destroy;
368 wl_signal_add(&output->events.destroy, &sway_layer->output_destroy);
369
369 wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link); 370 wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link);
370 371
371 // Temporarily set the layer's current state to client_pending 372 // Temporarily set the layer's current state to client_pending
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index d4115be8..f0f1603a 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -1199,6 +1199,8 @@ static void damage_handle_destroy(struct wl_listener *listener, void *data) {
1199 1199
1200static void handle_destroy(struct wl_listener *listener, void *data) { 1200static void handle_destroy(struct wl_listener *listener, void *data) {
1201 struct sway_output *output = wl_container_of(listener, output, destroy); 1201 struct sway_output *output = wl_container_of(listener, output, destroy);
1202 wl_signal_emit(&output->events.destroy, output);
1203
1202 if (output->swayc) { 1204 if (output->swayc) {
1203 container_destroy(output->swayc); 1205 container_destroy(output->swayc);
1204 } 1206 }
@@ -1277,6 +1279,7 @@ void output_enable(struct sway_output *output) {
1277 for (size_t i = 0; i < len; ++i) { 1279 for (size_t i = 0; i < len; ++i) {
1278 wl_list_init(&output->layers[i]); 1280 wl_list_init(&output->layers[i]);
1279 } 1281 }
1282 wl_signal_init(&output->events.destroy);
1280 1283
1281 input_manager_configure_xcursor(input_manager); 1284 input_manager_configure_xcursor(input_manager);
1282 1285