Fix cursor on transformed output with DRM backend

This commit is contained in:
emersion 2017-12-26 18:16:37 +01:00
parent 4d744aeb23
commit e737f65e38
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 24 additions and 9 deletions

View File

@ -543,10 +543,11 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
// OpenGL will read the pixels out upside down, // OpenGL will read the pixels out upside down,
// so we need to flip the image vertically // so we need to flip the image vertically
enum wl_output_transform transform = wlr_output_transform_compose(
wlr_output_transform_invert(output->transform),
WL_OUTPUT_TRANSFORM_FLIPPED_180);
wlr_matrix_texture(plane->matrix, plane->surf.width, plane->surf.height, wlr_matrix_texture(plane->matrix, plane->surf.width, plane->surf.height,
conn->output.transform ^ WL_OUTPUT_TRANSFORM_FLIPPED_180); transform);
// TODO the image needs to be rotated depending on the output rotation
plane->wlr_tex = plane->wlr_tex =
wlr_render_texture_create(plane->surf.renderer->wlr_rend); wlr_render_texture_create(plane->surf.renderer->wlr_rend);

View File

@ -118,6 +118,9 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y); double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
enum wl_output_transform wlr_output_transform_invert(enum wl_output_transform); enum wl_output_transform wlr_output_transform_invert(
enum wl_output_transform tr);
enum wl_output_transform wlr_output_transform_compose(
enum wl_output_transform tr_a, enum wl_output_transform tr_b);
#endif #endif

View File

@ -726,11 +726,22 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
free(cursor); free(cursor);
} }
enum wl_output_transform wlr_output_transform_invert( enum wl_output_transform wlr_output_transform_invert(
enum wl_output_transform transform) { enum wl_output_transform tr) {
if ((transform & WL_OUTPUT_TRANSFORM_90) && if ((tr & WL_OUTPUT_TRANSFORM_90) && !(tr & WL_OUTPUT_TRANSFORM_FLIPPED)) {
!(transform & WL_OUTPUT_TRANSFORM_FLIPPED)) { tr ^= WL_OUTPUT_TRANSFORM_180;
transform ^= WL_OUTPUT_TRANSFORM_180;
} }
return transform; return tr;
}
enum wl_output_transform wlr_output_transform_compose(
enum wl_output_transform tr_a, enum wl_output_transform tr_b) {
uint32_t flipped = (tr_a ^ tr_b) & WL_OUTPUT_TRANSFORM_FLIPPED;
uint32_t rotated =
(tr_a + tr_b) & (WL_OUTPUT_TRANSFORM_90 | WL_OUTPUT_TRANSFORM_180);
if ((tr_a & WL_OUTPUT_TRANSFORM_FLIPPED) && (tr_b & WL_OUTPUT_TRANSFORM_FLIPPED)) {
rotated = wlr_output_transform_invert(rotated);
}
return flipped | rotated;
} }