aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_compositor.h12
-rw-r--r--types/data_device/wlr_drag.c1
-rw-r--r--types/seat/wlr_seat_pointer.c1
-rw-r--r--types/tablet_v2/wlr_tablet_v2_tool.c1
-rw-r--r--types/wlr_compositor.c4
5 files changed, 18 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 649f5ab3..6a8bebdd 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -74,7 +74,15 @@ struct wlr_surface_state {
struct wlr_surface_role {
const char *name;
/**
+ * If true, the role isn't represented by any object.
+ * For example, this applies to cursor surfaces.
+ */
+ bool no_object;
+ /**
* Called when a new surface state is committed. May be NULL.
+ *
+ * If the role is represented by an object, this is only called if
+ * such object exists.
*/
void (*commit)(struct wlr_surface *surface);
/**
@@ -224,6 +232,10 @@ typedef void (*wlr_surface_iterator_func_t)(struct wlr_surface *surface,
/**
* Set the lifetime role for this surface. Returns true on success or false if
* the role cannot be set.
+ *
+ * If the role is represented by an object, role_data must be non-NULL.
+ * Alternatively, if the role isn't represented by any object, role_data must
+ * be NULL.
*/
bool wlr_surface_set_role(struct wlr_surface *surface,
const struct wlr_surface_role *role, void *role_data,
diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c
index 3e3f094e..5a417eaa 100644
--- a/types/data_device/wlr_drag.c
+++ b/types/data_device/wlr_drag.c
@@ -365,6 +365,7 @@ static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
const struct wlr_surface_role drag_icon_surface_role = {
.name = "wl_data_device-icon",
+ .no_object = true,
.commit = drag_icon_surface_role_commit,
};
diff --git a/types/seat/wlr_seat_pointer.c b/types/seat/wlr_seat_pointer.c
index ab1bb830..5d623dbc 100644
--- a/types/seat/wlr_seat_pointer.c
+++ b/types/seat/wlr_seat_pointer.c
@@ -79,6 +79,7 @@ static void pointer_cursor_surface_handle_commit(struct wlr_surface *surface) {
static const struct wlr_surface_role pointer_cursor_surface_role = {
.name = "wl_pointer-cursor",
+ .no_object = true,
.commit = pointer_cursor_surface_handle_commit,
};
diff --git a/types/tablet_v2/wlr_tablet_v2_tool.c b/types/tablet_v2/wlr_tablet_v2_tool.c
index dffa64a4..96ce8f42 100644
--- a/types/tablet_v2/wlr_tablet_v2_tool.c
+++ b/types/tablet_v2/wlr_tablet_v2_tool.c
@@ -25,6 +25,7 @@ static void tablet_tool_cursor_surface_handle_commit(struct wlr_surface *surface
static const struct wlr_surface_role tablet_tool_cursor_surface_role = {
.name = "wp_tablet_tool-cursor",
+ .no_object = true,
.commit = tablet_tool_cursor_surface_handle_commit,
};
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 9ef57cf8..d22d9c2c 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -491,7 +491,8 @@ static void surface_commit_state(struct wlr_surface *surface,
surface->pending.seq++;
}
- if (surface->role_data != NULL && surface->role->commit != NULL) {
+ if (surface->role != NULL && surface->role->commit != NULL &&
+ (surface->role_data != NULL || surface->role->no_object)) {
surface->role->commit(surface);
}
@@ -768,6 +769,7 @@ bool wlr_surface_set_role(struct wlr_surface *surface,
const struct wlr_surface_role *role, void *role_data,
struct wl_resource *error_resource, uint32_t error_code) {
assert(role != NULL);
+ assert((role_data == NULL) == role->no_object);
if (surface->role != NULL && surface->role != role) {
if (error_resource != NULL) {