aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2022-11-06 13:54:24 +0300
committerKirill Primak <vyivel@eclair.cafe>2022-11-06 17:00:00 +0300
commit099b9de752f9cc212140533a8a2e20b31aa9028f (patch)
tree1888f3030d586908acc02651b93dccd0e7b83199
parent32daa43a454bcea1306ad0976fd4161ce8c7e86f (diff)
compositor: drop role object NULL checks in handlers
Instead, move the check to the caller.
-rw-r--r--types/data_device/wlr_drag.c7
-rw-r--r--types/wlr_compositor.c4
-rw-r--r--types/wlr_input_method_v2.c12
-rw-r--r--types/wlr_layer_shell_v1.c9
-rw-r--r--types/wlr_session_lock_v1.c9
-rw-r--r--types/wlr_subcompositor.c9
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c9
-rw-r--r--xwayland/xwm.c9
8 files changed, 6 insertions, 62 deletions
diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c
index 7d419c15..d3cb979d 100644
--- a/types/data_device/wlr_drag.c
+++ b/types/data_device/wlr_drag.c
@@ -360,9 +360,6 @@ static void drag_handle_drag_source_destroy(struct wl_listener *listener,
static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
assert(surface->role == &drag_icon_surface_role);
struct wlr_drag_icon *icon = surface->role_data;
- if (icon == NULL) {
- return;
- }
drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
}
@@ -370,9 +367,7 @@ static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
static void drag_icon_surface_role_destroy(struct wlr_surface *surface) {
assert(surface->role == &drag_icon_surface_role);
struct wlr_drag_icon *icon = surface->role_data;
- if (icon == NULL) {
- return;
- }
+
drag_icon_set_mapped(icon, false);
wl_signal_emit_mutable(&icon->events.destroy, icon);
free(icon);
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 302d7b4a..df55938c 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -425,7 +425,7 @@ static void surface_commit_state(struct wlr_surface *surface,
struct wlr_surface_state *next) {
assert(next->cached_state_locks == 0);
- if (surface->role && surface->role->precommit) {
+ if (surface->role_data != NULL && surface->role->precommit != NULL) {
surface->role->precommit(surface, next);
}
@@ -484,7 +484,7 @@ static void surface_commit_state(struct wlr_surface *surface,
surface->pending.seq++;
}
- if (surface->role && surface->role->commit) {
+ if (surface->role_data != NULL && surface->role->commit != NULL) {
surface->role->commit(surface);
}
diff --git a/types/wlr_input_method_v2.c b/types/wlr_input_method_v2.c
index 54eeb788..285a7fbe 100644
--- a/types/wlr_input_method_v2.c
+++ b/types/wlr_input_method_v2.c
@@ -149,9 +149,7 @@ static void popup_surface_set_mapped(
static void popup_surface_surface_role_commit(struct wlr_surface *surface) {
struct wlr_input_popup_surface_v2 *popup_surface = surface->role_data;
- if (popup_surface == NULL) {
- return;
- }
+
popup_surface_set_mapped(popup_surface, wlr_surface_has_buffer(surface)
&& popup_surface->input_method->client_active);
}
@@ -159,9 +157,7 @@ static void popup_surface_surface_role_commit(struct wlr_surface *surface) {
static void popup_surface_surface_role_precommit(struct wlr_surface *surface,
const struct wlr_surface_state *state) {
struct wlr_input_popup_surface_v2 *popup_surface = surface->role_data;
- if (popup_surface == NULL) {
- return;
- }
+
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
// This is a NULL commit
popup_surface_set_mapped(popup_surface, false);
@@ -170,9 +166,7 @@ static void popup_surface_surface_role_precommit(struct wlr_surface *surface,
static void popup_surface_surface_role_destroy(struct wlr_surface *surface) {
struct wlr_input_popup_surface_v2 *popup_surface = surface->role_data;
- if (popup_surface == NULL) {
- return;
- }
+
popup_surface_set_mapped(popup_surface, false);
wl_signal_emit_mutable(&popup_surface->events.destroy, NULL);
wl_list_remove(&popup_surface->link);
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index 5261fb81..fa054d3c 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -315,9 +315,6 @@ void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface) {
static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
@@ -370,9 +367,6 @@ static void layer_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state) {
struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
// This is a NULL commit
@@ -385,9 +379,6 @@ static void layer_surface_role_precommit(struct wlr_surface *wlr_surface,
static void layer_surface_role_destroy(struct wlr_surface *wlr_surface) {
struct wlr_layer_surface_v1 *surface =
wlr_layer_surface_v1_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
if (surface->configured && surface->mapped) {
layer_surface_unmap(surface);
diff --git a/types/wlr_session_lock_v1.c b/types/wlr_session_lock_v1.c
index 022ea09c..8a933fb9 100644
--- a/types/wlr_session_lock_v1.c
+++ b/types/wlr_session_lock_v1.c
@@ -135,9 +135,6 @@ static const struct ext_session_lock_surface_v1_interface lock_surface_implement
static void lock_surface_role_commit(struct wlr_surface *surface) {
struct wlr_session_lock_surface_v1 *lock_surface =
wlr_session_lock_surface_v1_from_wlr_surface(surface);
- if (lock_surface == NULL) {
- return;
- }
if (!lock_surface->configured) {
wl_resource_post_error(lock_surface->resource,
@@ -167,9 +164,6 @@ static void lock_surface_role_precommit(struct wlr_surface *surface,
const struct wlr_surface_state *state) {
struct wlr_session_lock_surface_v1 *lock_surface =
wlr_session_lock_surface_v1_from_wlr_surface(surface);
- if (lock_surface == NULL) {
- return;
- }
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
wl_resource_post_error(lock_surface->resource,
@@ -182,9 +176,6 @@ static void lock_surface_role_precommit(struct wlr_surface *surface,
static void lock_surface_role_destroy(struct wlr_surface *surface) {
struct wlr_session_lock_surface_v1 *lock_surface =
wlr_session_lock_surface_v1_from_wlr_surface(surface);
- if (lock_surface == NULL) {
- return;
- }
wl_signal_emit_mutable(&lock_surface->events.destroy, NULL);
diff --git a/types/wlr_subcompositor.c b/types/wlr_subcompositor.c
index 861bdfd7..0b0c935c 100644
--- a/types/wlr_subcompositor.c
+++ b/types/wlr_subcompositor.c
@@ -244,9 +244,6 @@ static void subsurface_unmap(struct wlr_subsurface *subsurface) {
static void subsurface_role_commit(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface);
- if (subsurface == NULL) {
- return;
- }
subsurface_consider_map(subsurface, true);
}
@@ -255,9 +252,6 @@ static void subsurface_role_precommit(struct wlr_surface *surface,
const struct wlr_surface_state *state) {
struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface);
- if (subsurface == NULL) {
- return;
- }
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
// This is a NULL commit
@@ -268,9 +262,6 @@ static void subsurface_role_precommit(struct wlr_surface *surface,
static void subsurface_role_destroy(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface);
- if (subsurface == NULL) {
- return;
- }
if (subsurface->has_cache) {
wlr_surface_unlock_cached(subsurface->surface,
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index b643f21c..a03b90a1 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -285,9 +285,6 @@ static void xdg_surface_handle_surface_commit(struct wl_listener *listener,
void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
struct wlr_xdg_surface *surface =
wlr_xdg_surface_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
surface->current = surface->pending;
@@ -319,9 +316,6 @@ void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state) {
struct wlr_xdg_surface *surface =
wlr_xdg_surface_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
// This is a NULL commit
@@ -334,9 +328,6 @@ void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
void xdg_surface_role_destroy(struct wlr_surface *wlr_surface) {
struct wlr_xdg_surface *surface =
wlr_xdg_surface_from_wlr_surface(wlr_surface);
- if (surface == NULL) {
- return;
- }
reset_xdg_surface(surface);
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 8f4c0ebb..3a3d35f2 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -824,9 +824,6 @@ static void read_surface_property(struct wlr_xwm *xwm,
static void xwayland_surface_role_commit(struct wlr_surface *wlr_surface) {
assert(wlr_surface->role == &xwayland_surface_role);
struct wlr_xwayland_surface *surface = wlr_surface->role_data;
- if (surface == NULL) {
- return;
- }
if (!surface->mapped && wlr_surface_has_buffer(surface->surface)) {
surface->mapped = true;
@@ -839,9 +836,6 @@ static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state) {
assert(wlr_surface->role == &xwayland_surface_role);
struct wlr_xwayland_surface *surface = wlr_surface->role_data;
- if (surface == NULL) {
- return;
- }
if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
// This is a NULL commit
@@ -856,9 +850,6 @@ static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface,
static void xwayland_surface_role_destroy(struct wlr_surface *wlr_surface) {
assert(wlr_surface->role == &xwayland_surface_role);
struct wlr_xwayland_surface *surface = wlr_surface->role_data;
- if (surface == NULL) {
- return;
- }
if (surface->mapped) {
wl_signal_emit_mutable(&surface->events.unmap, surface);