output: Add functions to get transformed geometry

pull/20/head
Andri Yngvason 2020-03-05 20:19:13 +00:00
parent 35ffc2dac7
commit e01f75bfbd
2 changed files with 31 additions and 0 deletions

View File

@ -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);

View File

@ -18,6 +18,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <wayland-client-protocol.h>
#include <wayland-client.h>
@ -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,