aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-20 13:51:12 -0500
committerLibravatar emersion <contact@emersion.fr>2019-01-21 12:59:42 +0100
commit1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 (patch)
tree5c3f60e0219cb8b4a1b7cafb760a871661866e32 /sway/config/output.c
parentLog libinput_config_status errors (diff)
downloadsway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.gz
sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.zst
sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.zip
Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 8f59c863..ec833ffe 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -91,7 +91,7 @@ static void merge_wildcard_on_all(struct output_config *wildcard) {
91 for (int i = 0; i < config->output_configs->length; i++) { 91 for (int i = 0; i < config->output_configs->length; i++) {
92 struct output_config *oc = config->output_configs->items[i]; 92 struct output_config *oc = config->output_configs->items[i];
93 if (strcmp(wildcard->name, oc->name) != 0) { 93 if (strcmp(wildcard->name, oc->name) != 0) {
94 wlr_log(WLR_DEBUG, "Merging output * config on %s", oc->name); 94 sway_log(SWAY_DEBUG, "Merging output * config on %s", oc->name);
95 merge_output_config(oc, wildcard); 95 merge_output_config(oc, wildcard);
96 } 96 }
97 } 97 }
@@ -105,16 +105,16 @@ struct output_config *store_output_config(struct output_config *oc) {
105 105
106 int i = list_seq_find(config->output_configs, output_name_cmp, oc->name); 106 int i = list_seq_find(config->output_configs, output_name_cmp, oc->name);
107 if (i >= 0) { 107 if (i >= 0) {
108 wlr_log(WLR_DEBUG, "Merging on top of existing output config"); 108 sway_log(SWAY_DEBUG, "Merging on top of existing output config");
109 struct output_config *current = config->output_configs->items[i]; 109 struct output_config *current = config->output_configs->items[i];
110 merge_output_config(current, oc); 110 merge_output_config(current, oc);
111 free_output_config(oc); 111 free_output_config(oc);
112 oc = current; 112 oc = current;
113 } else if (!wildcard) { 113 } else if (!wildcard) {
114 wlr_log(WLR_DEBUG, "Adding non-wildcard output config"); 114 sway_log(SWAY_DEBUG, "Adding non-wildcard output config");
115 i = list_seq_find(config->output_configs, output_name_cmp, "*"); 115 i = list_seq_find(config->output_configs, output_name_cmp, "*");
116 if (i >= 0) { 116 if (i >= 0) {
117 wlr_log(WLR_DEBUG, "Merging on top of output * config"); 117 sway_log(SWAY_DEBUG, "Merging on top of output * config");
118 struct output_config *current = new_output_config(oc->name); 118 struct output_config *current = new_output_config(oc->name);
119 merge_output_config(current, config->output_configs->items[i]); 119 merge_output_config(current, config->output_configs->items[i]);
120 merge_output_config(current, oc); 120 merge_output_config(current, oc);
@@ -124,11 +124,11 @@ struct output_config *store_output_config(struct output_config *oc) {
124 list_add(config->output_configs, oc); 124 list_add(config->output_configs, oc);
125 } else { 125 } else {
126 // New wildcard config. Just add it 126 // New wildcard config. Just add it
127 wlr_log(WLR_DEBUG, "Adding output * config"); 127 sway_log(SWAY_DEBUG, "Adding output * config");
128 list_add(config->output_configs, oc); 128 list_add(config->output_configs, oc);
129 } 129 }
130 130
131 wlr_log(WLR_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " 131 sway_log(SWAY_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
132 "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)", 132 "position %d,%d scale %f transform %d) (bg %s %s) (dpms %d)",
133 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate, 133 oc->name, oc->enabled, oc->width, oc->height, oc->refresh_rate,
134 oc->x, oc->y, oc->scale, oc->transform, oc->background, 134 oc->x, oc->y, oc->scale, oc->transform, oc->background,
@@ -141,7 +141,7 @@ static bool set_mode(struct wlr_output *output, int width, int height,
141 float refresh_rate) { 141 float refresh_rate) {
142 int mhz = (int)(refresh_rate * 1000); 142 int mhz = (int)(refresh_rate * 1000);
143 if (wl_list_empty(&output->modes)) { 143 if (wl_list_empty(&output->modes)) {
144 wlr_log(WLR_DEBUG, "Assigning custom mode to %s", output->name); 144 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name);
145 return wlr_output_set_custom_mode(output, width, height, mhz); 145 return wlr_output_set_custom_mode(output, width, height, mhz);
146 } 146 }
147 147
@@ -156,11 +156,11 @@ static bool set_mode(struct wlr_output *output, int width, int height,
156 } 156 }
157 } 157 }
158 if (!best) { 158 if (!best) {
159 wlr_log(WLR_ERROR, "Configured mode for %s not available", output->name); 159 sway_log(SWAY_ERROR, "Configured mode for %s not available", output->name);
160 wlr_log(WLR_INFO, "Picking default mode instead"); 160 sway_log(SWAY_INFO, "Picking default mode instead");
161 best = wl_container_of(output->modes.prev, mode, link); 161 best = wl_container_of(output->modes.prev, mode, link);
162 } else { 162 } else {
163 wlr_log(WLR_DEBUG, "Assigning configured mode to %s", output->name); 163 sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name);
164 } 164 }
165 return wlr_output_set_mode(output, best); 165 return wlr_output_set_mode(output, best);
166} 166}
@@ -168,7 +168,7 @@ static bool set_mode(struct wlr_output *output, int width, int height,
168void terminate_swaybg(pid_t pid) { 168void terminate_swaybg(pid_t pid) {
169 int ret = kill(pid, SIGTERM); 169 int ret = kill(pid, SIGTERM);
170 if (ret != 0) { 170 if (ret != 0) {
171 wlr_log(WLR_ERROR, "Unable to terminate swaybg [pid: %d]", pid); 171 sway_log(SWAY_ERROR, "Unable to terminate swaybg [pid: %d]", pid);
172 } else { 172 } else {
173 int status; 173 int status;
174 waitpid(pid, &status, 0); 174 waitpid(pid, &status, 0);
@@ -197,7 +197,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
197 197
198 bool modeset_success; 198 bool modeset_success;
199 if (oc && oc->width > 0 && oc->height > 0) { 199 if (oc && oc->width > 0 && oc->height > 0) {
200 wlr_log(WLR_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width, 200 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width,
201 oc->height, oc->refresh_rate); 201 oc->height, oc->refresh_rate);
202 modeset_success = 202 modeset_success =
203 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); 203 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
@@ -213,22 +213,22 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
213 // Failed to modeset, maybe the output is missing a CRTC. Leave the 213 // Failed to modeset, maybe the output is missing a CRTC. Leave the
214 // output disabled for now and try again when the output gets the mode 214 // output disabled for now and try again when the output gets the mode
215 // we asked for. 215 // we asked for.
216 wlr_log(WLR_ERROR, "Failed to modeset output %s", wlr_output->name); 216 sway_log(SWAY_ERROR, "Failed to modeset output %s", wlr_output->name);
217 return false; 217 return false;
218 } 218 }
219 219
220 if (oc && oc->scale > 0) { 220 if (oc && oc->scale > 0) {
221 wlr_log(WLR_DEBUG, "Set %s scale to %f", oc->name, oc->scale); 221 sway_log(SWAY_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
222 wlr_output_set_scale(wlr_output, oc->scale); 222 wlr_output_set_scale(wlr_output, oc->scale);
223 } 223 }
224 if (oc && oc->transform >= 0) { 224 if (oc && oc->transform >= 0) {
225 wlr_log(WLR_DEBUG, "Set %s transform to %d", oc->name, oc->transform); 225 sway_log(SWAY_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
226 wlr_output_set_transform(wlr_output, oc->transform); 226 wlr_output_set_transform(wlr_output, oc->transform);
227 } 227 }
228 228
229 // Find position for it 229 // Find position for it
230 if (oc && (oc->x != -1 || oc->y != -1)) { 230 if (oc && (oc->x != -1 || oc->y != -1)) {
231 wlr_log(WLR_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); 231 sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
232 wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y); 232 wlr_output_layout_add(root->output_layout, wlr_output, oc->x, oc->y);
233 } else { 233 } else {
234 wlr_output_layout_add_auto(root->output_layout, wlr_output); 234 wlr_output_layout_add_auto(root->output_layout, wlr_output);
@@ -238,7 +238,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
238 terminate_swaybg(output->bg_pid); 238 terminate_swaybg(output->bg_pid);
239 } 239 }
240 if (oc && oc->background && config->swaybg_command) { 240 if (oc && oc->background && config->swaybg_command) {
241 wlr_log(WLR_DEBUG, "Setting background for output %s to %s", 241 sway_log(SWAY_DEBUG, "Setting background for output %s to %s",
242 wlr_output->name, oc->background); 242 wlr_output->name, oc->background);
243 243
244 char *const cmd[] = { 244 char *const cmd[] = {
@@ -252,21 +252,21 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
252 252
253 output->bg_pid = fork(); 253 output->bg_pid = fork();
254 if (output->bg_pid < 0) { 254 if (output->bg_pid < 0) {
255 wlr_log_errno(WLR_ERROR, "fork failed"); 255 sway_log_errno(SWAY_ERROR, "fork failed");
256 } else if (output->bg_pid == 0) { 256 } else if (output->bg_pid == 0) {
257 execvp(cmd[0], cmd); 257 execvp(cmd[0], cmd);
258 wlr_log_errno(WLR_ERROR, "Failed to execute swaybg"); 258 sway_log_errno(SWAY_ERROR, "Failed to execute swaybg");
259 } 259 }
260 } 260 }
261 261
262 if (oc) { 262 if (oc) {
263 switch (oc->dpms_state) { 263 switch (oc->dpms_state) {
264 case DPMS_ON: 264 case DPMS_ON:
265 wlr_log(WLR_DEBUG, "Turning on screen"); 265 sway_log(SWAY_DEBUG, "Turning on screen");
266 wlr_output_enable(wlr_output, true); 266 wlr_output_enable(wlr_output, true);
267 break; 267 break;
268 case DPMS_OFF: 268 case DPMS_OFF:
269 wlr_log(WLR_DEBUG, "Turning off screen"); 269 sway_log(SWAY_DEBUG, "Turning off screen");
270 wlr_output_enable(wlr_output, false); 270 wlr_output_enable(wlr_output, false);
271 break; 271 break;
272 case DPMS_IGNORE: 272 case DPMS_IGNORE:
@@ -325,7 +325,7 @@ static struct output_config *get_output_config(char *identifier,
325 merge_output_config(result, oc_name); 325 merge_output_config(result, oc_name);
326 merge_output_config(result, oc_id); 326 merge_output_config(result, oc_id);
327 327
328 wlr_log(WLR_DEBUG, "Generated output config \"%s\" (enabled: %d)" 328 sway_log(SWAY_DEBUG, "Generated output config \"%s\" (enabled: %d)"
329 " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)" 329 " (%dx%d@%fHz position %d,%d scale %f transform %d) (bg %s %s)"
330 " (dpms %d)", result->name, result->enabled, result->width, 330 " (dpms %d)", result->name, result->enabled, result->width,
331 result->height, result->refresh_rate, result->x, result->y, 331 result->height, result->refresh_rate, result->x, result->y,