From 1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 Mon Sep 17 00:00:00 2001 From: M Stoeckl Date: Sun, 20 Jan 2019 13:51:12 -0500 Subject: 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. --- sway/tree/arrange.c | 8 ++++---- sway/tree/container.c | 6 +++--- sway/tree/output.c | 10 +++++----- sway/tree/root.c | 14 +++++++------- sway/tree/view.c | 14 +++++++------- sway/tree/workspace.c | 18 +++++++++--------- 6 files changed, 35 insertions(+), 35 deletions(-) (limited to 'sway/tree') 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) { double scale = parent->width / total_width; // Resize windows - wlr_log(WLR_DEBUG, "Arranging %p horizontally", parent); + sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); double child_x = parent->x; for (int i = 0; i < children->length; ++i) { struct sway_container *child = children->items[i]; @@ -75,7 +75,7 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { double scale = parent->height / total_height; // Resize - wlr_log(WLR_DEBUG, "Arranging %p vertically", parent); + sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); double child_y = parent->y; for (int i = 0; i < children->length; ++i) { struct sway_container *child = children->items[i]; @@ -186,7 +186,7 @@ void arrange_workspace(struct sway_workspace *workspace) { } struct sway_output *output = workspace->output; struct wlr_box *area = &output->usable_area; - wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d", + sway_log(SWAY_DEBUG, "Usable area for ws: %dx%d@%d,%d", area->width, area->height, area->x, area->y); workspace_remove_gaps(workspace); @@ -217,7 +217,7 @@ void arrange_workspace(struct sway_workspace *workspace) { workspace_add_gaps(workspace); node_set_dirty(&workspace->node); - wlr_log(WLR_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, + sway_log(SWAY_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, workspace->x, workspace->y); if (workspace->fullscreen) { 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 @@ struct sway_container *container_create(struct sway_view *view) { struct sway_container *c = calloc(1, sizeof(struct sway_container)); if (!c) { - wlr_log(WLR_ERROR, "Unable to allocate sway_container"); + sway_log(SWAY_ERROR, "Unable to allocate sway_container"); return NULL; } node_init(&c->node, N_CONTAINER, c); @@ -983,7 +983,7 @@ void container_discover_outputs(struct sway_container *con) { if (intersects && index == -1) { // Send enter - wlr_log(WLR_DEBUG, "Container %p entered output %p", con, output); + sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output); if (con->view) { view_for_each_surface(con->view, surface_send_enter_iterator, output->wlr_output); @@ -991,7 +991,7 @@ void container_discover_outputs(struct sway_container *con) { list_add(con->outputs, output); } else if (!intersects && index != -1) { // Send leave - wlr_log(WLR_DEBUG, "Container %p left output %p", con, output); + sway_log(SWAY_DEBUG, "Container %p left output %p", con, output); if (con->view) { view_for_each_surface(con->view, 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) { if (!output->workspaces->length) { // Create workspace char *ws_name = workspace_next_name(wlr_output->name); - wlr_log(WLR_DEBUG, "Creating default workspace %s", ws_name); + sway_log(SWAY_DEBUG, "Creating default workspace %s", ws_name); ws = workspace_create(output, ws_name); // Set each seat's focus if not already set struct sway_seat *seat = NULL; @@ -212,7 +212,7 @@ void output_disable(struct sway_output *output) { if (!sway_assert(output->enabled, "Expected an enabled output")) { return; } - wlr_log(WLR_DEBUG, "Disabling output '%s'", output->wlr_output->name); + sway_log(SWAY_DEBUG, "Disabling output '%s'", output->wlr_output->name); wl_signal_emit(&output->events.destroy, output); output_evacuate(output); @@ -237,7 +237,7 @@ void output_begin_destroy(struct sway_output *output) { if (!sway_assert(!output->enabled, "Expected a disabled output")) { return; } - wlr_log(WLR_DEBUG, "Destroying output '%s'", output->wlr_output->name); + sway_log(SWAY_DEBUG, "Destroying output '%s'", output->wlr_output->name); output->node.destroying = true; node_set_dirty(&output->node); @@ -258,11 +258,11 @@ struct output_config *output_find_config(struct sway_output *output) { if (strcasecmp(name, cur->name) == 0 || strcasecmp(identifier, cur->name) == 0) { - wlr_log(WLR_DEBUG, "Matched output config for %s", name); + sway_log(SWAY_DEBUG, "Matched output config for %s", name); oc = cur; } if (strcasecmp("*", cur->name) == 0) { - wlr_log(WLR_DEBUG, "Matched wildcard output config for %s", name); + sway_log(SWAY_DEBUG, "Matched wildcard output config for %s", name); all = cur; } 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, struct sway_root *root_create(void) { struct sway_root *root = calloc(1, sizeof(struct sway_root)); if (!root) { - wlr_log(WLR_ERROR, "Unable to allocate sway_root"); + sway_log(SWAY_ERROR, "Unable to allocate sway_root"); return NULL; } node_init(&root->node, N_ROOT, root); @@ -178,14 +178,14 @@ struct sway_workspace *root_workspace_for_pid(pid_t pid) { struct sway_workspace *ws = NULL; struct pid_workspace *pw = NULL; - wlr_log(WLR_DEBUG, "Looking up workspace for pid %d", pid); + sway_log(SWAY_DEBUG, "Looking up workspace for pid %d", pid); do { struct pid_workspace *_pw = NULL; wl_list_for_each(_pw, &pid_workspaces, link) { if (pid == _pw->pid) { pw = _pw; - wlr_log(WLR_DEBUG, + sway_log(SWAY_DEBUG, "found pid_workspace for pid %d, workspace %s", pid, pw->workspace); goto found; @@ -199,7 +199,7 @@ found: ws = workspace_by_name(pw->workspace); if (!ws) { - wlr_log(WLR_DEBUG, + sway_log(SWAY_DEBUG, "Creating workspace %s for pid %d because it disappeared", pw->workspace, pid); ws = workspace_create(pw->output, pw->workspace); @@ -222,7 +222,7 @@ static void pw_handle_output_destroy(struct wl_listener *listener, void *data) { } void root_record_workspace_pid(pid_t pid) { - wlr_log(WLR_DEBUG, "Recording workspace for process %d", pid); + sway_log(SWAY_DEBUG, "Recording workspace for process %d", pid); if (!pid_workspaces.prev && !pid_workspaces.next) { wl_list_init(&pid_workspaces); } @@ -230,12 +230,12 @@ void root_record_workspace_pid(pid_t pid) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *ws = seat_get_focused_workspace(seat); if (!ws) { - wlr_log(WLR_DEBUG, "Bailing out, no workspace"); + sway_log(SWAY_DEBUG, "Bailing out, no workspace"); return; } struct sway_output *output = ws->output; if (!output) { - wlr_log(WLR_DEBUG, "Bailing out, no output"); + sway_log(SWAY_DEBUG, "Bailing out, no output"); return; } 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) { } void view_set_csd_from_server(struct sway_view *view, bool enabled) { - wlr_log(WLR_DEBUG, "Telling view %p to set CSD to %i", view, enabled); + sway_log(SWAY_DEBUG, "Telling view %p to set CSD to %i", view, enabled); if (view->xdg_decoration) { uint32_t mode = enabled ? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE : @@ -340,7 +340,7 @@ void view_set_csd_from_server(struct sway_view *view, bool enabled) { } void view_update_csd_from_client(struct sway_view *view, bool enabled) { - wlr_log(WLR_DEBUG, "View %p updated CSD to %i", view, enabled); + sway_log(SWAY_DEBUG, "View %p updated CSD to %i", view, enabled); struct sway_container *con = view->container; if (enabled && con && con->border != B_CSD) { con->saved_border = con->border; @@ -429,12 +429,12 @@ void view_execute_criteria(struct sway_view *view) { list_t *criterias = criteria_for_view(view, CT_COMMAND); for (int i = 0; i < criterias->length; i++) { struct criteria *criteria = criterias->items[i]; - wlr_log(WLR_DEBUG, "Checking criteria %s", criteria->raw); + sway_log(SWAY_DEBUG, "Checking criteria %s", criteria->raw); if (view_has_executed_criteria(view, criteria)) { - wlr_log(WLR_DEBUG, "Criteria already executed"); + sway_log(SWAY_DEBUG, "Criteria already executed"); continue; } - wlr_log(WLR_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", + sway_log(SWAY_DEBUG, "for_window '%s' matches view %p, cmd: '%s'", criteria->raw, view, criteria->cmdlist); list_add(view->executed_criteria, criteria); list_t *res_list = execute_command( @@ -721,7 +721,7 @@ static void view_subsurface_create(struct sway_view *view, struct sway_subsurface *subsurface = calloc(1, sizeof(struct sway_subsurface)); if (subsurface == NULL) { - wlr_log(WLR_ERROR, "Allocation failed"); + sway_log(SWAY_ERROR, "Allocation failed"); return; } view_child_init(&subsurface->child, &subsurface_impl, view, @@ -860,7 +860,7 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { } const char *role = wlr_surface->role ? wlr_surface->role->name : NULL; - wlr_log(WLR_DEBUG, "Surface of unknown type (role %s): %p", + sway_log(SWAY_DEBUG, "Surface of unknown type (role %s): %p", role, wlr_surface); return NULL; } 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, output = workspace_get_initial_output(name); } - wlr_log(WLR_DEBUG, "Adding workspace %s for output %s", name, + sway_log(SWAY_DEBUG, "Adding workspace %s for output %s", name, output->wlr_output->name); struct sway_workspace *ws = calloc(1, sizeof(struct sway_workspace)); if (!ws) { - wlr_log(WLR_ERROR, "Unable to allocate sway_workspace"); + sway_log(SWAY_ERROR, "Unable to allocate sway_workspace"); return NULL; } node_init(&ws->node, N_WORKSPACE, ws); @@ -152,7 +152,7 @@ void workspace_destroy(struct sway_workspace *workspace) { } void workspace_begin_destroy(struct sway_workspace *workspace) { - wlr_log(WLR_DEBUG, "Destroying workspace '%s'", workspace->name); + sway_log(SWAY_DEBUG, "Destroying workspace '%s'", workspace->name); ipc_event_workspace(NULL, workspace, "empty"); // intentional wl_signal_emit(&workspace->node.events.destroy, &workspace->node); @@ -223,7 +223,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding, char *_target = strdup(name); _target = do_var_replacement(_target); strip_quotes(_target); - wlr_log(WLR_DEBUG, "Got valid workspace command for target: '%s'", + sway_log(SWAY_DEBUG, "Got valid workspace command for target: '%s'", _target); // Make sure that the command references an actual workspace @@ -248,7 +248,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding, temp[length - 1] = '\0'; free(_target); _target = temp; - wlr_log(WLR_DEBUG, "Isolated name from workspace number: '%s'", _target); + sway_log(SWAY_DEBUG, "Isolated name from workspace number: '%s'", _target); // Make sure the workspace number doesn't already exist if (isdigit(_target[0]) && workspace_by_number(_target)) { @@ -277,7 +277,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding, *min_order = binding->order; free(*earliest_name); *earliest_name = _target; - wlr_log(WLR_DEBUG, "Workspace: Found free name %s", _target); + sway_log(SWAY_DEBUG, "Workspace: Found free name %s", _target); } else { free(_target); } @@ -286,7 +286,7 @@ static void workspace_name_from_binding(const struct sway_binding * binding, } char *workspace_next_name(const char *output_name) { - wlr_log(WLR_DEBUG, "Workspace: Generating new workspace name for output %s", + sway_log(SWAY_DEBUG, "Workspace: Generating new workspace name for output %s", output_name); // Scan for available workspace names by looking through output-workspace // assignments primarily, falling back to bindings and numbers. @@ -468,13 +468,13 @@ bool workspace_switch(struct sway_workspace *workspace, free(seat->prev_workspace_name); seat->prev_workspace_name = malloc(strlen(active_ws->name) + 1); if (!seat->prev_workspace_name) { - wlr_log(WLR_ERROR, "Unable to allocate previous workspace name"); + sway_log(SWAY_ERROR, "Unable to allocate previous workspace name"); return false; } strcpy(seat->prev_workspace_name, active_ws->name); } - wlr_log(WLR_DEBUG, "Switching to workspace %p:%s", + sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); struct sway_node *next = seat_get_focus_inactive(seat, &workspace->node); if (next == NULL) { -- cgit v1.2.3-54-g00ecf