Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
backend/drm: move cursor fields to wlr_drm_connector
Browse files Browse the repository at this point in the history
Doesn't make a lot of sense to split the cursor fields between
wlr_drm_plane and wlr_drm_connector. Let's just move everything to
wlr_drm_connector.
  • Loading branch information
emersion committed Apr 28, 2021
1 parent baab0f8 commit 352b062
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
37 changes: 16 additions & 21 deletions backend/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,18 +898,18 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return false;
}

if (plane->cursor_hotspot_x != hotspot_x ||
plane->cursor_hotspot_y != hotspot_y) {
if (conn->cursor_hotspot_x != hotspot_x ||
conn->cursor_hotspot_y != hotspot_y) {
// Update cursor hotspot
conn->cursor_x -= hotspot_x - plane->cursor_hotspot_x;
conn->cursor_y -= hotspot_y - plane->cursor_hotspot_y;
plane->cursor_hotspot_x = hotspot_x;
plane->cursor_hotspot_y = hotspot_y;
conn->cursor_x -= hotspot_x - conn->cursor_hotspot_x;
conn->cursor_y -= hotspot_y - conn->cursor_hotspot_y;
conn->cursor_hotspot_x = hotspot_x;
conn->cursor_hotspot_y = hotspot_y;

wlr_output_update_needs_frame(output);
}

plane->cursor_enabled = false;
conn->cursor_enabled = false;
if (buffer != NULL) {
if ((uint64_t)buffer->width != drm->cursor_width ||
(uint64_t)buffer->height != drm->cursor_height) {
Expand Down Expand Up @@ -947,9 +947,9 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return false;
}

plane->cursor_enabled = true;
plane->cursor_width = buffer->width;
plane->cursor_height = buffer->height;
conn->cursor_enabled = true;
conn->cursor_width = buffer->width;
conn->cursor_height = buffer->height;
}

wlr_output_update_needs_frame(output);
Expand All @@ -976,8 +976,8 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
wlr_output_transform_invert(output->transform);
wlr_box_transform(&box, &box, transform, width, height);

box.x -= plane->cursor_hotspot_x;
box.y -= plane->cursor_hotspot_y;
box.x -= conn->cursor_hotspot_x;
box.y -= conn->cursor_hotspot_y;

conn->cursor_x = box.x;
conn->cursor_y = box.y;
Expand All @@ -987,14 +987,11 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
}

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 &&
return conn->cursor_enabled &&
conn->cursor_x < conn->output.width &&
conn->cursor_y < conn->output.height &&
conn->cursor_x + plane->cursor_width >= 0 &&
conn->cursor_y + plane->cursor_height >= 0;
conn->cursor_x + conn->cursor_width >= 0 &&
conn->cursor_y + conn->cursor_height >= 0;
}

static void dealloc_crtc(struct wlr_drm_connector *conn);
Expand Down Expand Up @@ -1099,10 +1096,8 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {

drm_plane_finish_surface(conn->crtc->primary);
drm_plane_finish_surface(conn->crtc->cursor);
if (conn->crtc->cursor != NULL) {
conn->crtc->cursor->cursor_enabled = false;
}

conn->cursor_enabled = false;
conn->crtc = NULL;
}

Expand Down
10 changes: 4 additions & 6 deletions include/backend/drm/drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ struct wlr_drm_plane {

struct wlr_drm_format_set formats;

// Only used by cursor plane
bool cursor_enabled;
int cursor_width, cursor_height;
int cursor_hotspot_x, cursor_hotspot_y;

union wlr_drm_plane_props props;
};

Expand Down Expand Up @@ -131,7 +126,10 @@ struct wlr_drm_connector {

union wlr_drm_connector_props props;

int32_t cursor_x, cursor_y;
bool cursor_enabled;
int cursor_x, cursor_y;
int cursor_width, cursor_height;
int cursor_hotspot_x, cursor_hotspot_y;

drmModeCrtc *old_crtc;

Expand Down

0 comments on commit 352b062

Please sign in to comment.