Merge pull request #483 from emersion/dynamic-output-scale-transform

Update output layout when scale or transform changes
This commit is contained in:
Tony Crisci 2017-12-13 07:56:08 -05:00 committed by GitHub
commit 96f09c7492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 38 additions and 15 deletions

View File

@ -453,11 +453,7 @@ static bool wlr_drm_connector_set_mode(struct wlr_output *output,
conn->state = WLR_DRM_CONN_CONNECTED; conn->state = WLR_DRM_CONN_CONNECTED;
conn->output.current_mode = mode; conn->output.current_mode = mode;
if (conn->output.width != mode->width || conn->output.height != mode->height) { wlr_output_update_size(&conn->output, mode->width, mode->height);
conn->output.width = mode->width;
conn->output.height = mode->height;
wl_signal_emit(&conn->output.events.resolution, &conn->output);
}
// Since realloc_crtcs can deallocate planes on OTHER outputs, // Since realloc_crtcs can deallocate planes on OTHER outputs,
// we actually need to reinitalise any than has changed // we actually need to reinitalise any than has changed

View File

@ -33,7 +33,6 @@ static bool wlr_wl_output_set_custom_mode(struct wlr_output *_output,
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output; struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
wl_egl_window_resize(output->egl_window, width, height, 0, 0); wl_egl_window_resize(output->egl_window, width, height, 0, 0);
wlr_output_update_size(&output->wlr_output, width, height); wlr_output_update_size(&output->wlr_output, width, height);
wl_signal_emit(&output->wlr_output.events.resolution, output);
return true; return true;
} }
@ -228,7 +227,6 @@ static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *x
// loop over states for maximized etc? // loop over states for maximized etc?
wl_egl_window_resize(output->egl_window, width, height, 0, 0); wl_egl_window_resize(output->egl_window, width, height, 0, 0);
wlr_output_update_size(&output->wlr_output, width, height); wlr_output_update_size(&output->wlr_output, width, height);
wl_signal_emit(&output->wlr_output.events.resolution, output);
} }
static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel) { static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel) {

View File

@ -118,7 +118,6 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
xcb_configure_notify_event_t *ev = (xcb_configure_notify_event_t *)event; xcb_configure_notify_event_t *ev = (xcb_configure_notify_event_t *)event;
wlr_output_update_size(&output->wlr_output, ev->width, ev->height); wlr_output_update_size(&output->wlr_output, ev->width, ev->height);
wl_signal_emit(&output->wlr_output.events.resolution, output);
// Move the pointer to its new location // Move the pointer to its new location
xcb_query_pointer_cookie_t cookie = xcb_query_pointer_cookie_t cookie =

View File

@ -72,7 +72,7 @@ static void handle_output_add(struct output_state *ostate) {
example_config_get_output(sample->config, ostate->output); example_config_get_output(sample->config, ostate->output);
if (o_config) { if (o_config) {
wlr_output_transform(ostate->output, o_config->transform); wlr_output_set_transform(ostate->output, o_config->transform);
wlr_output_layout_add(sample->layout, ostate->output, o_config->x, wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
o_config->y); o_config->y);
} else { } else {

View File

@ -136,7 +136,7 @@ static void handle_output_add(struct output_state *ostate) {
example_config_get_output(sample->config, ostate->output); example_config_get_output(sample->config, ostate->output);
if (o_config) { if (o_config) {
wlr_output_transform(ostate->output, o_config->transform); wlr_output_set_transform(ostate->output, o_config->transform);
wlr_output_layout_add(sample->layout, ostate->output, o_config->x, wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
o_config->y); o_config->y);
} else { } else {

View File

@ -101,7 +101,7 @@ static void handle_output_add(struct output_state *ostate) {
example_config_get_output(sample->config, ostate->output); example_config_get_output(sample->config, ostate->output);
if (o_config) { if (o_config) {
wlr_output_transform(ostate->output, o_config->transform); wlr_output_set_transform(ostate->output, o_config->transform);
wlr_output_layout_add(sample->layout, ostate->output, o_config->x, wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
o_config->y); o_config->y);
} else { } else {

View File

@ -78,7 +78,7 @@ static void handle_output_add(struct output_state *output) {
struct output_config *conf; struct output_config *conf;
wl_list_for_each(conf, &state->config->outputs, link) { wl_list_for_each(conf, &state->config->outputs, link) {
if (strcmp(conf->name, output->output->name) == 0) { if (strcmp(conf->name, output->output->name) == 0) {
wlr_output_transform(output->output, conf->transform); wlr_output_set_transform(output->output, conf->transform);
break; break;
} }
} }

View File

@ -62,6 +62,8 @@ struct wlr_output {
struct wl_signal frame; struct wl_signal frame;
struct wl_signal swap_buffers; struct wl_signal swap_buffers;
struct wl_signal resolution; struct wl_signal resolution;
struct wl_signal scale;
struct wl_signal transform;
struct wl_signal destroy; struct wl_signal destroy;
} events; } events;
@ -85,7 +87,7 @@ bool wlr_output_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode); struct wlr_output_mode *mode);
bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width, bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh); int32_t height, int32_t refresh);
void wlr_output_transform(struct wlr_output *output, void wlr_output_set_transform(struct wlr_output *output,
enum wl_output_transform transform); enum wl_output_transform transform);
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly);
void wlr_output_set_scale(struct wlr_output *output, uint32_t scale); void wlr_output_set_scale(struct wlr_output *output, uint32_t scale);

View File

@ -321,7 +321,7 @@ void output_add_notify(struct wl_listener *listener, void *data) {
set_mode(wlr_output, output_config); set_mode(wlr_output, output_config);
} }
wlr_output_set_scale(wlr_output, output_config->scale); wlr_output_set_scale(wlr_output, output_config->scale);
wlr_output_transform(wlr_output, output_config->transform); wlr_output_set_transform(wlr_output, output_config->transform);
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x, wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
output_config->y); output_config->y);
} else { } else {

View File

@ -195,9 +195,11 @@ void wlr_output_update_size(struct wlr_output *output, int32_t width,
wl_resource_for_each(resource, &output->wl_resources) { wl_resource_for_each(resource, &output->wl_resources) {
wlr_output_send_current_mode_to_resource(resource); wlr_output_send_current_mode_to_resource(resource);
} }
wl_signal_emit(&output->events.resolution, output);
} }
void wlr_output_transform(struct wlr_output *output, void wlr_output_set_transform(struct wlr_output *output,
enum wl_output_transform transform) { enum wl_output_transform transform) {
output->impl->transform(output, transform); output->impl->transform(output, transform);
wlr_output_update_matrix(output); wlr_output_update_matrix(output);
@ -207,6 +209,8 @@ void wlr_output_transform(struct wlr_output *output,
wl_resource_for_each(resource, &output->wl_resources) { wl_resource_for_each(resource, &output->wl_resources) {
wl_output_send_to_resource(resource); wl_output_send_to_resource(resource);
} }
wl_signal_emit(&output->events.transform, output);
} }
void wlr_output_set_position(struct wlr_output *output, int32_t lx, void wlr_output_set_position(struct wlr_output *output, int32_t lx,
@ -237,6 +241,8 @@ void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) {
wl_resource_for_each(resource, &output->wl_resources) { wl_resource_for_each(resource, &output->wl_resources) {
wl_output_send_to_resource(resource); wl_output_send_to_resource(resource);
} }
wl_signal_emit(&output->events.scale, output);
} }
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
@ -252,6 +258,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
wl_signal_init(&output->events.frame); wl_signal_init(&output->events.frame);
wl_signal_init(&output->events.swap_buffers); wl_signal_init(&output->events.swap_buffers);
wl_signal_init(&output->events.resolution); wl_signal_init(&output->events.resolution);
wl_signal_init(&output->events.scale);
wl_signal_init(&output->events.transform);
wl_signal_init(&output->events.destroy); wl_signal_init(&output->events.destroy);
} }

