Fix output rotation direction

The Wayland protocol specifies output transform rotations to be
counterclockwise and applied to the surface. Previously, wlroots
copied Weston and incorrectly made rotations act clockwise on
surfaces. This commit fixes that.

This change will break compositors which expect transform rotations
to be clockwise, and the rare applications that make use of surface
transforms.
This commit is contained in:
Manuel Stoeckl 2020-02-09 09:57:40 -05:00 committed by Drew DeVault
parent c5376c2d2c
commit f22a5d1704
4 changed files with 40 additions and 40 deletions

View File

@ -91,32 +91,32 @@ void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
dest->y = src.y;
break;
case WL_OUTPUT_TRANSFORM_90:
dest->x = src.y;
dest->y = width - src.x - src.width;
dest->x = height - src.y - src.height;
dest->y = src.x;
break;
case WL_OUTPUT_TRANSFORM_180:
dest->x = width - src.x - src.width;
dest->y = height - src.y - src.height;
break;
case WL_OUTPUT_TRANSFORM_270:
dest->x = height - src.y - src.height;
dest->y = src.x;
dest->x = src.y;
dest->y = width - src.x - src.width;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
dest->x = width - src.x - src.width;
dest->y = src.y;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
dest->x = height - src.y - src.height;
dest->y = width - src.x - src.width;
dest->x = src.y;
dest->y = src.x;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
dest->x = src.x;
dest->y = height - src.y - src.height;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
dest->x = src.y;
dest->y = src.x;
dest->x = height - src.y - src.height;
dest->y = width - src.x - src.width;
break;
}
}

View File

@ -366,32 +366,32 @@ static void apply_output_transform(double *x, double *y,
dy = *y;
break;
case WL_OUTPUT_TRANSFORM_90:
dx = *y;
dy = width - *x;
dx = height - *y;
dy = *x;
break;
case WL_OUTPUT_TRANSFORM_180:
dx = width - *x;
dy = height - *y;
break;
case WL_OUTPUT_TRANSFORM_270:
dx = height - *y;
dy = *x;
dx = *y;
dy = width - *x;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
dx = width - *x;
dy = *y;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
dx = height - *y;
dy = width - *x;
dx = *y;
dy = *x;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
dx = *x;
dy = height - *y;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
dx = *y;
dy = *x;
dx = height - *y;
dy = width - *x;
break;
}
*x = dx;

View File

@ -76,8 +76,8 @@ static const float transforms[][9] = {
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_90] = {
0.0f, -1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_180] = {
@ -86,8 +86,8 @@ static const float transforms[][9] = {
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_270] = {
0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED] = {
@ -96,8 +96,8 @@ static const float transforms[][9] = {
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_90] = {
0.0f, -1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_180] = {
@ -106,8 +106,8 @@ static const float transforms[][9] = {
0.0f, 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_270] = {
0.0f, 1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f,
},
};

View File

@ -56,10 +56,10 @@ void wlr_region_transform(pixman_region32_t *dst, pixman_region32_t *src,
dst_rects[i].y2 = src_rects[i].y2;
break;
case WL_OUTPUT_TRANSFORM_90:
dst_rects[i].x1 = src_rects[i].y1;
dst_rects[i].y1 = width - src_rects[i].x2;
dst_rects[i].x2 = src_rects[i].y2;
dst_rects[i].y2 = width - src_rects[i].x1;
dst_rects[i].x1 = height - src_rects[i].y2;
dst_rects[i].y1 = src_rects[i].x1;
dst_rects[i].x2 = height - src_rects[i].y1;
dst_rects[i].y2 = src_rects[i].x2;
break;
case WL_OUTPUT_TRANSFORM_180:
dst_rects[i].x1 = width - src_rects[i].x2;
@ -68,10 +68,10 @@ void wlr_region_transform(pixman_region32_t *dst, pixman_region32_t *src,
dst_rects[i].y2 = height - src_rects[i].y1;
break;
case WL_OUTPUT_TRANSFORM_270:
dst_rects[i].x1 = height - src_rects[i].y2;
dst_rects[i].y1 = src_rects[i].x1;
dst_rects[i].x2 = height - src_rects[i].y1;
dst_rects[i].y2 = src_rects[i].x2;
dst_rects[i].x1 = src_rects[i].y1;
dst_rects[i].y1 = width - src_rects[i].x2;
dst_rects[i].x2 = src_rects[i].y2;
dst_rects[i].y2 = width - src_rects[i].x1;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED:
dst_rects[i].x1 = width - src_rects[i].x2;
@ -80,10 +80,10 @@ void wlr_region_transform(pixman_region32_t *dst, pixman_region32_t *src,
dst_rects[i].y2 = src_rects[i].y2;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
dst_rects[i].x1 = height - src_rects[i].y2;
dst_rects[i].y1 = width - src_rects[i].x2;
dst_rects[i].x2 = height - src_rects[i].y1;
dst_rects[i].y2 = width - src_rects[i].x1;
dst_rects[i].x1 = src_rects[i].y1;
dst_rects[i].y1 = src_rects[i].x1;
dst_rects[i].x2 = src_rects[i].y2;
dst_rects[i].y2 = src_rects[i].x2;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
dst_rects[i].x1 = src_rects[i].x1;
@ -92,10 +92,10 @@ void wlr_region_transform(pixman_region32_t *dst, pixman_region32_t *src,
dst_rects[i].y2 = height - src_rects[i].y1;
break;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
dst_rects[i].x1 = src_rects[i].y1;
dst_rects[i].y1 = src_rects[i].x1;
dst_rects[i].x2 = src_rects[i].y2;
dst_rects[i].y2 = src_rects[i].x2;
dst_rects[i].x1 = height - src_rects[i].y2;
dst_rects[i].y1 = width - src_rects[i].x2;
dst_rects[i].x2 = height - src_rects[i].y1;
dst_rects[i].y2 = width - src_rects[i].x1;
break;
}
}