Add scale and transform events to sway_output
This commit is contained in:
parent
475a0132a9
commit
f3d880b0ec
|
@ -12,8 +12,16 @@ struct sway_output {
|
||||||
struct sway_container *swayc;
|
struct sway_container *swayc;
|
||||||
struct sway_server *server;
|
struct sway_server *server;
|
||||||
struct timespec last_frame;
|
struct timespec last_frame;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_signal scale;
|
||||||
|
struct wl_signal transform;
|
||||||
|
} events;
|
||||||
|
|
||||||
struct wl_listener frame;
|
struct wl_listener frame;
|
||||||
struct wl_listener resolution;
|
struct wl_listener resolution;
|
||||||
|
struct wl_listener scale;
|
||||||
|
struct wl_listener transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -112,10 +112,12 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
if (oc && oc->scale > 0) {
|
if (oc && oc->scale > 0) {
|
||||||
sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
|
sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
|
||||||
wlr_output_set_scale(wlr_output, oc->scale);
|
wlr_output_set_scale(wlr_output, oc->scale);
|
||||||
|
wl_signal_emit(&output->sway_output->events.scale, output->sway_output);
|
||||||
}
|
}
|
||||||
if (oc && oc->transform >= 0) {
|
if (oc && oc->transform >= 0) {
|
||||||
sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
|
sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
|
||||||
wlr_output_transform(wlr_output, oc->transform);
|
wlr_output_transform(wlr_output, oc->transform);
|
||||||
|
wl_signal_emit(&output->sway_output->events.transform, output->sway_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find position for it
|
// Find position for it
|
||||||
|
|
|
@ -98,17 +98,40 @@ static void output_resolution_notify(struct wl_listener *listener, void *data) {
|
||||||
arrange_windows(soutput->swayc, -1, -1);
|
arrange_windows(soutput->swayc, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void output_scale_notify(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_output *soutput = wl_container_of(
|
||||||
|
listener, soutput, scale);
|
||||||
|
arrange_windows(soutput->swayc, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void output_transform_notify(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_output *soutput = wl_container_of(
|
||||||
|
listener, soutput, transform);
|
||||||
|
arrange_windows(soutput->swayc, -1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
void output_add_notify(struct wl_listener *listener, void *data) {
|
void output_add_notify(struct wl_listener *listener, void *data) {
|
||||||
struct sway_server *server = wl_container_of(listener, server, output_add);
|
struct sway_server *server = wl_container_of(listener, server, output_add);
|
||||||
struct wlr_output *wlr_output = data;
|
struct wlr_output *wlr_output = data;
|
||||||
sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
|
||||||
|
|
||||||
struct sway_output *output = calloc(1, sizeof(struct sway_output));
|
struct sway_output *output = calloc(1, sizeof(struct sway_output));
|
||||||
|
if (!output) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
output->wlr_output = wlr_output;
|
output->wlr_output = wlr_output;
|
||||||
output->server = server;
|
output->server = server;
|
||||||
output->swayc = new_output(output);
|
|
||||||
|
|
||||||
if (wl_list_length(&wlr_output->modes) > 0) {
|
wl_signal_init(&output->events.scale);
|
||||||
|
wl_signal_init(&output->events.transform);
|
||||||
|
|
||||||
|
output->swayc = new_output(output);
|
||||||
|
if (!output->swayc) {
|
||||||
|
free(output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wl_list_empty(&wlr_output->modes)) {
|
||||||
struct wlr_output_mode *mode = NULL;
|
struct wlr_output_mode *mode = NULL;
|
||||||
mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
|
mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
|
||||||
wlr_output_set_mode(wlr_output, mode);
|
wlr_output_set_mode(wlr_output, mode);
|
||||||
|
@ -116,9 +139,12 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
output->frame.notify = output_frame_notify;
|
output->frame.notify = output_frame_notify;
|
||||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||||
|
|
||||||
output->resolution.notify = output_resolution_notify;
|
output->resolution.notify = output_resolution_notify;
|
||||||
wl_signal_add(&wlr_output->events.resolution, &output->resolution);
|
wl_signal_add(&wlr_output->events.resolution, &output->resolution);
|
||||||
|
output->scale.notify = output_scale_notify;
|
||||||
|
wl_signal_add(&output->events.scale, &output->scale);
|
||||||
|
output->transform.notify = output_transform_notify;
|
||||||
|
wl_signal_add(&output->events.transform, &output->transform);
|
||||||
|
|
||||||
arrange_windows(output->swayc, -1, -1);
|
arrange_windows(output->swayc, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue