tRearrange startup and add output_layout/cursor init - spkp - Stacking wayland compositor
(HTM) git clone git://git.z3bra.org/spkp.git
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 18f199d018b8525a90666d62c29aa7533e994488
(DIR) parent 8c9a50a1bd58997e0cdc1b528490878aefd90de6
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Mon, 9 Nov 2020 10:02:39 +0100
Rearrange startup and add output_layout/cursor init
Diffstat:
M compositor.c | 53 +++++++++++++++++++++++--------
1 file changed, 39 insertions(+), 14 deletions(-)
---
(DIR) diff --git a/compositor.c b/compositor.c
t@@ -7,6 +7,7 @@
#include <wlr/backend.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_gamma_control_v1.h>
t@@ -14,8 +15,10 @@
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h>
+#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection_v1.h>
#include <wlr/types/wlr_screencopy_v1.h>
+#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell.h>
#include "xdg-shell-protocol.h"
t@@ -26,11 +29,13 @@
/* keep track of internal compositor state */
struct state {
struct wl_display *dpy;
- struct wl_event_loop *evloop;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_xdg_shell *shell;
+ struct wlr_output_layout *layout;
struct wlr_seat *seat;
+ struct wlr_cursor *cursor;
+ struct wlr_xcursor_manager *cursor_mgr;
struct wl_listener new_input;
struct wl_listener new_output;
t@@ -219,7 +224,8 @@ cb_new_output(struct wl_listener *listener, void *data)
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
wl_signal_add(&wlr_output->events.frame, &output->frame);
- wlr_output_create_global(wlr_output);
+ /* create global and arrange outputs from left to right */
+ wlr_output_layout_add_auto(server->layout, wlr_output);
}
/*
t@@ -470,46 +476,65 @@ main(int argc, char *argv[])
break; /* NOTREACHED */
} ARGEND;
+ /*
+ * create server side resources
+ */
server.dpy = wl_display_create();
- server.evloop = wl_display_get_event_loop(server.dpy);
-
+ server.seat = wlr_seat_create(server.dpy, "seat0");
+ server.shell = wlr_xdg_shell_create(server.dpy);
+ server.layout = wlr_output_layout_create();
server.backend = wlr_backend_autocreate(server.dpy, NULL);
server.renderer = wlr_backend_get_renderer(server.backend);
- server.shell = wlr_xdg_shell_create(server.dpy);
- server.seat = wlr_seat_create(server.dpy, "seat0");
wl_list_init(&server.outputs);
wl_list_init(&server.windows);
+ wl_list_init(&server.keyboards);
+
+ wl_display_init_shm(server.dpy);
+ wlr_renderer_init_wl_display(server.renderer, server.dpy);
wlr_compositor_create(server.dpy, server.renderer);
wlr_data_device_manager_create(server.dpy);
+ wlr_gamma_control_manager_v1_create(server.dpy);
+ wlr_screencopy_manager_v1_create(server.dpy);
+ wlr_primary_selection_v1_device_manager_create(server.dpy);
+ wlr_idle_create(server.dpy);
+
+ /*
+ * Setup callbacks for server-side events
+ */
+ server.new_window.notify = cb_new_window;
server.new_input.notify = cb_new_input;
server.new_output.notify = cb_new_output;
- server.new_window.notify = cb_new_window;
- wl_signal_add(&server.backend->events.new_input, &server.new_input);
wl_signal_add(&server.backend->events.new_output, &server.new_output);
wl_signal_add(&server.shell->events.new_surface, &server.new_window);
+ wl_signal_add(&server.backend->events.new_input, &server.new_input);
+
+
+ /*
+ server.cursor = wlr_cursor_create();
+ server.cursor_mgr = wlr_xcursor_manager_create(NULL, 24);
+
+ wlr_cursor_attach_output_layout(server.cursor, server.layout);
+ wlr_xcursor_manager_load(server.cursor_mgr, 1);
+ */
socket = wl_display_add_socket_auto(server.dpy);
setenv("WAYLAND_DISPLAY", socket, 1);
if (!wlr_backend_start(server.backend)) {
fprintf(stderr, "Failed to start backend\n");
+ wlr_backend_destroy(server.backend);
wl_display_destroy(server.dpy);
return -1;
}
/* all these interfaces are managed internally by wlroots */
- wl_display_init_shm(server.dpy);
- wlr_gamma_control_manager_v1_create(server.dpy);
- wlr_screencopy_manager_v1_create(server.dpy);
- wlr_primary_selection_v1_device_manager_create(server.dpy);
- wlr_idle_create(server.dpy);
-
/* trigger internal event loop */
wl_display_run(server.dpy);
+ wl_display_destroy_clients(server.dpy);
wl_display_destroy(server.dpy);
return 0;