View File

@ -19,6 +19,8 @@ struct wlr_output_layout_output_state {
bool auto_configured; bool auto_configured;
struct wl_listener resolution; struct wl_listener resolution;
struct wl_listener scale;
struct wl_listener transform;
struct wl_listener output_destroy; struct wl_listener output_destroy;
}; };
@ -46,6 +48,8 @@ static void wlr_output_layout_output_destroy(
struct wlr_output_layout_output *l_output) { struct wlr_output_layout_output *l_output) {
wl_signal_emit(&l_output->events.destroy, l_output); wl_signal_emit(&l_output->events.destroy, l_output);
wl_list_remove(&l_output->state->resolution.link); wl_list_remove(&l_output->state->resolution.link);
wl_list_remove(&l_output->state->scale.link);
wl_list_remove(&l_output->state->transform.link);
wl_list_remove(&l_output->state->output_destroy.link); wl_list_remove(&l_output->state->output_destroy.link);
wl_list_remove(&l_output->link); wl_list_remove(&l_output->link);
free(l_output->state); free(l_output->state);
@ -134,6 +138,18 @@ static void handle_output_resolution(struct wl_listener *listener, void *data) {
wlr_output_layout_reconfigure(state->layout); wlr_output_layout_reconfigure(state->layout);
} }
static void handle_output_scale(struct wl_listener *listener, void *data) {
struct wlr_output_layout_output_state *state =
wl_container_of(listener, state, scale);
wlr_output_layout_reconfigure(state->layout);
}
static void handle_output_transform(struct wl_listener *listener, void *data) {
struct wlr_output_layout_output_state *state =
wl_container_of(listener, state, transform);
wlr_output_layout_reconfigure(state->layout);
}
static void handle_output_destroy(struct wl_listener *listener, void *data) { static void handle_output_destroy(struct wl_listener *listener, void *data) {
struct wlr_output_layout_output_state *state = struct wlr_output_layout_output_state *state =
wl_container_of(listener, state, output_destroy); wl_container_of(listener, state, output_destroy);
@ -162,6 +178,10 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create(
wl_signal_add(&output->events.resolution, &l_output->state->resolution); wl_signal_add(&output->events.resolution, &l_output->state->resolution);
l_output->state->resolution.notify = handle_output_resolution; l_output->state->resolution.notify = handle_output_resolution;
wl_signal_add(&output->events.scale, &l_output->state->scale);
l_output->state->scale.notify = handle_output_scale;
wl_signal_add(&output->events.transform, &l_output->state->transform);
l_output->state->transform.notify = handle_output_transform;
wl_signal_add(&output->events.destroy, &l_output->state->output_destroy); wl_signal_add(&output->events.destroy, &l_output->state->output_destroy);
l_output->state->output_destroy.notify = handle_output_destroy; l_output->state->output_destroy.notify = handle_output_destroy;