aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.c4
-rw-r--r--backend/wayland/backend.c13
-rw-r--r--backend/wayland/registry.c19
3 files changed, 24 insertions, 12 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 02fd7479..087696ec 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -8,6 +8,7 @@
#include <wlr/backend/interface.h>
#include <wlr/backend/drm.h>
#include <wlr/backend/libinput.h>
+#include <wlr/backend/wayland.h>
#include <wlr/backend/multi.h>
#include "backend/libinput.h"
#include "backend/udev.h"
@@ -42,6 +43,9 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
struct wlr_session *session) {
// TODO: Choose the most appropriate backend for the situation
// Attempt DRM+libinput
+ if(getenv("WAYLAND_DISPLAY") || getenv("_WAYLAND_DISPLAY")) {
+ return wlr_wl_backend_create(display, 1);
+ }
struct wlr_udev *udev;
if (!(udev = wlr_udev_create(display))) {
wlr_log(L_ERROR, "Failed to start udev");
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 53a96696..cbc5c5d6 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -13,14 +13,16 @@
* the specified display.
*/
static bool wlr_wl_backend_init(struct wlr_backend_state* state) {
+ wlr_log(L_INFO, "Initializating wayland backend");
+
state->remote_display = wl_display_connect(getenv("_WAYLAND_DISPLAY"));
if (!state->remote_display) {
- wlr_log(L_ERROR, "Could not connect to remote display");
+ wlr_log_errno(L_ERROR, "Could not connect to remote display");
return false;
}
if (!(state->registry = wl_display_get_registry(state->remote_display))) {
- wlr_log(L_ERROR, "Could not obtain reference to remote registry");
+ wlr_log_errno(L_ERROR, "Could not obtain reference to remote registry");
return false;
}
@@ -57,7 +59,7 @@ static struct wlr_backend_impl backend_impl = {
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
size_t outputs) {
- wlr_log(L_INFO, "Initalizing wayland backend");
+ wlr_log(L_INFO, "Creating wayland backend");
struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state));
if (!state) {
@@ -76,6 +78,11 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
goto error;
}
+ if (!(state->devices = list_create())) {
+ wlr_log(L_ERROR, "Could not allocate devices list");
+ goto error;
+ }
+
state->local_display = display;
state->backend = backend;
diff --git a/backend/wayland/registry.c b/backend/wayland/registry.c
index 66ea4b72..1cd49ed9 100644
--- a/backend/wayland/registry.c
+++ b/backend/wayland/registry.c
@@ -44,23 +44,24 @@ static struct wlr_output_impl output_impl = {
};
static void registry_wl_output(struct wlr_backend_state *state,
- struct wl_output *wl_output, struct wl_registry *registry, uint32_t version) {
- struct wlr_output_state *output;
- if (!(output = calloc(sizeof(struct wlr_output_state), 1))) {
+ struct wl_output *wl_output, struct wl_registry *registry,
+ uint32_t version) {
+ struct wlr_output_state *ostate;
+ if (!(ostate = calloc(sizeof(struct wlr_output_state), 1))) {
wlr_log(L_ERROR, "Failed to allocate wlr_wl_output");
return;
}
- struct wlr_output *wlr_output = wlr_output_create(&output_impl, output);
+ struct wlr_output *wlr_output = wlr_output_create(&output_impl, ostate);
if (!wlr_output) {
- free(state);
- wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
+ free(ostate);
+ wlr_log_errno(L_ERROR, "Allocation failed");
return;
}
- output->output = wl_output;
- list_add(state->outputs, output);
- wl_output_add_listener(wl_output, &output_listener, output);
+ ostate->output = wl_output;
+ list_add(state->outputs, wlr_output);
+ wl_output_add_listener(wl_output, &output_listener, wlr_output);
wl_signal_emit(&state->backend->events.output_add, wlr_output);
return;
}