diff options
author | emersion <contact@emersion.fr> | 2017-12-13 15:52:18 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-12-13 15:52:18 +0100 |
commit | a4619e98c462690f14baf5c0c72c25553e3c6d51 (patch) | |
tree | d5b8341824d7bcc882343f2173c55d23b330346f /sway/desktop/output.c | |
parent | Update output container box in event handler (diff) | |
download | sway-a4619e98c462690f14baf5c0c72c25553e3c6d51.tar.gz sway-a4619e98c462690f14baf5c0c72c25553e3c6d51.tar.zst sway-a4619e98c462690f14baf5c0c72c25553e3c6d51.zip |
Update output containers on output layout change
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 47 |
1 files changed, 5 insertions, 42 deletions
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) { |