diff --git a/include/output.h b/include/output.h index 4fd3374..05ce095 100644 --- a/include/output.h +++ b/include/output.h @@ -51,3 +51,6 @@ void output_list_destroy(struct wl_list* list); struct output* output_find_by_id(struct wl_list* list, uint32_t id); struct output* output_find_by_name(struct wl_list* list, const char* name); struct output* output_first(struct wl_list* list); + +uint32_t output_get_transformed_width(const struct output* self); +uint32_t output_get_transformed_height(const struct output* self); diff --git a/src/output.c b/src/output.c index d50efd6..317b224 100644 --- a/src/output.c +++ b/src/output.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,33 @@ #include "xdg-output-unstable-v1.h" +static bool is_transform_90_degrees(enum wl_output_transform transform) +{ + switch (transform) { + case WL_OUTPUT_TRANSFORM_90: + case WL_OUTPUT_TRANSFORM_270: + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + return true; + default: + break; + } + + return false; +} + +uint32_t output_get_transformed_width(const struct output* self) +{ + return is_transform_90_degrees(self->transform) + ? self->height : self->width; +} + +uint32_t output_get_transformed_height(const struct output* self) +{ + return is_transform_90_degrees(self->transform) + ? self->width : self->height; +} + static void output_handle_geometry(void* data, struct wl_output* wl_output, int32_t x, int32_t y, int32_t phys_width, int32_t phys_height, int32_t subpixel,