wlroots/types/wlr_output.c

42 lines
1.2 KiB
C
Raw Normal View History

2017-05-07 16:26:48 +00:00
#include <stdlib.h>
#include <wayland-server.h>
2017-05-31 20:24:32 +00:00
#include <wlr/types.h>
#include <wlr/common/list.h>
#include "types.h"
2017-05-07 16:26:48 +00:00
struct wlr_output *wlr_output_create(struct wlr_output_impl *impl,
struct wlr_output_state *state) {
struct wlr_output *output = calloc(1, sizeof(struct wlr_output));
output->impl = impl;
output->state = state;
output->modes = list_create();
output->transform = WL_OUTPUT_TRANSFORM_NORMAL;
2017-05-07 16:26:48 +00:00
wl_signal_init(&output->events.frame);
return output;
}
void wlr_output_enable(struct wlr_output *output, bool enable) {
output->impl->enable(output->state, enable);
}
bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) {
return output->impl->set_mode(output->state, mode);
}
void wlr_output_transform(struct wlr_output *output,
enum wl_output_transform transform) {
output->impl->transform(output->state, transform);
}
2017-05-31 20:17:04 +00:00
void wlr_output_destroy(struct wlr_output *output) {
2017-05-07 16:26:48 +00:00
if (!output) return;
2017-05-31 20:17:04 +00:00
output->impl->destroy(output->state);
2017-05-07 16:26:48 +00:00
if (output->make) free(output->make);
if (output->model) free(output->model);
for (size_t i = 0; output->modes && i < output->modes->length; ++i) {
free(output->modes->items[i]);
}
list_free(output->modes);
free(output);
}