summaryrefslogtreecommitdiffstats
path: root/sway/tree
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/tree
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/tree')
-rw-r--r--sway/tree/arrange.c8
-rw-r--r--sway/tree/container.c6
-rw-r--r--sway/tree/output.c10
-rw-r--r--sway/tree/root.c14
-rw-r--r--sway/tree/view.c14
-rw-r--r--sway/tree/workspace.c18
6 files changed, 35 insertions, 35 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index 852d53bf..f78d95a4 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -35,7 +35,7 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
35 double scale = parent->width / total_width; 35 double scale = parent->width / total_width;
36 36
37 // Resize windows 37 // Resize windows
38 wlr_log(WLR_DEBUG, "Arranging %p horizontally", parent); 38 sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent);
39 double child_x = parent->x; 39 double child_x = parent->x;
40 for (int i = 0; i < children->length; ++i) { 40 for (int i = 0; i < children->length; ++i) {
41 struct sway_container *child = children->items[i]; 41 struct sway_container *child = children->items[i];
@@ -75,7 +75,7 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
75 double scale = parent->height / total_height; 75 double scale = parent->height / total_height;
76 76
77 // Resize 77 // Resize
78 wlr_log(WLR_DEBUG, "Arranging %p vertically", parent); 78 sway_log(SWAY_DEBUG, "Arranging %p vertically", parent);
79 double child_y = parent->y; 79 double child_y = parent->y;
80 for (int i = 0; i < children->length; ++i) { 80 for (int i = 0; i < children->length; ++i) {
81 struct sway_container *child = children->items[i]; 81 struct sway_container *child = children->items[i];
@@ -186,7 +186,7 @@ void arrange_workspace(struct sway_workspace *workspace) {
186 } 186 }
187 struct sway_output *output = workspace->output; 187 struct sway_output *output = workspace->output;
188 struct wlr_box *area = &output->usable_area; 188 struct wlr_box *area = &output->usable_area;
189 wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d", 189 sway_log(SWAY_DEBUG, "Usable area for ws: %dx%d@%d,%d",
190 area->width, area->height, area->x, area->y); 190 area->width, area->height, area->x, area->y);
191 workspace_remove_gaps(workspace); 191 workspace_remove_gaps(workspace);
192 192
@@ -217,7 +217,7 @@ void arrange_workspace(struct sway_workspace *workspace) {
217 217
218 workspace_add_gaps(workspace); 218 workspace_add_gaps(workspace);
219 node_set_dirty(&workspace->node); 219 node_set_dirty(&workspace->node);
220 wlr_log(WLR_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, 220 sway_log(SWAY_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name,
221 workspace->x, workspace->y); 221 workspace->x, workspace->y);
222 if (workspace->fullscreen) { 222 if (workspace->fullscreen) {
223 struct sway_container *fs = workspace->fullscreen; 223 struct sway_container *fs = workspace->fullscreen;
diff --git a/sway/tree/container.c b/sway/tree/container.c
index d9c721f5..97a52d91 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -28,7 +28,7 @@
28struct sway_container *container_create(struct sway_view *view) { 28struct sway_container *container_create(struct sway_view *view) {
29 struct sway_container *c = calloc(1, sizeof(struct sway_container)); 29 struct sway_container *c = calloc(1, sizeof(struct sway_container));
30 if (!c) { 30 if (!c) {
31 wlr_log(WLR_ERROR, "Unable to allocate sway_container"); 31 sway_log(SWAY_ERROR, "Unable to allocate sway_container");
32 return NULL; 32 return NULL;
33 } 33 }
34 node_init(&c->node, N_CONTAINER, c); 34 node_init(&c->node, N_CONTAINER, c);
@@ -983,7 +983,7 @@ void container_discover_outputs(struct sway_container *con) {
983 983
984 if (intersects && index == -1) { 984 if (intersects && index == -1) {
985 // Send enter 985 // Send enter
986 wlr_log(WLR_DEBUG, "Container %p entered output %p", con, output); 986 sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output);
987 if (con->view) { 987 if (con->view) {
988 view_for_each_surface(con->view, 988 view_for_each_surface(con->view,
989 surface_send_enter_iterator, output->wlr_output); 989 surface_send_enter_iterator, output->wlr_output);
@@ -991,7 +991,7 @@ void container_discover_outputs(struct sway_container *con) {
991 list_add(con->outputs, output); 991 list_add(con->outputs, output);
992 } else if (!intersects && index != -1) { 992 } else if (!intersects && index != -1) {
993 // Send leave 993 // Send leave
994 wlr_log(WLR_DEBUG, "Container %p left output %p", con, output); 994 sway_log(SWAY_DEBUG, "Container %p left output %p", con, output);
995 if (con->view) { 995 if (con->view) {
996 view_for_each_surface(con->view, 996 view_for_each_surface(con->view,
997 surface_send_leave_iterator, output->wlr_output); 997 surface_send_leave_iterator, output->wlr_output);
diff --git a/sway/tree/output.c b/sway/tree/output.c
index b79e70d4..7fbeeebd 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -97,7 +97,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
97 if (!output->workspaces->length) { 97 if (!output->workspaces->length) {
98 // Create workspace 98 // Create workspace
99 char *ws_name = workspace_next_name(wlr_output->name); 99 char *ws_name = workspace_next_name(wlr_output->name);
100 wlr_log(WLR_DEBUG, "Creating default workspace %s", ws_name); 100 sway_log(SWAY_DEBUG, "Creating default workspace %s", ws_name);
101 ws = workspace_create(output, ws_name); 101 ws = workspace_create(output, ws_name);
102 // Set each seat's focus if not already set 102 // Set each seat's focus if not already set
103 struct sway_seat *seat = NULL; 103 struct sway_seat *seat = NULL;
@@ -212,7 +212,7 @@ void output_disable(struct sway_output *output) {
212 if (!sway_assert(output->enabled, "Expected an enabled output")) { 212 if (!sway_assert(output->enabled, "Expected an enabled output")) {
213 return; 213 return;
214 } 214 }
215 wlr_log(WLR_DEBUG, "Disabling output '%s'", output->wlr_output->name); 215 sway_log(SWAY_DEBUG, "Disabling output '%s'", output->wlr_output->name);
216 wl_signal_emit(&output->events.destroy, output); 216 wl_signal_emit(&output->events.destroy, output);
217 217
218 output_evacuate(output); 218 output_evacuate(output);
@@ -237,7 +237,7 @@ void output_begin_destroy(struct sway_output *output) {
237 if (!sway_assert(!output->enabled, "Expected a disabled output")) { 237 if (!sway_assert(!output->enabled, "Expected a disabled output")) {
238 return; 238 return;
239 } 239 }
240 wlr_log(WLR_DEBUG, "Destroying output '%s'", output->wlr_output->name); 240 sway_log(SWAY_DEBUG, "Destroying output '%s'", output->wlr_output->name);
241 241
242 output->node.destroying = true; 242 output->node.destroying = true;
243 node_set_dirty(&output->node); 243 node_set_dirty(&output->node);
@@ -258,11 +258,11 @@ struct output_config *output_find_config(struct sway_output *output) {
258 258
259 if (strcasecmp(name, cur->name) == 0 || 259 if (strcasecmp(name, cur->name) == 0 ||
260 strcasecmp(identifier, cur->name) == 0) { 260 strcasecmp(identifier, cur->name) == 0) {
261 wlr_log(WLR_DEBUG, "Matched output config for %s", name); 261 sway_log(SWAY_DEBUG, "Matched output config for %s", name);
262 oc = cur; 262 oc = cur;
263 } 263 }
264 if (strcasecmp("*", cur->name) == 0) { 264 if (strcasecmp("*", cur->name) == 0) {
265 wlr_log(WLR_DEBUG, "Matched wildcard output config for %s", name); 265 sway_log(SWAY_DEBUG, "Matched wildcard output config for %s", name);
266 all = cur; 266 all = cur;
267 } 267 }
268 268
diff --git a/sway/tree/root.c b/sway/tree/root.c
index e5df8dd1..08ce7942 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -26,7 +26,7 @@ static void output_layout_handle_change(struct wl_listener *listener,
26struct sway_root *root_create(void) { 26struct sway_root *root_create(void) {
27 struct sway_root *root = calloc(1, sizeof(struct sway_root)); 27 struct sway_root *root = calloc(1, sizeof(struct sway_root));
28 if (!root) { 28 if (!root) {
29 wlr_log(WLR_ERROR, "Unable to allocate sway_root"); 29 sway_log(SWAY_ERROR, "Unable to allocate sway_root");
30 return NULL; 30 return NULL;
31 } 31 }
32 node_init(&root->node, N_ROOT, root); 32 node_init(&root->node, N_ROOT, root);
@@ -178,14 +178,14 @@ struct sway_workspace *root_workspace_for_pid(pid_t pid) {
178 struct sway_workspace *ws = NULL; 178 struct sway_workspace *ws = NULL;
179 struct pid_workspace *pw = NULL; 179 struct pid_workspace *pw = NULL;
180 180
181 wlr_log(WLR_DEBUG, "Looking up workspace for pid %d", pid); 181 sway_log(SWAY_DEBUG, "Looking up workspace for pid %d", pid);
182 182
183 do { 183 do {
184 struct pid_workspace *_pw = NULL; 184 struct pid_workspace *_pw = NULL;
185 wl_list_for_each(_pw, &pid_workspaces, link) { 185 wl_list_for_each(_pw, &pid_workspaces, link) {
186 if (pid == _pw->pid) { 186 if (pid == _pw->pid) {
187 pw = _pw; 187 pw = _pw;
188 wlr_log(WLR_DEBUG, 188 sway_log(SWAY_DEBUG,
189 "found pid_workspace for pid %d, workspace %s", 189 "found pid_workspace for pid %d, workspace %s",
190 pid, pw->workspace); 190 pid, pw->workspace);
191 goto found; 191 goto found;
@@ -199,7 +199,7 @@ found:
199 ws = workspace_by_name(pw->workspace); 199 ws = workspace_by_name(pw->workspace);
200 200
201 if (!ws) { 201 if (!ws) {
202 wlr_log(WLR_DEBUG, 202 sway_log(SWAY_DEBUG,
203 "Creating workspace %s for pid %d because it disappeared", 203 "Creating workspace %s for pid %d because it disappeared",
204 pw->workspace, pid); 204 pw->workspace, pid);
205 ws = workspace_create(pw->output, pw->workspace); 205 ws = workspace_create(pw->output, pw->workspace);
@@ -222,7 +222,7 @@ static void pw_handle_output_destroy(struct wl_listener *listener, void *data) {
222} 222}
223 223
224void root_record_workspace_pid(pid_t pid) { 224void root_record_workspace_pid(pid_t pid) {
225 wlr_log(WLR_DEBUG, "Recording workspace for process %d", pid); 225 sway_log(SWAY_DEBUG, "Recording workspace for process %d", pid);
226 if (!pid_workspaces.prev && !pid_workspaces.next) { 226 if (!pid_workspaces.prev && !pid_workspaces.next) {
227 wl_list_init(&pid_workspaces); 227 wl_list_init(&pid_workspaces);
228 } 228 }
@@ -230,12 +230,12 @@ void root_record_workspace_pid(pid_t pid) {
230 struct sway_seat *seat = input_manager_current_seat(); 230 struct sway_seat *seat = input_manager_current_seat();
231 struct sway_workspace *ws = seat_get_focused_workspace(seat); 231 struct sway_workspace *ws = seat_get_focused_workspace(seat);
232 if (!ws) { 232 if (!ws) {
233 wlr_log(WLR_DEBUG, "Bailing out, no workspace"); 233 sway_log(SWAY_DEBUG, "Bailing out, no workspace");
234 return; 234 return;
235 } 235 }
236 struct sway_output *output = ws->output; 236 struct sway_output *output = ws->output;
237 if (!output) { 237 if (!output) {
238 wlr_log(WLR_DEBUG, "Bailing out, no output"); 238 sway_log(SWAY_DEBUG, "Bailing out, no output");
239 return; 239 return;
240 } 240 }
241 241
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e65968c6..bc252521 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -328,7 +328,7 @@ void view_request_activate(struct sway_view *view) {
328} 328}
329 329
330void view_set_csd_from_server(struct sway_view *view, bool enabled) { 330void view_set_csd_from_server(struct sway_view *view, bool enabled) {
331 wlr_log(WLR_DEBUG, "Telling view %p to set CSD to %i", view, enabled); 331 sway_log(SWAY_DEBUG, "Telling view %p to set CSD to %i", view, enabled);
332 if (view->xdg_decoration) { 332 if (view->xdg_decoration) {
333 uint32_t mode = enabled ? 333 uint32_t mode = enabled ?
334 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE : 334 WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
@@ -340,7 +340,7 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) {
340} 340}
341 341
342void view_update_csd_from_client(struct sway_view *view, bool enabled) { 342void view_update_csd_from_client(struct sway_view *view, bool enabled) {
343 wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled); 343 sway_log(SWAY_DEBUG, "View %p updated CSD to %i", view, enabled);
344 struct sway_container *con = view->container; 344 struct sway_container *con = view->container;
345 if (enabled && con && con->border != B_CSD) { 345 if (enabled && con && con->border != B_CSD) {
346 con->saved_border = con->border; 346 con->saved_border = con->border;
@@ -429,12 +429,12 @@ void view_execute_criteria(struct sway_view *view) {
429 list_t *criterias = criteria_for_view(view, CT_COMMAND); 429 list_t *criterias = criteria_for_view(view, CT_COMMAND);
430 for (int i = 0; i < criterias->length; i++) { 430 for (int i = 0; i < criterias->length; i++) {
431 struct criteria *criteria = criterias->items[i]; 431 struct criteria *criteria = criterias->items[i];
432 wlr_log(WLR_DEBUG, "Checking criteria %s", criteria->raw); 432 sway_log(SWAY_DEBUG, "Checking criteria %s", criteria->raw);
433 if (view_has_executed_criteria(view, criteria)) { 433 if (view_has_executed_criteria(view, criteria)) {
434 wlr_log(WLR_DEBUG, "Criteria already executed"); 434 sway_log(SWAY_DEBUG, "Criteria already executed");
435 continue; 435 continue;
436 } 436 }
437 wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", 437 sway_log(SWAY_DEBUG, "for_window '%s' matches view %p, cmd: '%s'",
438 criteria->raw, view, criteria->cmdlist); 438 criteria->raw, view, criteria->cmdlist);
439 list_add(view->executed_criteria, criteria); 439 list_add(view->executed_criteria, criteria);
440 list_t *res_list = execute_command( 440 list_t *res_list = execute_command(
@@ -721,7 +721,7 @@ static void view_subsurface_create(struct sway_view *view,
721 struct sway_subsurface *subsurface = 721 struct sway_subsurface *subsurface =
722 calloc(1, sizeof(struct sway_subsurface)); 722 calloc(1, sizeof(struct sway_subsurface));
723 if (subsurface == NULL) { 723 if (subsurface == NULL) {
724 wlr_log(WLR_ERROR, "Allocation failed"); 724 sway_log(SWAY_ERROR, "Allocation failed");
725 return; 725 return;
726 } 726 }
727 view_child_init(&subsurface->child, &subsurface_impl, view, 727 view_child_init(&subsurface->child, &subsurface_impl, view,
@@ -860,7 +860,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
860 } 860 }
861 861
862 const char *role = wlr_surface->role ? wlr_surface->role->name : NULL; 862 const char *role = wlr_surface->role ? wlr_surface->role->name : NULL;
863 wlr_log(WLR_DEBUG, "Surface of unknown type (role %s): %p", 863 sway_log(SWAY_DEBUG, "Surface of unknown type (role %s): %p",
864 role, wlr_surface); 864 role, wlr_surface);
865 return NULL; 865 return NULL;
866} 866}
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 7f18046d..e89c0849 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -69,12 +69,12 @@ struct sway_workspace *workspace_create(struct sway_output *output,
69 output = workspace_get_initial_output(name); 69 output = workspace_get_initial_output(name);
70 } 70 }
71 71
72 wlr_log(WLR_DEBUG, "Adding workspace %s for output %s", name, 72 sway_log(SWAY_DEBUG, "Adding workspace %s for output %s", name,
73 output->wlr_output->name); 73 output->wlr_output->name);
74 74
75 struct sway_workspace *ws = calloc(1, sizeof(struct sway_workspace)); 75 struct sway_workspace *ws = calloc(1, sizeof(struct sway_workspace));
76 if (!ws) { 76 if (!ws) {
77 wlr_log(WLR_ERROR, "Unable to allocate sway_workspace"); 77 sway_log(SWAY_ERROR, "Unable to allocate sway_workspace");
78 return NULL; 78 return NULL;
79 } 79 }
80 node_init(&ws->node, N_WORKSPACE, ws); 80 node_init(&ws->node, N_WORKSPACE, ws);
@@ -152,7 +152,7 @@ void workspace_destroy(struct sway_workspace *workspace) {
152} 152}
153 153
154void workspace_begin_destroy(struct sway_workspace *workspace) { 154void workspace_begin_destroy(struct sway_workspace *workspace) {
155 wlr_log(WLR_DEBUG, "Destroying workspace '%s'", workspace->name); 155 sway_log(SWAY_DEBUG, "Destroying workspace '%s'", workspace->name);
156 ipc_event_workspace(NULL, workspace, "empty"); // intentional 156 ipc_event_workspace(NULL, workspace, "empty"); // intentional
157 wl_signal_emit(&workspace->node.events.destroy, &workspace->node); 157 wl_signal_emit(&workspace->node.events.destroy, &workspace->node);
158 158
@@ -223,7 +223,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
223 char *_target = strdup(name); 223 char *_target = strdup(name);
224 _target = do_var_replacement(_target); 224 _target = do_var_replacement(_target);
225 strip_quotes(_target); 225 strip_quotes(_target);
226 wlr_log(WLR_DEBUG, "Got valid workspace command for target: '%s'", 226 sway_log(SWAY_DEBUG, "Got valid workspace command for target: '%s'",
227 _target); 227 _target);
228 228
229 // Make sure that the command references an actual workspace 229 // Make sure that the command references an actual workspace
@@ -248,7 +248,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
248 temp[length - 1] = '\0'; 248 temp[length - 1] = '\0';
249 free(_target); 249 free(_target);
250 _target = temp; 250 _target = temp;
251 wlr_log(WLR_DEBUG, "Isolated name from workspace number: '%s'", _target); 251 sway_log(SWAY_DEBUG, "Isolated name from workspace number: '%s'", _target);
252 252
253 // Make sure the workspace number doesn't already exist 253 // Make sure the workspace number doesn't already exist
254 if (isdigit(_target[0]) && workspace_by_number(_target)) { 254 if (isdigit(_target[0]) && workspace_by_number(_target)) {
@@ -277,7 +277,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
277 *min_order = binding->order; 277 *min_order = binding->order;
278 free(*earliest_name); 278 free(*earliest_name);
279 *earliest_name = _target; 279 *earliest_name = _target;
280 wlr_log(WLR_DEBUG, "Workspace: Found free name %s", _target); 280 sway_log(SWAY_DEBUG, "Workspace: Found free name %s", _target);
281 } else { 281 } else {
282 free(_target); 282 free(_target);
283 } 283 }
@@ -286,7 +286,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
286} 286}
287 287
288char *workspace_next_name(const char *output_name) { 288char *workspace_next_name(const char *output_name) {
289 wlr_log(WLR_DEBUG, "Workspace: Generating new workspace name for output %s", 289 sway_log(SWAY_DEBUG, "Workspace: Generating new workspace name for output %s",
290 output_name); 290 output_name);
291 // Scan for available workspace names by looking through output-workspace 291 // Scan for available workspace names by looking through output-workspace
292 // assignments primarily, falling back to bindings and numbers. 292 // assignments primarily, falling back to bindings and numbers.
@@ -468,13 +468,13 @@ bool workspace_switch(struct sway_workspace *workspace,
468 free(seat->prev_workspace_name); 468 free(seat->prev_workspace_name);
469 seat->prev_workspace_name = malloc(strlen(active_ws->name) + 1); 469 seat->prev_workspace_name = malloc(strlen(active_ws->name) + 1);
470 if (!seat->prev_workspace_name) { 470 if (!seat->prev_workspace_name) {
471 wlr_log(WLR_ERROR, "Unable to allocate previous workspace name"); 471 sway_log(SWAY_ERROR, "Unable to allocate previous workspace name");
472 return false; 472 return false;
473 } 473 }
474 strcpy(seat->prev_workspace_name, active_ws->name); 474 strcpy(seat->prev_workspace_name, active_ws->name);
475 } 475 }
476 476
477 wlr_log(WLR_DEBUG, "Switching to workspace %p:%s", 477 sway_log(SWAY_DEBUG, "Switching to workspace %p:%s",
478 workspace, workspace->name); 478 workspace, workspace->name);
479 struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node); 479 struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node);
480 if (next == NULL) { 480 if (next == NULL) {