diff --git a/include/output.h b/include/output.h index 0bab5db..20b8d1b 100644 --- a/include/output.h +++ b/include/output.h @@ -16,9 +16,9 @@ #pragma once -#include #include #include +#include struct zxdg_output_v1; @@ -41,6 +41,14 @@ struct output { char model[256]; char name[256]; char description[256]; + + bool is_dimension_changed; + bool is_transform_changed; + + void (*on_dimension_change)(struct output*); + void (*on_transform_change)(struct output*); + + void* userdata; }; struct output* output_new(struct wl_output* wl_output, uint32_t id); diff --git a/src/output.c b/src/output.c index 72c88cb..bccf4b5 100644 --- a/src/output.c +++ b/src/output.c @@ -123,6 +123,9 @@ static void output_handle_geometry(void* data, struct wl_output* wl_output, { struct output* output = data; + if (transform != (int32_t)output->transform) + output->is_transform_changed = true; + output->x = x; output->y = y; output->transform = transform; @@ -140,12 +143,25 @@ static void output_handle_mode(void* data, struct wl_output* wl_output, if (!(flags & WL_OUTPUT_MODE_CURRENT)) return; + if (width != (int32_t)output->width || height != (int32_t)output->height) + output->is_dimension_changed = true; + output->width = width; output->height = height; } static void output_handle_done(void* data, struct wl_output* wl_output) { + struct output* output = data; + + if (output->is_dimension_changed && output->on_dimension_change) + output->on_dimension_change(output); + + if (output->is_transform_changed && output->on_transform_change) + output->on_transform_change(output); + + output->is_dimension_changed = false; + output->is_transform_changed = false; } static void output_handle_scale(void* data, struct wl_output* wl_output,