swayfx/sway/desktop/output.c

50 lines
1.5 KiB
C
Raw Normal View History

2017-11-12 06:41:18 +11:00
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <time.h>
#include <wayland-server.h>
#include <wlr/types/wlr_output.h>
2017-11-12 06:41:18 +11:00
#include <wlr/render.h>
#include "log.h"
2017-11-20 09:04:28 +11:00
#include "sway/container.h"
2017-11-19 03:22:02 +11:00
#include "sway/output.h"
#include "sway/server.h"
2017-11-12 06:41:18 +11:00
static void output_frame_notify(struct wl_listener *listener, void *data) {
struct sway_output *soutput = wl_container_of(
listener, soutput, frame);
struct wlr_output *wlr_output = data;
struct sway_server *server = soutput->server;
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_output_make_current(wlr_output);
wlr_renderer_begin(server->renderer, wlr_output);
wlr_renderer_end(server->renderer);
wlr_output_swap_buffers(wlr_output);
soutput->last_frame = now;
}
void output_add_notify(struct wl_listener *listener, void *data) {
struct sway_server *server = wl_container_of(listener, server, output_add);
struct wlr_output *wlr_output = data;
sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
2017-11-12 06:41:18 +11:00
struct sway_output *output = calloc(1, sizeof(struct sway_output));
output->wlr_output = wlr_output;
output->server = server;
2017-11-20 09:04:28 +11:00
output->swayc = new_output(output);
2017-11-12 06:41:18 +11:00
output->frame.notify = output_frame_notify;
wl_signal_add(&wlr_output->events.frame, &output->frame);
}
void output_remove_notify(struct wl_listener *listener, void *data) {
struct sway_server *server = wl_container_of(listener, server, output_remove);
struct wlr_output *wlr_output = data;
sway_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
// TODO
}