aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/atomic.c2
-rw-r--r--backend/drm/drm.c11
-rw-r--r--backend/drm/legacy.c2
-rw-r--r--include/backend/drm/drm.h1
4 files changed, 14 insertions, 2 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index 22d8e69b..be6cfa3e 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -219,7 +219,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
}
set_plane_props(&atom, drm, crtc->primary, crtc->id, 0, 0);
if (crtc->cursor) {
- if (crtc->cursor->cursor_enabled) {
+ if (drm_connector_is_cursor_visible(conn)) {
set_plane_props(&atom, drm, crtc->cursor, crtc->id,
conn->cursor_x, conn->cursor_y);
} else {
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index b13d048d..8dc83cd3 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -999,6 +999,17 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
return true;
}
+bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn) {
+ assert(conn->crtc != NULL && conn->crtc->cursor != NULL);
+ struct wlr_drm_plane *plane = conn->crtc->cursor;
+
+ return plane->cursor_enabled &&
+ conn->cursor_x < conn->output.width &&
+ conn->cursor_y < conn->output.height &&
+ conn->cursor_x + (int)plane->surf.width >= 0 &&
+ conn->cursor_y + (int)plane->surf.height >= 0;
+}
+
static void drm_connector_destroy(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
drm_connector_cleanup(conn);
diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c
index 61309475..6acb87d4 100644
--- a/backend/drm/legacy.c
+++ b/backend/drm/legacy.c
@@ -62,7 +62,7 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
}
}
- if (cursor != NULL && cursor->cursor_enabled) {
+ if (cursor != NULL && drm_connector_is_cursor_visible(conn)) {
struct wlr_drm_fb *cursor_fb = plane_get_next_fb(cursor);
struct gbm_bo *cursor_bo =
drm_fb_acquire(cursor_fb, drm, &cursor->mgpu_surf);
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 7755da59..83fb6293 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -152,6 +152,7 @@ void scan_drm_connectors(struct wlr_drm_backend *state);
int handle_drm_event(int fd, uint32_t mask, void *data);
bool drm_connector_set_mode(struct wlr_drm_connector *conn,
struct wlr_output_mode *mode);
+bool drm_connector_is_cursor_visible(struct wlr_drm_connector *conn);
size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc);