aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-11 14:41:18 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-11 14:41:18 -0500
commit1efd5f819f9986bf27e390f4988359388606cea0 (patch)
treebb417f4442a37e7d2baea13cc6e674a70978acf7 /sway/desktop/output.c
parentInitialize outputs from backend and add to tree (diff)
downloadsway-1efd5f819f9986bf27e390f4988359388606cea0.tar.gz
sway-1efd5f819f9986bf27e390f4988359388606cea0.tar.zst
sway-1efd5f819f9986bf27e390f4988359388606cea0.zip
Wire up output frame loop
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 51363e76..6d0bebc5 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -1,21 +1,60 @@
1#define _POSIX_C_SOURCE 200809L
2#include <stdlib.h>
3#include <time.h>
1#include <wayland-server.h> 4#include <wayland-server.h>
2#include <wlr/types/wlr_output.h> 5#include <wlr/types/wlr_output.h>
6#include <wlr/render.h>
3#include "sway/server.h" 7#include "sway/server.h"
4#include "sway/container.h" 8#include "sway/container.h"
5#include "sway/workspace.h" 9#include "sway/workspace.h"
10#include "sway/output.h"
6#include "log.h" 11#include "log.h"
7 12
13static void output_frame_notify(struct wl_listener *listener, void *data) {
14 struct sway_output *soutput = wl_container_of(
15 listener, soutput, frame);
16 struct wlr_output *wlr_output = data;
17 struct sway_server *server = soutput->server;
18
19 struct timespec now;
20 clock_gettime(CLOCK_MONOTONIC, &now);
21
22 wlr_output_make_current(wlr_output);
23 wlr_renderer_begin(server->renderer, wlr_output);
24
25 wlr_renderer_end(server->renderer);
26 wlr_output_swap_buffers(wlr_output);
27
28 soutput->last_frame = now;
29}
30
8void output_add_notify(struct wl_listener *listener, void *data) { 31void output_add_notify(struct wl_listener *listener, void *data) {
9 struct sway_server *server = wl_container_of(listener, server, output_add); 32 struct sway_server *server = wl_container_of(listener, server, output_add);
10 struct wlr_output *wlr_output = data; 33 struct wlr_output *wlr_output = data;
11 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name); 34 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
12 swayc_t *op = new_output(wlr_output); 35
13 if (!sway_assert(op, "Failed to allocate output")) { 36 struct sway_output *output = calloc(1, sizeof(struct sway_output));
37 output->wlr_output = wlr_output;
38 output->server = server;
39
40 swayc_t *node = new_output(output);
41 if (!sway_assert(node, "Failed to allocate output")) {
14 return; 42 return;
15 } 43 }
44
16 // Switch to workspace if we need to 45 // Switch to workspace if we need to
17 if (swayc_active_workspace() == NULL) { 46 if (swayc_active_workspace() == NULL) {
18 swayc_t *ws = op->children->items[0]; 47 swayc_t *ws = node->children->items[0];
19 workspace_switch(ws); 48 workspace_switch(ws);
20 } 49 }
50
51 output->frame.notify = output_frame_notify;
52 wl_signal_add(&wlr_output->events.frame, &output->frame);
53}
54
55void output_remove_notify(struct wl_listener *listener, void *data) {
56 struct sway_server *server = wl_container_of(listener, server, output_remove);
57 struct wlr_output *wlr_output = data;
58 sway_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
59 // TODO
21} 60}