diff options
-rw-r--r-- | include/sway/output.h | 8 | ||||
-rw-r--r-- | sway/config/output.c | 5 | ||||
-rw-r--r-- | sway/desktop/output.c | 47 | ||||
-rw-r--r-- | sway/tree/layout.c | 20 |
4 files changed, 23 insertions, 57 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index 11869398..7ca02d7b 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -13,15 +13,7 @@ struct sway_output { | |||
13 | struct sway_server *server; | 13 | struct sway_server *server; |
14 | struct timespec last_frame; | 14 | struct timespec last_frame; |
15 | 15 | ||
16 | struct { | ||
17 | struct wl_signal scale; | ||
18 | struct wl_signal transform; | ||
19 | } events; | ||
20 | |||
21 | struct wl_listener frame; | 16 | struct wl_listener frame; |
22 | struct wl_listener resolution; | ||
23 | struct wl_listener scale; | ||
24 | struct wl_listener transform; | ||
25 | }; | 17 | }; |
26 | 18 | ||
27 | #endif | 19 | #endif |
diff --git a/sway/config/output.c b/sway/config/output.c index 6371763f..8d946386 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -113,13 +113,10 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { | |||
113 | if (oc && oc->scale > 0) { | 113 | if (oc && oc->scale > 0) { |
114 | sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale); | 114 | sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale); |
115 | wlr_output_set_scale(wlr_output, oc->scale); | 115 | wlr_output_set_scale(wlr_output, oc->scale); |
116 | wl_signal_emit(&output->sway_output->events.scale, output->sway_output); | ||
117 | } | 116 | } |
118 | if (oc && oc->transform >= 0) { | 117 | if (oc && oc->transform >= 0) { |
119 | 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); |
120 | wlr_output_transform(wlr_output, oc->transform); | 119 | wlr_output_set_transform(wlr_output, oc->transform); |
121 | wl_signal_emit(&output->sway_output->events.transform, | ||
122 | output->sway_output); | ||
123 | } | 120 | } |
124 | 121 | ||
125 | // Find position for it | 122 | // Find position for it |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 3fd49846..2177ad74 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -91,32 +91,6 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { | |||
91 | soutput->last_frame = now; | 91 | soutput->last_frame = now; |
92 | } | 92 | } |
93 | 93 | ||
94 | static void output_update_size(struct sway_output *output) { | ||
95 | struct wlr_box *output_layout_box = wlr_output_layout_get_box( | ||
96 | root_container.sway_root->output_layout, output->wlr_output); | ||
97 | output->swayc->x = output_layout_box->x; | ||
98 | output->swayc->y = output_layout_box->y; | ||
99 | output->swayc->width = output_layout_box->width; | ||
100 | output->swayc->height = output_layout_box->height; | ||
101 | |||
102 | arrange_windows(output->swayc, -1, -1); | ||
103 | } | ||
104 | |||
105 | static void output_resolution_notify(struct wl_listener *listener, void *data) { | ||
106 | struct sway_output *output = wl_container_of(listener, output, resolution); | ||
107 | output_update_size(output); | ||
108 | } | ||
109 | |||
110 | static void output_scale_notify(struct wl_listener *listener, void *data) { | ||
111 | struct sway_output *output = wl_container_of(listener, output, scale); | ||
112 | output_update_size(output); | ||
113 | } | ||
114 | |||
115 | static void output_transform_notify(struct wl_listener *listener, void *data) { | ||
116 | struct sway_output *output = wl_container_of(listener, output, transform); | ||
117 | output_update_size(output); | ||
118 | } | ||
119 | |||
120 | void output_add_notify(struct wl_listener *listener, void *data) { | 94 | void output_add_notify(struct wl_listener *listener, void *data) { |
121 | struct sway_server *server = wl_container_of(listener, server, output_add); | 95 | struct sway_server *server = wl_container_of(listener, server, output_add); |
122 | struct wlr_output *wlr_output = data; | 96 | struct wlr_output *wlr_output = data; |
@@ -129,8 +103,11 @@ void output_add_notify(struct wl_listener *listener, void *data) { | |||
129 | output->wlr_output = wlr_output; | 103 | output->wlr_output = wlr_output; |
130 | output->server = server; | 104 | output->server = server; |
131 | 105 | ||
132 | wl_signal_init(&output->events.scale); | 106 | if (!wl_list_empty(&wlr_output->modes)) { |
133 | wl_signal_init(&output->events.transform); | 107 | struct wlr_output_mode *mode = |
108 | wl_container_of(wlr_output->modes.prev, mode, link); | ||
109 | wlr_output_set_mode(wlr_output, mode); | ||
110 | } | ||
134 | 111 | ||
135 | output->swayc = new_output(output); | 112 | output->swayc = new_output(output); |
136 | if (!output->swayc) { | 113 | if (!output->swayc) { |
@@ -138,22 +115,8 @@ void output_add_notify(struct wl_listener *listener, void *data) { | |||
138 | return; | 115 | return; |
139 | } | 116 | } |
140 | 117 | ||
141 | if (!wl_list_empty(&wlr_output->modes)) { | ||
142 | struct wlr_output_mode *mode = NULL; | ||
143 | mode = wl_container_of((&wlr_output->modes)->prev, mode, link); | ||
144 | wlr_output_set_mode(wlr_output, mode); | ||
145 | } | ||
146 | |||
147 | output->frame.notify = output_frame_notify; | 118 | output->frame.notify = output_frame_notify; |
148 | wl_signal_add(&wlr_output->events.frame, &output->frame); | 119 | wl_signal_add(&wlr_output->events.frame, &output->frame); |
149 | output->resolution.notify = output_resolution_notify; | ||
150 | wl_signal_add(&wlr_output->events.resolution, &output->resolution); | ||
151 | output->scale.notify = output_scale_notify; | ||
152 | wl_signal_add(&output->events.scale, &output->scale); | ||
153 | output->transform.notify = output_transform_notify; | ||
154 | wl_signal_add(&output->events.transform, &output->transform); | ||
155 | |||
156 | arrange_windows(output->swayc, -1, -1); | ||
157 | } | 120 | } |
158 | 121 | ||
159 | void output_remove_notify(struct wl_listener *listener, void *data) { | 122 | void output_remove_notify(struct wl_listener *listener, void *data) { |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index fd17f8a5..65382231 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -16,10 +16,24 @@ | |||
16 | swayc_t root_container; | 16 | swayc_t root_container; |
17 | 17 | ||
18 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { | 18 | static void output_layout_change_notify(struct wl_listener *listener, void *data) { |
19 | struct wlr_box *box = wlr_output_layout_get_box( | 19 | struct wlr_box *layout_box = wlr_output_layout_get_box( |
20 | root_container.sway_root->output_layout, NULL); | 20 | root_container.sway_root->output_layout, NULL); |
21 | root_container.width = box->width; | 21 | root_container.width = layout_box->width; |
22 | root_container.height = box->height; | 22 | root_container.height = layout_box->height; |
23 | |||
24 | for (int i = 0 ; i < root_container.children->length; ++i) { | ||
25 | swayc_t *output_container = root_container.children->items[i]; | ||
26 | struct sway_output *output = output_container->sway_output; | ||
27 | |||
28 | struct wlr_box *output_box = wlr_output_layout_get_box( | ||
29 | root_container.sway_root->output_layout, output->wlr_output); | ||
30 | output_container->x = output_box->x; | ||
31 | output_container->y = output_box->y; | ||
32 | output_container->width = output_box->width; | ||
33 | output_container->height = output_box->height; | ||
34 | } | ||
35 | |||
36 | arrange_windows(&root_container, -1, -1); | ||
23 | } | 37 | } |
24 | 38 | ||
25 | void init_layout(void) { | 39 | void init_layout(void) { |