commit 4be707fd105b05c22fb0f8791c1a0728fea93739
parent 3984baaca22ff7847a4583efbd9b66b2bbac5b6e
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 10 Jan 2019 18:12:09 -0500
Move output code into output.c
Diffstat:
4 files changed, 57 insertions(+), 47 deletions(-)
diff --git a/include/server.h b/include/server.h
@@ -14,6 +14,7 @@ struct wio_server {
struct wl_list outputs;
struct wl_listener new_output;
+ struct wl_listener new_input;
};
struct wio_output {
@@ -24,4 +25,6 @@ struct wio_output {
struct wl_listener frame;
};
+void server_new_output(struct wl_listener *listener, void *data);
+
#endif
diff --git a/main.c b/main.c
@@ -5,56 +5,10 @@
#include <wlr/backend.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_data_device.h>
-#include <wlr/types/wlr_output.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/util/log.h>
-#include "colors.h"
#include "server.h"
-static void output_frame(struct wl_listener *listener, void *data) {
- struct wio_output *output = wl_container_of(listener, output, frame);
- struct wlr_renderer *renderer = output->server->renderer;
-
- struct timespec now;
- clock_gettime(CLOCK_MONOTONIC, &now);
-
- if (!wlr_output_make_current(output->wlr_output, NULL)) {
- return;
- }
-
- int width, height;
- wlr_output_effective_resolution(output->wlr_output, &width, &height);
- wlr_renderer_begin(renderer, width, height);
-
- wlr_renderer_clear(renderer, background);
- // TODO: other stuff
- wlr_renderer_end(renderer);
- wlr_output_swap_buffers(output->wlr_output, NULL, NULL);
-}
-
-static void server_new_output(struct wl_listener *listener, void *data) {
- struct wio_server *server =
- wl_container_of(listener, server, new_output);
- struct wlr_output *wlr_output = data;
-
- if (!wl_list_empty(&wlr_output->modes)) {
- struct wlr_output_mode *mode =
- wl_container_of(wlr_output->modes.prev, mode, link);
- wlr_output_set_mode(wlr_output, mode);
- }
-
- struct wio_output *output = calloc(1, sizeof(struct wio_output));
- output->wlr_output = wlr_output;
- output->server = server;
- output->frame.notify = output_frame;
- wl_signal_add(&wlr_output->events.frame, &output->frame);
- wl_list_insert(&server->outputs, &output->link);
-
- // TODO
- //wlr_output_layout_add_auto(server->output_layout, wlr_output);
- wlr_output_create_global(wlr_output);
-}
-
int main(int argc, char **argv) {
struct wio_server server;
diff --git a/meson.build b/meson.build
@@ -30,7 +30,8 @@ wio_inc = include_directories('include')
subdir('protocols')
wio_sources = files(
- 'main.c'
+ 'main.c',
+ 'output.c',
)
executable(
diff --git a/output.c b/output.c
@@ -0,0 +1,52 @@
+#define _POSIX_C_SOURCE 200112L
+#include <stdlib.h>
+#include <time.h>
+#include <wayland-server.h>
+#include <wlr/types/wlr_output.h>
+#include <wlr/render/wlr_renderer.h>
+#include "colors.h"
+#include "server.h"
+
+static void output_frame(struct wl_listener *listener, void *data) {
+ struct wio_output *output = wl_container_of(listener, output, frame);
+ struct wlr_renderer *renderer = output->server->renderer;
+
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+
+ if (!wlr_output_make_current(output->wlr_output, NULL)) {
+ return;
+ }
+
+ int width, height;
+ wlr_output_effective_resolution(output->wlr_output, &width, &height);
+ wlr_renderer_begin(renderer, width, height);
+
+ wlr_renderer_clear(renderer, background);
+ // TODO: other stuff
+ wlr_renderer_end(renderer);
+ wlr_output_swap_buffers(output->wlr_output, NULL, NULL);
+}
+
+void server_new_output(struct wl_listener *listener, void *data) {
+ struct wio_server *server =
+ wl_container_of(listener, server, new_output);
+ struct wlr_output *wlr_output = data;
+
+ if (!wl_list_empty(&wlr_output->modes)) {
+ struct wlr_output_mode *mode =
+ wl_container_of(wlr_output->modes.prev, mode, link);
+ wlr_output_set_mode(wlr_output, mode);
+ }
+
+ struct wio_output *output = calloc(1, sizeof(struct wio_output));
+ output->wlr_output = wlr_output;
+ output->server = server;
+ output->frame.notify = output_frame;
+ wl_signal_add(&wlr_output->events.frame, &output->frame);
+ wl_list_insert(&server->outputs, &output->link);
+
+ // TODO
+ //wlr_output_layout_add_auto(server->output_layout, wlr_output);
+ wlr_output_create_global(wlr_output);
+}