aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/drm.c5
-rw-r--r--backend/wayland/wl_seat.c5
-rw-r--r--include/wlr/interfaces/wlr_output.h4
-rw-r--r--include/wlr/types/wlr_box.h4
-rw-r--r--render/matrix.c28
-rw-r--r--types/wlr_box.c47
-rw-r--r--types/wlr_output.c46
7 files changed, 69 insertions, 70 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index dd247998..cf6ad550 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -569,8 +569,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
enum wl_output_transform transform =
wlr_output_transform_invert(output->transform);
struct wlr_box transformed_hotspot;
- wlr_output_transform_apply_to_box(transform, &hotspot,
- &transformed_hotspot);
+ wlr_box_transform(&hotspot, transform, &transformed_hotspot);
plane->cursor_hotspot_x = transformed_hotspot.x;
plane->cursor_hotspot_y = transformed_hotspot.y;
@@ -632,7 +631,7 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
enum wl_output_transform transform =
wlr_output_transform_invert(output->transform);
struct wlr_box transformed_box;
- wlr_output_transform_apply_to_box(transform, &box, &transformed_box);
+ wlr_box_transform(&box, transform, &transformed_box);
transformed_box.x -= plane->cursor_hotspot_x;
transformed_box.y -= plane->cursor_hotspot_y;
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index a2da8df5..77c46164 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -55,9 +55,8 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
box.x = wl_fixed_to_int(surface_x);
box.y = wl_fixed_to_int(surface_y);
struct wlr_box transformed;
- wlr_output_transform_apply_to_box(
- wlr_wl_pointer->current_output->wlr_output.transform, &box,
- &transformed);
+ wlr_box_transform(&box,
+ wlr_wl_pointer->current_output->wlr_output.transform, &transformed);
struct wlr_event_pointer_motion_absolute wlr_event;
wlr_event.device = dev;
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index b4f39d35..8fbb650a 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -32,8 +32,4 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
struct wl_display *display);
void wlr_output_destroy_global(struct wlr_output *wlr_output);
-void wlr_output_transform_apply_to_box(enum wl_output_transform transform,
- struct wlr_box *box, struct wlr_box *dest);
-enum wl_output_transform wlr_output_transform_invert(enum wl_output_transform);
-
#endif
diff --git a/include/wlr/types/wlr_box.h b/include/wlr/types/wlr_box.h
index 5b8b00c9..5290ada5 100644
--- a/include/wlr/types/wlr_box.h
+++ b/include/wlr/types/wlr_box.h
@@ -18,4 +18,8 @@ bool wlr_box_contains_point(struct wlr_box *box, double x, double y);
bool wlr_box_empty(struct wlr_box *box);
+enum wl_output_transform;
+void wlr_box_transform(struct wlr_box *box, enum wl_output_transform transform,
+ struct wlr_box *dest);
+
#endif
diff --git a/render/matrix.c b/render/matrix.c
index 8a3352e0..6118e6a5 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -86,35 +86,35 @@ void wlr_matrix_mul(const float (*x)[16], const float (*y)[16], float (*product)
static const float transforms[][4] = {
[WL_OUTPUT_TRANSFORM_NORMAL] = {
1.0f, 0.0f,
- 0.0f, -1.0f,
+ 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_90] = {
0.0f, -1.0f,
- -1.0f, 0.0f,
+ 1.0f, 0.0f,
},
[WL_OUTPUT_TRANSFORM_180] = {
-1.0f, 0.0f,
- 0.0f, 1.0f,
+ 0.0f, -1.0f,
},
[WL_OUTPUT_TRANSFORM_270] = {
0.0f, 1.0f,
- 1.0f, 0.0f,
+ -1.0f, 0.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED] = {
-1.0f, 0.0f,
- 0.0f, -1.0f,
+ 0.0f, 1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_90] = {
0.0f, 1.0f,
- -1.0f, 0.0f,
+ 1.0f, 0.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_180] = {
1.0f, 0.0f,
- 0.0f, 1.0f,
+ 0.0f, -1.0f,
},
[WL_OUTPUT_TRANSFORM_FLIPPED_270] = {
0.0f, -1.0f,
- 1.0f, 0.0f,
+ -1.0f, 0.0f,
},
};
@@ -124,11 +124,11 @@ void wlr_matrix_transform(float mat[static 16],
const float *t = transforms[transform];
- // Rotation + relection
+ // Rotation + reflection
mat[0] = t[0];
mat[1] = t[1];
- mat[4] = -t[2];
- mat[5] = -t[3];
+ mat[4] = t[2];
+ mat[5] = t[3];
// Identity
mat[10] = 1.0f;
@@ -144,11 +144,11 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
float x = 2.0f / width;
float y = 2.0f / height;
- // Rotation + relection
+ // Rotation + reflection
mat[0] = x * t[0];
mat[1] = x * t[1];
- mat[4] = y * t[2];
- mat[5] = y * t[3];
+ mat[4] = y * -t[2];
+ mat[5] = y * -t[3];
// Translation
mat[3] = -copysign(1.0f, mat[0] + mat[1]);
diff --git a/types/wlr_box.c b/types/wlr_box.c
index 7e981833..88f4b8ab 100644
--- a/types/wlr_box.c
+++ b/types/wlr_box.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
+#include <wayland-server-protocol.h>
#include <wlr/types/wlr_box.h>
#include <wlr/util/log.h>
@@ -65,3 +66,49 @@ bool wlr_box_contains_point(struct wlr_box *box, double x, double y) {
y >= box->y && y <= box->y + box->height;
}
}
+
+void wlr_box_transform(struct wlr_box *box,
+ enum wl_output_transform transform, struct wlr_box *dest) {
+ if (transform % 2 == 0) {
+ dest->width = box->width;
+ dest->height = box->height;
+ } else {
+ dest->width = box->height;
+ dest->height = box->width;
+ }
+
+ switch (transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ dest->x = box->x;
+ dest->y = box->y;
+ break;
+ case WL_OUTPUT_TRANSFORM_90:
+ dest->x = box->y;
+ dest->y = box->width - box->x;
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ dest->x = box->width - box->x;
+ dest->y = box->height - box->y;
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ dest->x = box->height - box->y;
+ dest->y = box->x;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ dest->x = box->width - box->x;
+ dest->y = box->y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+ dest->x = box->y;
+ dest->y = box->x;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ dest->x = box->x;
+ dest->y = box->height - box->y;
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ dest->x = box->height - box->y;
+ dest->y = box->width - box->x;
+ break;
+ }
+}
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 21d94cfb..aad7dfec 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -626,52 +626,6 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
free(cursor);
}
-void wlr_output_transform_apply_to_box(enum wl_output_transform transform,
- struct wlr_box *box, struct wlr_box *dest) {
- if (transform % 2 == 0) {
- dest->width = box->width;
- dest->height = box->height;
- } else {
- dest->width = box->height;
- dest->height = box->width;
- }
-
- switch (transform) {
- case WL_OUTPUT_TRANSFORM_NORMAL:
- dest->x = box->x;
- dest->y = box->y;
- break;
- case WL_OUTPUT_TRANSFORM_90:
- dest->x = box->y;
- dest->y = box->width - box->x;
- break;
- case WL_OUTPUT_TRANSFORM_180:
- dest->x = box->width - box->x;
- dest->y = box->height - box->y;
- break;
- case WL_OUTPUT_TRANSFORM_270:
- dest->x = box->height - box->y;
- dest->y = box->x;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED:
- dest->x = box->width - box->x;
- dest->y = box->y;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_90:
- dest->x = box->y;
- dest->y = box->x;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_180:
- dest->x = box->x;
- dest->y = box->height - box->y;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- dest->x = box->height - box->y;
- dest->y = box->width - box->x;
- break;
- }
-}
-
enum wl_output_transform wlr_output_transform_invert(
enum wl_output_transform transform) {
if ((transform & WL_OUTPUT_TRANSFORM_90) &&