Suppport output transforms

This commit is contained in:
Jente Hidskes 2019-01-20 14:11:52 +01:00
parent 7379226bbe
commit 8db6b82c59
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
3 changed files with 22 additions and 7 deletions

View file

@ -113,7 +113,7 @@ handle_output_frame(struct wl_listener *listener, void *data)
clock_gettime(CLOCK_MONOTONIC, &now);
int width, height;
wlr_output_effective_resolution(output->wlr_output, &width, &height);
wlr_output_transformed_resolution(output->wlr_output, &width, &height);
wlr_renderer_begin(renderer, width, height);
@ -151,6 +151,17 @@ handle_output_frame(struct wl_listener *listener, void *data)
wlr_output_swap_buffers(output->wlr_output, NULL, NULL);
}
static void
handle_output_transform(struct wl_listener *listener, void *data)
{
struct cg_output *output = wl_container_of(listener, output, transform);
struct cg_view *view;
wl_list_for_each(view, &output->server->views, link) {
view_position(view);
}
}
static void
handle_output_mode(struct wl_listener *listener, void *data)
{
@ -165,12 +176,13 @@ handle_output_mode(struct wl_listener *listener, void *data)
static void
handle_output_destroy(struct wl_listener *listener, void *data)
{
struct cg_output *output = wl_container_of(listener, output, destroy);
struct cg_output *output = wl_container_of(listener, output, destroy);
struct cg_server *server = output->server;
wl_list_remove(&output->destroy.link);
wl_list_remove(&output->frame.link);
free(output);
wl_list_remove(&output->destroy.link);
wl_list_remove(&output->transform.link);
wl_list_remove(&output->frame.link);
free(output);
server->output = NULL;
/* Since there is no use in continuing without our (single)
@ -201,6 +213,8 @@ handle_new_output(struct wl_listener *listener, void *data)
wl_signal_add(&wlr_output->events.frame, &server->output->frame);
server->output->mode.notify = handle_output_mode;
wl_signal_add(&wlr_output->events.mode, &server->output->mode);
server->output->transform.notify = handle_output_transform;
wl_signal_add(&wlr_output->events.transform, &server->output->transform);
server->output->destroy.notify = handle_output_destroy;
wl_signal_add(&wlr_output->events.destroy, &server->output->destroy);

View file

@ -12,6 +12,7 @@ struct cg_output {
struct wl_listener frame;
struct wl_listener mode;
struct wl_listener transform;
struct wl_listener destroy;
};

4
view.c
View file

@ -40,7 +40,7 @@ view_maximize(struct cg_view *view)
struct cg_output *output = view->server->output;
int output_width, output_height;
wlr_output_effective_resolution(output->wlr_output, &output_width, &output_height);
wlr_output_transformed_resolution(output->wlr_output, &output_width, &output_height);
view->maximize(view, output_width, output_height);
}
@ -50,7 +50,7 @@ view_center(struct cg_view *view)
struct wlr_output *output = view->server->output->wlr_output;
int output_width, output_height;
wlr_output_effective_resolution(output, &output_width, &output_height);
wlr_output_transformed_resolution(output, &output_width, &output_height);
int width, height;
view->get_geometry(view, &width, &height);