mirror of
https://github.com/swaywm/sway.git
synced 2025-11-25 06:59:48 -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
|
|
@ -9,7 +9,7 @@
|
|||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct sway_idle_inhibitor_v1 *inhibitor =
|
||||
wl_container_of(listener, inhibitor, destroy);
|
||||
wlr_log(WLR_DEBUG, "Sway idle inhibitor destroyed");
|
||||
sway_log(SWAY_DEBUG, "Sway idle inhibitor destroyed");
|
||||
wl_list_remove(&inhibitor->link);
|
||||
wl_list_remove(&inhibitor->destroy.link);
|
||||
idle_inhibit_v1_check_active(inhibitor->manager);
|
||||
|
|
@ -20,7 +20,7 @@ void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data) {
|
|||
struct wlr_idle_inhibitor_v1 *wlr_inhibitor = data;
|
||||
struct sway_idle_inhibit_manager_v1 *manager =
|
||||
wl_container_of(listener, manager, new_idle_inhibitor_v1);
|
||||
wlr_log(WLR_DEBUG, "New sway idle inhibitor");
|
||||
sway_log(SWAY_DEBUG, "New sway idle inhibitor");
|
||||
|
||||
struct sway_idle_inhibitor_v1 *inhibitor =
|
||||
calloc(1, sizeof(struct sway_idle_inhibitor_v1));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
|
|
@ -175,7 +174,7 @@ void arrange_layers(struct sway_output *output) {
|
|||
|
||||
if (memcmp(&usable_area, &output->usable_area,
|
||||
sizeof(struct wlr_box)) != 0) {
|
||||
wlr_log(WLR_DEBUG, "Usable area changed, rearranging output");
|
||||
sway_log(SWAY_DEBUG, "Usable area changed, rearranging output");
|
||||
memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
|
||||
arrange_output(output);
|
||||
}
|
||||
|
|
@ -308,7 +307,7 @@ static void unmap(struct sway_layer_surface *sway_layer) {
|
|||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct sway_layer_surface *sway_layer =
|
||||
wl_container_of(listener, sway_layer, destroy);
|
||||
wlr_log(WLR_DEBUG, "Layer surface destroyed (%s)",
|
||||
sway_log(SWAY_DEBUG, "Layer surface destroyed (%s)",
|
||||
sway_layer->layer_surface->namespace);
|
||||
if (sway_layer->layer_surface->mapped) {
|
||||
unmap(sway_layer);
|
||||
|
|
@ -357,7 +356,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
|||
struct wlr_layer_surface_v1 *layer_surface = data;
|
||||
struct sway_server *server =
|
||||
wl_container_of(listener, server, layer_shell_surface);
|
||||
wlr_log(WLR_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
|
||||
sway_log(SWAY_DEBUG, "new layer surface: namespace %s layer %d anchor %d "
|
||||
"size %dx%d margin %d,%d,%d,%d",
|
||||
layer_surface->namespace, layer_surface->layer, layer_surface->layer,
|
||||
layer_surface->client_pending.desired_width,
|
||||
|
|
@ -380,7 +379,7 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
if (!output) {
|
||||
if (!root->outputs->length) {
|
||||
wlr_log(WLR_ERROR,
|
||||
sway_log(SWAY_ERROR,
|
||||
"no output to auto-assign layer surface '%s' to",
|
||||
layer_surface->namespace);
|
||||
wlr_layer_surface_v1_close(layer_surface);
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ static void handle_mode(struct wl_listener *listener, void *data) {
|
|||
// We want to enable this output, but it didn't work last time,
|
||||
// possibly because we hadn't enough CRTCs. Try again now that the
|
||||
// output has a mode.
|
||||
wlr_log(WLR_DEBUG, "Output %s has gained a CRTC, "
|
||||
sway_log(SWAY_DEBUG, "Output %s has gained a CRTC, "
|
||||
"trying to enable it", output->wlr_output->name);
|
||||
apply_output_config(oc, output);
|
||||
}
|
||||
|
|
@ -580,7 +580,7 @@ static void handle_present(struct wl_listener *listener, void *data) {
|
|||
void handle_new_output(struct wl_listener *listener, void *data) {
|
||||
struct sway_server *server = wl_container_of(listener, server, new_output);
|
||||
struct wlr_output *wlr_output = data;
|
||||
wlr_log(WLR_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
||||
sway_log(SWAY_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
||||
|
||||
struct sway_output *output = output_create(wlr_output);
|
||||
if (!output) {
|
||||
|
|
|
|||
|
|
@ -260,14 +260,14 @@ static void apply_container_state(struct sway_container *container,
|
|||
* Apply a transaction to the "current" state of the tree.
|
||||
*/
|
||||
static void transaction_apply(struct sway_transaction *transaction) {
|
||||
wlr_log(WLR_DEBUG, "Applying transaction %p", transaction);
|
||||
sway_log(SWAY_DEBUG, "Applying transaction %p", transaction);
|
||||
if (debug.txn_timings) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
struct timespec *commit = &transaction->commit_time;
|
||||
float ms = (now.tv_sec - commit->tv_sec) * 1000 +
|
||||
(now.tv_nsec - commit->tv_nsec) / 1000000.0;
|
||||
wlr_log(WLR_DEBUG, "Transaction %p: %.1fms waiting "
|
||||
sway_log(SWAY_DEBUG, "Transaction %p: %.1fms waiting "
|
||||
"(%.1f frames if 60Hz)", transaction, ms, ms / (1000.0f / 60));
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ static void transaction_progress_queue(void) {
|
|||
|
||||
static int handle_timeout(void *data) {
|
||||
struct sway_transaction *transaction = data;
|
||||
wlr_log(WLR_DEBUG, "Transaction %p timed out (%zi waiting)",
|
||||
sway_log(SWAY_DEBUG, "Transaction %p timed out (%zi waiting)",
|
||||
transaction, transaction->num_waiting);
|
||||
transaction->num_waiting = 0;
|
||||
transaction_progress_queue();
|
||||
|
|
@ -398,7 +398,7 @@ static bool should_configure(struct sway_node *node,
|
|||
}
|
||||
|
||||
static void transaction_commit(struct sway_transaction *transaction) {
|
||||
wlr_log(WLR_DEBUG, "Transaction %p committing with %i instructions",
|
||||
sway_log(SWAY_DEBUG, "Transaction %p committing with %i instructions",
|
||||
transaction, transaction->instructions->length);
|
||||
transaction->num_waiting = 0;
|
||||
for (int i = 0; i < transaction->instructions->length; ++i) {
|
||||
|
|
@ -449,7 +449,7 @@ static void transaction_commit(struct sway_transaction *transaction) {
|
|||
wl_event_source_timer_update(transaction->timer,
|
||||
server.txn_timeout_ms);
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Unable to create transaction timer (%s). "
|
||||
sway_log(SWAY_ERROR, "Unable to create transaction timer (%s). "
|
||||
"Some imperfect frames might be rendered.",
|
||||
strerror(errno));
|
||||
transaction->num_waiting = 0;
|
||||
|
|
@ -472,7 +472,7 @@ static void set_instruction_ready(
|
|||
struct timespec *start = &transaction->commit_time;
|
||||
float ms = (now.tv_sec - start->tv_sec) * 1000 +
|
||||
(now.tv_nsec - start->tv_nsec) / 1000000.0;
|
||||
wlr_log(WLR_DEBUG, "Transaction %p: %zi/%zi ready in %.1fms (%s)",
|
||||
sway_log(SWAY_DEBUG, "Transaction %p: %zi/%zi ready in %.1fms (%s)",
|
||||
transaction,
|
||||
transaction->num_configures - transaction->num_waiting + 1,
|
||||
transaction->num_configures, ms,
|
||||
|
|
@ -481,7 +481,7 @@ static void set_instruction_ready(
|
|||
|
||||
// If the transaction has timed out then its num_waiting will be 0 already.
|
||||
if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) {
|
||||
wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction);
|
||||
sway_log(SWAY_DEBUG, "Transaction %p is ready", transaction);
|
||||
wl_event_source_timer_update(transaction->timer, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -485,11 +485,11 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xdg_surface *xdg_surface = data;
|
||||
|
||||
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
||||
wlr_log(WLR_DEBUG, "New xdg_shell popup");
|
||||
sway_log(SWAY_DEBUG, "New xdg_shell popup");
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
||||
sway_log(SWAY_DEBUG, "New xdg_shell toplevel title='%s' app_id='%s'",
|
||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||
wlr_xdg_surface_ping(xdg_surface);
|
||||
|
||||
|
|
|
|||
|
|
@ -469,11 +469,11 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xdg_surface_v6 *xdg_surface = data;
|
||||
|
||||
if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
||||
wlr_log(WLR_DEBUG, "New xdg_shell_v6 popup");
|
||||
sway_log(SWAY_DEBUG, "New xdg_shell_v6 popup");
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
||||
sway_log(SWAY_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
|
||||
xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
|
||||
wlr_xdg_surface_v6_ping(xdg_surface);
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
|
|||
struct sway_xwayland_unmanaged *surface =
|
||||
calloc(1, sizeof(struct sway_xwayland_unmanaged));
|
||||
if (surface == NULL) {
|
||||
wlr_log(WLR_ERROR, "Allocation failed");
|
||||
sway_log(SWAY_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -578,12 +578,12 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xwayland_surface *xsurface = data;
|
||||
|
||||
if (xsurface->override_redirect) {
|
||||
wlr_log(WLR_DEBUG, "New xwayland unmanaged surface");
|
||||
sway_log(SWAY_DEBUG, "New xwayland unmanaged surface");
|
||||
create_unmanaged(xsurface);
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "New xwayland surface title='%s' class='%s'",
|
||||
sway_log(SWAY_DEBUG, "New xwayland surface title='%s' class='%s'",
|
||||
xsurface->title, xsurface->class);
|
||||
|
||||
struct sway_xwayland_view *xwayland_view =
|
||||
|
|
@ -655,7 +655,7 @@ void handle_xwayland_ready(struct wl_listener *listener, void *data) {
|
|||
xcb_connection_t *xcb_conn = xcb_connect(NULL, NULL);
|
||||
int err = xcb_connection_has_error(xcb_conn);
|
||||
if (err) {
|
||||
wlr_log(WLR_ERROR, "XCB connect failed: %d", err);
|
||||
sway_log(SWAY_ERROR, "XCB connect failed: %d", err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -674,7 +674,7 @@ void handle_xwayland_ready(struct wl_listener *listener, void *data) {
|
|||
free(reply);
|
||||
|
||||
if (error != NULL) {
|
||||
wlr_log(WLR_ERROR, "could not resolve atom %s, X11 error code %d",
|
||||
sway_log(SWAY_ERROR, "could not resolve atom %s, X11 error code %d",
|
||||
atom_map[i], error->error_code);
|
||||
free(error);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue