mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
Fix furhter wayland backend issues
This commit is contained in:
parent
8fbf1ca3ff
commit
10526de444
3 changed files with 24 additions and 12 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <wlr/backend/interface.h>
|
#include <wlr/backend/interface.h>
|
||||||
#include <wlr/backend/drm.h>
|
#include <wlr/backend/drm.h>
|
||||||
#include <wlr/backend/libinput.h>
|
#include <wlr/backend/libinput.h>
|
||||||
|
#include <wlr/backend/wayland.h>
|
||||||
#include <wlr/backend/multi.h>
|
#include <wlr/backend/multi.h>
|
||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "backend/udev.h"
|
#include "backend/udev.h"
|
||||||
|
@ -42,6 +43,9 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
||||||
struct wlr_session *session) {
|
struct wlr_session *session) {
|
||||||
// TODO: Choose the most appropriate backend for the situation
|
// TODO: Choose the most appropriate backend for the situation
|
||||||
// Attempt DRM+libinput
|
// Attempt DRM+libinput
|
||||||
|
if(getenv("WAYLAND_DISPLAY") || getenv("_WAYLAND_DISPLAY")) {
|
||||||
|
return wlr_wl_backend_create(display, 1);
|
||||||
|
}
|
||||||
struct wlr_udev *udev;
|
struct wlr_udev *udev;
|
||||||
if (!(udev = wlr_udev_create(display))) {
|
if (!(udev = wlr_udev_create(display))) {
|
||||||
wlr_log(L_ERROR, "Failed to start udev");
|
wlr_log(L_ERROR, "Failed to start udev");
|
||||||
|
|
|
@ -13,14 +13,16 @@
|
||||||
* the specified display.
|
* the specified display.
|
||||||
*/
|
*/
|
||||||
static bool wlr_wl_backend_init(struct wlr_backend_state* state) {
|
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"));
|
state->remote_display = wl_display_connect(getenv("_WAYLAND_DISPLAY"));
|
||||||
if (!state->remote_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(state->registry = wl_display_get_registry(state->remote_display))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ static struct wlr_backend_impl backend_impl = {
|
||||||
|
|
||||||
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
size_t outputs) {
|
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));
|
struct wlr_backend_state *state = calloc(1, sizeof(struct wlr_backend_state));
|
||||||
if (!state) {
|
if (!state) {
|
||||||
|
@ -76,6 +78,11 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(state->devices = list_create())) {
|
||||||
|
wlr_log(L_ERROR, "Could not allocate devices list");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
state->local_display = display;
|
state->local_display = display;
|
||||||
state->backend = backend;
|
state->backend = backend;
|
||||||
|
|
||||||
|
|
|
@ -44,23 +44,24 @@ static struct wlr_output_impl output_impl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void registry_wl_output(struct wlr_backend_state *state,
|
static void registry_wl_output(struct wlr_backend_state *state,
|
||||||
struct wl_output *wl_output, struct wl_registry *registry, uint32_t version) {
|
struct wl_output *wl_output, struct wl_registry *registry,
|
||||||
struct wlr_output_state *output;
|
uint32_t version) {
|
||||||
if (!(output = calloc(sizeof(struct wlr_output_state), 1))) {
|
struct wlr_output_state *ostate;
|
||||||
|
if (!(ostate = calloc(sizeof(struct wlr_output_state), 1))) {
|
||||||
wlr_log(L_ERROR, "Failed to allocate wlr_wl_output");
|
wlr_log(L_ERROR, "Failed to allocate wlr_wl_output");
|
||||||
return;
|
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) {
|
if (!wlr_output) {
|
||||||
free(state);
|
free(ostate);
|
||||||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
|
wlr_log_errno(L_ERROR, "Allocation failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output->output = wl_output;
|
ostate->output = wl_output;
|
||||||
list_add(state->outputs, output);
|
list_add(state->outputs, wlr_output);
|
||||||
wl_output_add_listener(wl_output, &output_listener, output);
|
wl_output_add_listener(wl_output, &output_listener, wlr_output);
|
||||||
wl_signal_emit(&state->backend->events.output_add, wlr_output);
|
wl_signal_emit(&state->backend->events.output_add, wlr_output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue