aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/output.h8
-rw-r--r--sway/config/output.c2
-rw-r--r--sway/desktop/output.c30
3 files changed, 38 insertions, 2 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index 895cb07d..11869398 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -12,8 +12,16 @@ struct sway_output {
12 struct sway_container *swayc; 12 struct sway_container *swayc;
13 struct sway_server *server; 13 struct sway_server *server;
14 struct timespec last_frame; 14 struct timespec last_frame;
15
16 struct {
17 struct wl_signal scale;
18 struct wl_signal transform;
19 } events;
20
15 struct wl_listener frame; 21 struct wl_listener frame;
16 struct wl_listener resolution; 22 struct wl_listener resolution;
23 struct wl_listener scale;
24 struct wl_listener transform;
17}; 25};
18 26
19#endif 27#endif
diff --git a/sway/config/output.c b/sway/config/output.c
index e6e680d3..b06c7c0e 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -112,10 +112,12 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
112 if (oc && oc->scale > 0) { 112 if (oc && oc->scale > 0) {
113 sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale); 113 sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
114 wlr_output_set_scale(wlr_output, oc->scale); 114 wlr_output_set_scale(wlr_output, oc->scale);
115 wl_signal_emit(&output->sway_output->events.scale, output->sway_output);
115 } 116 }
116 if (oc && oc->transform >= 0) { 117 if (oc && oc->transform >= 0) {
117 sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform); 118 sway_log(L_DEBUG, "Set %s transform to %d", oc->name, oc->transform);
118 wlr_output_transform(wlr_output, oc->transform); 119 wlr_output_transform(wlr_output, oc->transform);
120 wl_signal_emit(&output->sway_output->events.transform, output->sway_output);
119 } 121 }
120 122
121 // Find position for it 123 // Find position for it
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 7eb48bdf..f44cda1a 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -98,17 +98,40 @@ static void output_resolution_notify(struct wl_listener *listener, void *data) {
98 arrange_windows(soutput->swayc, -1, -1); 98 arrange_windows(soutput->swayc, -1, -1);
99} 99}
100 100
101static void output_scale_notify(struct wl_listener *listener, void *data) {
102 struct sway_output *soutput = wl_container_of(
103 listener, soutput, scale);
104 arrange_windows(soutput->swayc, -1, -1);
105}
106
107static void output_transform_notify(struct wl_listener *listener, void *data) {
108 struct sway_output *soutput = wl_container_of(
109 listener, soutput, transform);
110 arrange_windows(soutput->swayc, -1, -1);
111}
112
101void output_add_notify(struct wl_listener *listener, void *data) { 113void output_add_notify(struct wl_listener *listener, void *data) {
102 struct sway_server *server = wl_container_of(listener, server, output_add); 114 struct sway_server *server = wl_container_of(listener, server, output_add);
103 struct wlr_output *wlr_output = data; 115 struct wlr_output *wlr_output = data;
104 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name); 116 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
105 117
106 struct sway_output *output = calloc(1, sizeof(struct sway_output)); 118 struct sway_output *output = calloc(1, sizeof(struct sway_output));
119 if (!output) {
120 return;
121 }
107 output->wlr_output = wlr_output; 122 output->wlr_output = wlr_output;
108 output->server = server; 123 output->server = server;
124
125 wl_signal_init(&output->events.scale);
126 wl_signal_init(&output->events.transform);
127
109 output->swayc = new_output(output); 128 output->swayc = new_output(output);
129 if (!output->swayc) {
130 free(output);
131 return;
132 }
110 133
111 if (wl_list_length(&wlr_output->modes) > 0) { 134 if (!wl_list_empty(&wlr_output->modes)) {
112 struct wlr_output_mode *mode = NULL; 135 struct wlr_output_mode *mode = NULL;
113 mode = wl_container_of((&wlr_output->modes)->prev, mode, link); 136 mode = wl_container_of((&wlr_output->modes)->prev, mode, link);
114 wlr_output_set_mode(wlr_output, mode); 137 wlr_output_set_mode(wlr_output, mode);
@@ -116,9 +139,12 @@ void output_add_notify(struct wl_listener *listener, void *data) {
116 139
117 output->frame.notify = output_frame_notify; 140 output->frame.notify = output_frame_notify;
118 wl_signal_add(&wlr_output->events.frame, &output->frame); 141 wl_signal_add(&wlr_output->events.frame, &output->frame);
119
120 output->resolution.notify = output_resolution_notify; 142 output->resolution.notify = output_resolution_notify;
121 wl_signal_add(&wlr_output->events.resolution, &output->resolution); 143 wl_signal_add(&wlr_output->events.resolution, &output->resolution);
144 output->scale.notify = output_scale_notify;
145 wl_signal_add(&output->events.scale, &output->scale);
146 output->transform.notify = output_transform_notify;
147 wl_signal_add(&output->events.transform, &output->transform);
122 148
123 arrange_windows(output->swayc, -1, -1); 149 arrange_windows(output->swayc, -1, -1);
124} 150}