mirror of
https://github.com/swaywm/sway.git
synced 2025-11-16 06:59:49 -05:00
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.
This commit is contained in:
parent
5c834d36e1
commit
1211a81aad
108 changed files with 613 additions and 504 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue