#include <stdlib.h>

#include "types/wlr_output.h"

void output_pending_resolution(struct wlr_output *output,
		const struct wlr_output_state *state, int *width, int *height) {
	if (state->committed & WLR_OUTPUT_STATE_MODE) {
		switch (state->mode_type) {
		case WLR_OUTPUT_STATE_MODE_FIXED:
			*width = state->mode->width;
			*height = state->mode->height;
			return;
		case WLR_OUTPUT_STATE_MODE_CUSTOM:
			*width = state->custom_mode.width;
			*height = state->custom_mode.height;
			return;
		}
		abort();
	} else {
		*width = output->width;
		*height = output->height;
	}
}

const struct wlr_output_image_description *output_pending_image_description(
		struct wlr_output *output, const struct wlr_output_state *state) {
	if (state->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) {
		return state->image_description;
	}
	return output->image_description;
}
