aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-28 14:21:37 +0200
committerSimon Ser <contact@emersion.fr>2023-07-28 14:21:37 +0200
commitd40bcfe2c18f057f4bc324a81230f6ba2267db44 (patch)
treebce3eef983848ee4f9061df079eabdba419854da
parent60ca6f17eb190cfdb3ba9863cdd8a4f7b00f3e64 (diff)
xwayland: avoid calling xwm_get_atom_name() when debug logs are off
xwm_get_atom_name() performs a roundtrip to the X11 server. Avoid calling this blocking function if debug logs are turned off.
-rw-r--r--xwayland/selection/outgoing.c10
-rw-r--r--xwayland/xwm.c9
2 files changed, 11 insertions, 8 deletions
diff --git a/xwayland/selection/outgoing.c b/xwayland/selection/outgoing.c
index 87c0fb06..3e5432f0 100644
--- a/xwayland/selection/outgoing.c
+++ b/xwayland/selection/outgoing.c
@@ -412,10 +412,12 @@ void xwm_handle_selection_request(struct wlr_xwm *xwm,
// No xwayland surface focused, deny access to clipboard
if (xwm->focus_surface == NULL && xwm->drag_focus == NULL) {
- char *selection_name = xwm_get_atom_name(xwm, selection->atom);
- wlr_log(WLR_DEBUG, "denying read access to selection %u (%s): "
- "no xwayland surface focused", selection->atom, selection_name);
- free(selection_name);
+ if (wlr_log_get_verbosity() >= WLR_DEBUG) {
+ char *selection_name = xwm_get_atom_name(xwm, selection->atom);
+ wlr_log(WLR_DEBUG, "denying read access to selection %u (%s): "
+ "no xwayland surface focused", selection->atom, selection_name);
+ free(selection_name);
+ }
goto fail_notify_requestor;
}
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 2f690f41..188bb5b8 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -873,7 +873,7 @@ static void read_surface_property(struct wlr_xwm *xwm,
read_surface_role(xwm, xsurface, reply);
} else if (property == xwm->atoms[NET_STARTUP_ID]) {
read_surface_startup_id(xwm, xsurface, reply);
- } else {
+ } else if (wlr_log_get_verbosity() >= WLR_DEBUG) {
char *prop_name = xwm_get_atom_name(xwm, property);
wlr_log(WLR_DEBUG, "unhandled X11 property %" PRIu32 " (%s) for window %" PRIu32,
property, prop_name ? prop_name : "(null)", xsurface->window_id);
@@ -1327,7 +1327,7 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm,
changed = update_state(action, &xsurface->maximized_horz);
} else if (property == xwm->atoms[NET_WM_STATE_HIDDEN]) {
changed = update_state(action, &xsurface->minimized);
- } else if (property != XCB_ATOM_NONE) {
+ } else if (property != XCB_ATOM_NONE && wlr_log_get_verbosity() >= WLR_DEBUG) {
char *prop_name = xwm_get_atom_name(xwm, property);
wlr_log(WLR_DEBUG, "Unhandled NET_WM_STATE property change "
"%"PRIu32" (%s)", property, prop_name ? prop_name : "(null)");
@@ -1391,7 +1391,7 @@ static void xwm_handle_wm_protocols_message(struct wlr_xwm *xwm,
wl_event_source_timer_update(surface->ping_timer, 0);
surface->pinging = false;
- } else {
+ } else if (wlr_log_get_verbosity() >= WLR_DEBUG) {
char *type_name = xwm_get_atom_name(xwm, type);
wlr_log(WLR_DEBUG, "unhandled WM_PROTOCOLS client message %" PRIu32 " (%s)",
type, type_name ? type_name : "(null)");
@@ -1520,7 +1520,8 @@ static void xwm_handle_client_message(struct wlr_xwm *xwm,
xwm_handle_net_startup_info_message(xwm, ev);
} else if (ev->type == xwm->atoms[WM_CHANGE_STATE]) {
xwm_handle_wm_change_state_message(xwm, ev);
- } else if (!xwm_handle_selection_client_message(xwm, ev)) {
+ } else if (!xwm_handle_selection_client_message(xwm, ev) &&
+ wlr_log_get_verbosity() >= WLR_DEBUG) {
char *type_name = xwm_get_atom_name(xwm, ev->type);
wlr_log(WLR_DEBUG, "unhandled x11 client message %" PRIu32 " (%s)", ev->type,
type_name ? type_name : "(null)");