diff options
author | M Stoeckl <code@mstoeckl.com> | 2019-01-20 13:51:12 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-21 12:59:42 +0100 |
commit | 1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 (patch) | |
tree | 5c3f60e0219cb8b4a1b7cafb760a871661866e32 /swaybar/tray/item.c | |
parent | Log libinput_config_status errors (diff) | |
download | sway-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 'swaybar/tray/item.c')
-rw-r--r-- | swaybar/tray/item.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/swaybar/tray/item.c b/swaybar/tray/item.c index 9056331e..39d83b23 100644 --- a/swaybar/tray/item.c +++ b/swaybar/tray/item.c | |||
@@ -35,12 +35,12 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni, | |||
35 | const char *prop, list_t **dest) { | 35 | const char *prop, list_t **dest) { |
36 | int ret = sd_bus_message_enter_container(msg, 'a', "(iiay)"); | 36 | int ret = sd_bus_message_enter_container(msg, 'a', "(iiay)"); |
37 | if (ret < 0) { | 37 | if (ret < 0) { |
38 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 38 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
39 | return ret; | 39 | return ret; |
40 | } | 40 | } |
41 | 41 | ||
42 | if (sd_bus_message_at_end(msg, 0)) { | 42 | if (sd_bus_message_at_end(msg, 0)) { |
43 | wlr_log(WLR_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop); | 43 | sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop); |
44 | return ret; | 44 | return ret; |
45 | } | 45 | } |
46 | 46 | ||
@@ -52,14 +52,14 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni, | |||
52 | while (!sd_bus_message_at_end(msg, 0)) { | 52 | while (!sd_bus_message_at_end(msg, 0)) { |
53 | ret = sd_bus_message_enter_container(msg, 'r', "iiay"); | 53 | ret = sd_bus_message_enter_container(msg, 'r', "iiay"); |
54 | if (ret < 0) { | 54 | if (ret < 0) { |
55 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 55 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
56 | goto error; | 56 | goto error; |
57 | } | 57 | } |
58 | 58 | ||
59 | int size; | 59 | int size; |
60 | ret = sd_bus_message_read(msg, "ii", NULL, &size); | 60 | ret = sd_bus_message_read(msg, "ii", NULL, &size); |
61 | if (ret < 0) { | 61 | if (ret < 0) { |
62 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 62 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
63 | goto error; | 63 | goto error; |
64 | } | 64 | } |
65 | 65 | ||
@@ -67,7 +67,7 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni, | |||
67 | size_t npixels; | 67 | size_t npixels; |
68 | ret = sd_bus_message_read_array(msg, 'y', &pixels, &npixels); | 68 | ret = sd_bus_message_read_array(msg, 'y', &pixels, &npixels); |
69 | if (ret < 0) { | 69 | if (ret < 0) { |
70 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 70 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
71 | goto error; | 71 | goto error; |
72 | } | 72 | } |
73 | 73 | ||
@@ -81,7 +81,7 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni, | |||
81 | } | 81 | } |
82 | list_free_items_and_destroy(*dest); | 82 | list_free_items_and_destroy(*dest); |
83 | *dest = pixmaps; | 83 | *dest = pixmaps; |
84 | wlr_log(WLR_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop, | 84 | sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop, |
85 | pixmaps->length); | 85 | pixmaps->length); |
86 | 86 | ||
87 | return ret; | 87 | return ret; |
@@ -107,7 +107,7 @@ static int get_property_callback(sd_bus_message *msg, void *data, | |||
107 | 107 | ||
108 | int ret; | 108 | int ret; |
109 | if (sd_bus_message_is_method_error(msg, NULL)) { | 109 | if (sd_bus_message_is_method_error(msg, NULL)) { |
110 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, | 110 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, |
111 | sd_bus_message_get_error(msg)->message); | 111 | sd_bus_message_get_error(msg)->message); |
112 | ret = sd_bus_message_get_errno(msg); | 112 | ret = sd_bus_message_get_errno(msg); |
113 | goto cleanup; | 113 | goto cleanup; |
@@ -115,7 +115,7 @@ static int get_property_callback(sd_bus_message *msg, void *data, | |||
115 | 115 | ||
116 | ret = sd_bus_message_enter_container(msg, 'v', type); | 116 | ret = sd_bus_message_enter_container(msg, 'v', type); |
117 | if (ret < 0) { | 117 | if (ret < 0) { |
118 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 118 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
119 | goto cleanup; | 119 | goto cleanup; |
120 | } | 120 | } |
121 | 121 | ||
@@ -131,16 +131,16 @@ static int get_property_callback(sd_bus_message *msg, void *data, | |||
131 | 131 | ||
132 | ret = sd_bus_message_read(msg, type, dest); | 132 | ret = sd_bus_message_read(msg, type, dest); |
133 | if (ret < 0) { | 133 | if (ret < 0) { |
134 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 134 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
135 | goto cleanup; | 135 | goto cleanup; |
136 | } | 136 | } |
137 | 137 | ||
138 | if (*type == 's' || *type == 'o') { | 138 | if (*type == 's' || *type == 'o') { |
139 | char **str = dest; | 139 | char **str = dest; |
140 | *str = strdup(*str); | 140 | *str = strdup(*str); |
141 | wlr_log(WLR_DEBUG, "%s %s = '%s'", sni->watcher_id, prop, *str); | 141 | sway_log(SWAY_DEBUG, "%s %s = '%s'", sni->watcher_id, prop, *str); |
142 | } else if (*type == 'b') { | 142 | } else if (*type == 'b') { |
143 | wlr_log(WLR_DEBUG, "%s %s = %s", sni->watcher_id, prop, | 143 | sway_log(SWAY_DEBUG, "%s %s = %s", sni->watcher_id, prop, |
144 | *(bool *)dest ? "true" : "false"); | 144 | *(bool *)dest ? "true" : "false"); |
145 | } | 145 | } |
146 | } | 146 | } |
@@ -165,7 +165,7 @@ static void sni_get_property_async(struct swaybar_sni *sni, const char *prop, | |||
165 | sni->path, "org.freedesktop.DBus.Properties", "Get", | 165 | sni->path, "org.freedesktop.DBus.Properties", "Get", |
166 | get_property_callback, data, "ss", sni->interface, prop); | 166 | get_property_callback, data, "ss", sni->interface, prop); |
167 | if (ret < 0) { | 167 | if (ret < 0) { |
168 | wlr_log(WLR_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); | 168 | sway_log(SWAY_ERROR, "%s %s: %s", sni->watcher_id, prop, strerror(-ret)); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
@@ -188,10 +188,10 @@ static int sni_check_msg_sender(struct swaybar_sni *sni, sd_bus_message *msg, | |||
188 | bool has_well_known_names = | 188 | bool has_well_known_names = |
189 | sd_bus_creds_get_mask(sd_bus_message_get_creds(msg)) & SD_BUS_CREDS_WELL_KNOWN_NAMES; | 189 | sd_bus_creds_get_mask(sd_bus_message_get_creds(msg)) & SD_BUS_CREDS_WELL_KNOWN_NAMES; |
190 | if (sni->service[0] == ':' || has_well_known_names) { | 190 | if (sni->service[0] == ':' || has_well_known_names) { |
191 | wlr_log(WLR_DEBUG, "%s has new %s", sni->watcher_id, signal); | 191 | sway_log(SWAY_DEBUG, "%s has new %s", sni->watcher_id, signal); |
192 | return 1; | 192 | return 1; |
193 | } else { | 193 | } else { |
194 | wlr_log(WLR_DEBUG, "%s may have new %s", sni->watcher_id, signal); | 194 | sway_log(SWAY_DEBUG, "%s may have new %s", sni->watcher_id, signal); |
195 | return 0; | 195 | return 0; |
196 | } | 196 | } |
197 | } | 197 | } |
@@ -218,12 +218,12 @@ static int handle_new_status(sd_bus_message *msg, void *data, sd_bus_error *erro | |||
218 | char *status; | 218 | char *status; |
219 | int r = sd_bus_message_read(msg, "s", &status); | 219 | int r = sd_bus_message_read(msg, "s", &status); |
220 | if (r < 0) { | 220 | if (r < 0) { |
221 | wlr_log(WLR_ERROR, "%s new status error: %s", sni->watcher_id, strerror(-ret)); | 221 | sway_log(SWAY_ERROR, "%s new status error: %s", sni->watcher_id, strerror(-ret)); |
222 | ret = r; | 222 | ret = r; |
223 | } else { | 223 | } else { |
224 | free(sni->status); | 224 | free(sni->status); |
225 | sni->status = strdup(status); | 225 | sni->status = strdup(status); |
226 | wlr_log(WLR_DEBUG, "%s has new status = '%s'", sni->watcher_id, status); | 226 | sway_log(SWAY_DEBUG, "%s has new status = '%s'", sni->watcher_id, status); |
227 | set_sni_dirty(sni); | 227 | set_sni_dirty(sni); |
228 | } | 228 | } |
229 | } else { | 229 | } else { |
@@ -238,7 +238,7 @@ static void sni_match_signal(struct swaybar_sni *sni, sd_bus_slot **slot, | |||
238 | int ret = sd_bus_match_signal(sni->tray->bus, slot, sni->service, sni->path, | 238 | int ret = sd_bus_match_signal(sni->tray->bus, slot, sni->service, sni->path, |
239 | sni->interface, signal, callback, sni); | 239 | sni->interface, signal, callback, sni); |
240 | if (ret < 0) { | 240 | if (ret < 0) { |
241 | wlr_log(WLR_ERROR, "Failed to subscribe to signal %s: %s", signal, | 241 | sway_log(SWAY_ERROR, "Failed to subscribe to signal %s: %s", signal, |
242 | strerror(-ret)); | 242 | strerror(-ret)); |
243 | } | 243 | } |
244 | } | 244 | } |
@@ -353,7 +353,7 @@ static int cmp_sni_id(const void *item, const void *cmp_to) { | |||
353 | static enum hotspot_event_handling icon_hotspot_callback( | 353 | static enum hotspot_event_handling icon_hotspot_callback( |
354 | struct swaybar_output *output, struct swaybar_hotspot *hotspot, | 354 | struct swaybar_output *output, struct swaybar_hotspot *hotspot, |
355 | int x, int y, uint32_t button, void *data) { | 355 | int x, int y, uint32_t button, void *data) { |
356 | wlr_log(WLR_DEBUG, "Clicked on %s", (char *)data); | 356 | sway_log(SWAY_DEBUG, "Clicked on %s", (char *)data); |
357 | 357 | ||
358 | struct swaybar_tray *tray = output->bar->tray; | 358 | struct swaybar_tray *tray = output->bar->tray; |
359 | int idx = list_seq_find(tray->items, cmp_sni_id, data); | 359 | int idx = list_seq_find(tray->items, cmp_sni_id, data); |
@@ -367,11 +367,11 @@ static enum hotspot_event_handling icon_hotspot_callback( | |||
367 | int global_y = output->output_y + (top_bar ? config->gaps.top + y: | 367 | int global_y = output->output_y + (top_bar ? config->gaps.top + y: |
368 | (int) output->output_height - config->gaps.bottom - y); | 368 | (int) output->output_height - config->gaps.bottom - y); |
369 | 369 | ||
370 | wlr_log(WLR_DEBUG, "Guessing click position at (%d, %d)", global_x, global_y); | 370 | sway_log(SWAY_DEBUG, "Guessing click position at (%d, %d)", global_x, global_y); |
371 | handle_click(sni, global_x, global_y, button, 1); // TODO get delta from event | 371 | handle_click(sni, global_x, global_y, button, 1); // TODO get delta from event |
372 | return HOTSPOT_IGNORE; | 372 | return HOTSPOT_IGNORE; |
373 | } else { | 373 | } else { |
374 | wlr_log(WLR_DEBUG, "but it doesn't exist"); | 374 | sway_log(SWAY_DEBUG, "but it doesn't exist"); |
375 | } | 375 | } |
376 | 376 | ||
377 | return HOTSPOT_PROCESS; | 377 | return HOTSPOT_PROCESS; |