aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-28 16:38:11 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-28 16:42:13 -0400
commit68cfa7ef6705c530ff28d9754c5b6cab7b429150 (patch)
tree0c25eb44f1285f2522b6a5f014276239cfa6ae3f /sway/desktop/output.c
parentAdd initial layer shell skeleton (diff)
downloadsway-68cfa7ef6705c530ff28d9754c5b6cab7b429150.tar.gz
sway-68cfa7ef6705c530ff28d9754c5b6cab7b429150.tar.zst
sway-68cfa7ef6705c530ff28d9754c5b6cab7b429150.zip
Render layer surfaces and respect exclusive zone
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index a9aa47a6..59f79a81 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -4,14 +4,17 @@
4#include <time.h> 4#include <time.h>
5#include <wayland-server.h> 5#include <wayland-server.h>
6#include <wlr/render/wlr_renderer.h> 6#include <wlr/render/wlr_renderer.h>
7#include <wlr/types/wlr_box.h>
7#include <wlr/types/wlr_matrix.h> 8#include <wlr/types/wlr_matrix.h>
8#include <wlr/types/wlr_output.h> 9#include <wlr/types/wlr_output.h>
10#include <wlr/types/wlr_output_layout.h>
9#include <wlr/types/wlr_surface.h> 11#include <wlr/types/wlr_surface.h>
10#include <wlr/types/wlr_wl_shell.h> 12#include <wlr/types/wlr_wl_shell.h>
11#include "log.h" 13#include "log.h"
12#include "sway/container.h" 14#include "sway/container.h"
13#include "sway/input/input-manager.h" 15#include "sway/input/input-manager.h"
14#include "sway/input/seat.h" 16#include "sway/input/seat.h"
17#include "sway/layers.h"
15#include "sway/layout.h" 18#include "sway/layout.h"
16#include "sway/output.h" 19#include "sway/output.h"
17#include "sway/server.h" 20#include "sway/server.h"
@@ -177,6 +180,20 @@ static void output_frame_view(swayc_t *view, void *data) {
177 } 180 }
178} 181}
179 182
183static void render_layer(struct sway_output *output,
184 const struct wlr_box *output_layout_box,
185 struct timespec *when,
186 struct wl_list *layer) {
187 struct sway_layer_surface *sway_layer;
188 wl_list_for_each(sway_layer, layer, link) {
189 struct wlr_layer_surface *layer = sway_layer->layer_surface;
190 render_surface(layer->surface, output->wlr_output, when,
191 sway_layer->geo.x + output_layout_box->x,
192 sway_layer->geo.y + output_layout_box->y, 0);
193 wlr_surface_send_frame_done(layer->surface, when);
194 }
195}
196
180static void output_frame_notify(struct wl_listener *listener, void *data) { 197static void output_frame_notify(struct wl_listener *listener, void *data) {
181 struct sway_output *soutput = wl_container_of(listener, soutput, frame); 198 struct sway_output *soutput = wl_container_of(listener, soutput, frame);
182 struct wlr_output *wlr_output = data; 199 struct wlr_output *wlr_output = data;
@@ -189,6 +206,18 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
189 wlr_output_make_current(wlr_output, &buffer_age); 206 wlr_output_make_current(wlr_output, &buffer_age);
190 wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height); 207 wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height);
191 208
209 struct timespec now;
210 clock_gettime(CLOCK_MONOTONIC, &now);
211
212 struct wlr_output_layout *layout = root_container.sway_root->output_layout;
213 const struct wlr_box *output_box = wlr_output_layout_get_box(
214 layout, wlr_output);
215
216 render_layer(soutput, output_box, &now,
217 &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]);
218 render_layer(soutput, output_box, &now,
219 &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
220
192 struct sway_seat *seat = input_manager_current_seat(input_manager); 221 struct sway_seat *seat = input_manager_current_seat(input_manager);
193 swayc_t *focus = sway_seat_get_focus_inactive(seat, soutput->swayc); 222 swayc_t *focus = sway_seat_get_focus_inactive(seat, soutput->swayc);
194 swayc_t *workspace = (focus->type == C_WORKSPACE ? 223 swayc_t *workspace = (focus->type == C_WORKSPACE ?
@@ -210,22 +239,32 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
210 } 239 }
211 } 240 }
212 241
242 // TODO: Consider revising this when fullscreen windows are supported
243 render_layer(soutput, output_box, &now,
244 &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]);
245 render_layer(soutput, output_box, &now,
246 &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
247
213 wlr_renderer_end(server->renderer); 248 wlr_renderer_end(server->renderer);
214 wlr_output_swap_buffers(wlr_output, &soutput->last_frame, NULL); 249 wlr_output_swap_buffers(wlr_output, &soutput->last_frame, NULL);
215 250
216 struct timespec now;
217 clock_gettime(CLOCK_MONOTONIC, &now);
218 soutput->last_frame = now; 251 soutput->last_frame = now;
219} 252}
220 253
221static void handle_output_destroy(struct wl_listener *listener, void *data) { 254static void handle_output_destroy(struct wl_listener *listener, void *data) {
222 struct sway_output *output = wl_container_of(listener, output, output_destroy); 255 struct sway_output *output = wl_container_of(listener, output, destroy);
223 struct wlr_output *wlr_output = data; 256 struct wlr_output *wlr_output = data;
224 wlr_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name); 257 wlr_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
225 258
226 destroy_output(output->swayc); 259 destroy_output(output->swayc);
227} 260}
228 261
262static void handle_output_mode(struct wl_listener *listener, void *data) {
263 struct sway_output *output = wl_container_of(listener, output, mode);
264 arrange_layers(output);
265 arrange_windows(output->swayc, -1, -1);
266}
267
229void handle_new_output(struct wl_listener *listener, void *data) { 268void handle_new_output(struct wl_listener *listener, void *data) {
230 struct sway_server *server = wl_container_of(listener, server, new_output); 269 struct sway_server *server = wl_container_of(listener, server, new_output);
231 struct wlr_output *wlr_output = data; 270 struct wlr_output *wlr_output = data;
@@ -260,9 +299,11 @@ void handle_new_output(struct wl_listener *listener, void *data) {
260 299
261 wl_signal_add(&wlr_output->events.frame, &output->frame); 300 wl_signal_add(&wlr_output->events.frame, &output->frame);
262 output->frame.notify = output_frame_notify; 301 output->frame.notify = output_frame_notify;
302 wl_signal_add(&wlr_output->events.destroy, &output->destroy);
303 output->destroy.notify = handle_output_destroy;
304 wl_signal_add(&wlr_output->events.mode, &output->mode);
305 output->mode.notify = handle_output_mode;
263 306
264 wl_signal_add(&wlr_output->events.destroy, &output->output_destroy); 307 arrange_layers(output);
265 output->output_destroy.notify = handle_output_destroy;
266
267 arrange_windows(&root_container, -1, -1); 308 arrange_windows(&root_container, -1, -1);
268} 309}