new package: wlroots
This commit is contained in:
parent
8dba2c435b
commit
ce8e1577f5
|
@ -0,0 +1,838 @@
|
|||
https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/1928d1ce9f31b2792e2e7cf7253e21f3c0102589
|
||||
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3814
|
||||
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3873
|
||||
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3874
|
||||
diff -uNr a/README.md b/README.md
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -48,9 +48,9 @@
|
||||
* GBM (optional, for the GBM allocator)
|
||||
* libinput (optional, for the libinput backend)
|
||||
* xkbcommon
|
||||
-* udev
|
||||
+* udev (optional, for the session)
|
||||
* pixman
|
||||
-* [libseat]
|
||||
+* [libseat] (optional, for the session)
|
||||
* [hwdata] (optional, for the DRM backend)
|
||||
|
||||
If you choose to enable X11 support:
|
||||
diff -uNr a/backend/backend.c b/backend/backend.c
|
||||
--- a/backend/backend.c
|
||||
+++ b/backend/backend.c
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <wlr/backend/headless.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/backend/multi.h>
|
||||
-#include <wlr/backend/session.h>
|
||||
#include <wlr/backend/wayland.h>
|
||||
#include <wlr/config.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
@@ -18,6 +17,11 @@
|
||||
#include "backend/multi.h"
|
||||
#include "render/allocator/allocator.h"
|
||||
#include "util/env.h"
|
||||
+#include "util/time.h"
|
||||
+
|
||||
+#if WLR_HAS_SESSION
|
||||
+#include <wlr/backend/session.h>
|
||||
+#endif
|
||||
|
||||
#if WLR_HAS_DRM_BACKEND
|
||||
#include <wlr/backend/drm.h>
|
||||
@@ -66,19 +70,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend) {
|
||||
- if (backend->impl->get_session) {
|
||||
- return backend->impl->get_session(backend);
|
||||
- }
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
-static uint64_t get_current_time_ms(void) {
|
||||
- struct timespec ts = {0};
|
||||
- clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
- return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
|
||||
-}
|
||||
-
|
||||
+#if WLR_HAS_SESSION
|
||||
static struct wlr_session *session_create_and_wait(struct wl_display *disp) {
|
||||
struct wlr_session *session = wlr_session_create(disp);
|
||||
|
||||
@@ -90,8 +82,8 @@
|
||||
if (!session->active) {
|
||||
wlr_log(WLR_INFO, "Waiting for a session to become active");
|
||||
|
||||
- uint64_t started_at = get_current_time_ms();
|
||||
- uint64_t timeout = WAIT_SESSION_TIMEOUT;
|
||||
+ int64_t started_at = get_current_time_msec();
|
||||
+ int64_t timeout = WAIT_SESSION_TIMEOUT;
|
||||
struct wl_event_loop *event_loop =
|
||||
wl_display_get_event_loop(session->display);
|
||||
|
||||
@@ -103,7 +95,7 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- uint64_t now = get_current_time_ms();
|
||||
+ int64_t now = get_current_time_msec();
|
||||
if (now >= started_at + WAIT_SESSION_TIMEOUT) {
|
||||
break;
|
||||
}
|
||||
@@ -118,6 +110,7 @@
|
||||
|
||||
return session;
|
||||
}
|
||||
+#endif
|
||||
|
||||
clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
|
||||
if (backend->impl->get_presentation_clock) {
|
||||
@@ -245,7 +238,8 @@
|
||||
#endif
|
||||
|
||||
static bool attempt_backend_by_name(struct wl_display *display,
|
||||
- struct wlr_multi_backend *multi, char *name) {
|
||||
+ struct wlr_backend *multi, char *name,
|
||||
+ struct wlr_session **session_ptr) {
|
||||
struct wlr_backend *backend = NULL;
|
||||
if (strcmp(name, "wayland") == 0) {
|
||||
backend = attempt_wl_backend(display);
|
||||
@@ -257,9 +251,11 @@
|
||||
backend = attempt_headless_backend(display);
|
||||
} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) {
|
||||
// DRM and libinput need a session
|
||||
- if (multi->session == NULL) {
|
||||
- multi->session = session_create_and_wait(display);
|
||||
- if (multi->session == NULL) {
|
||||
+ if (*session_ptr == NULL) {
|
||||
+#if WLR_HAS_SESSION
|
||||
+ *session_ptr = session_create_and_wait(display);
|
||||
+#endif
|
||||
+ if (*session_ptr == NULL) {
|
||||
wlr_log(WLR_ERROR, "failed to start a session");
|
||||
return false;
|
||||
}
|
||||
@@ -267,13 +263,13 @@
|
||||
|
||||
if (strcmp(name, "libinput") == 0) {
|
||||
#if WLR_HAS_LIBINPUT_BACKEND
|
||||
- backend = wlr_libinput_backend_create(display, multi->session);
|
||||
+ backend = wlr_libinput_backend_create(display, *session_ptr);
|
||||
#endif
|
||||
} else {
|
||||
#if WLR_HAS_DRM_BACKEND
|
||||
// attempt_drm_backend adds the multi drm backends itself
|
||||
- return attempt_drm_backend(display, &multi->backend,
|
||||
- multi->session) != NULL;
|
||||
+ return attempt_drm_backend(display, multi,
|
||||
+ *session_ptr) != NULL;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@@ -281,13 +277,18 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- return wlr_multi_backend_add(&multi->backend, backend);
|
||||
+ return wlr_multi_backend_add(multi, backend);
|
||||
}
|
||||
|
||||
-struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
|
||||
- struct wlr_backend *backend = wlr_multi_backend_create(display);
|
||||
- struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
|
||||
- if (!backend) {
|
||||
+struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
||||
+ struct wlr_session **session_ptr) {
|
||||
+ if (session_ptr != NULL) {
|
||||
+ *session_ptr = NULL;
|
||||
+ }
|
||||
+
|
||||
+ struct wlr_session *session = NULL;
|
||||
+ struct wlr_backend *multi = wlr_multi_backend_create(display);
|
||||
+ if (!multi) {
|
||||
wlr_log(WLR_ERROR, "could not allocate multibackend");
|
||||
return NULL;
|
||||
}
|
||||
@@ -300,26 +301,23 @@
|
||||
names = strdup(names);
|
||||
if (names == NULL) {
|
||||
wlr_log(WLR_ERROR, "allocation failed");
|
||||
- wlr_backend_destroy(backend);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
char *saveptr;
|
||||
char *name = strtok_r(names, ",", &saveptr);
|
||||
while (name != NULL) {
|
||||
- if (!attempt_backend_by_name(display, multi, name)) {
|
||||
+ if (!attempt_backend_by_name(display, multi, name, &session)) {
|
||||
wlr_log(WLR_ERROR, "failed to add backend '%s'", name);
|
||||
- wlr_session_destroy(multi->session);
|
||||
- wlr_backend_destroy(backend);
|
||||
free(names);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
name = strtok_r(NULL, ",", &saveptr);
|
||||
}
|
||||
|
||||
free(names);
|
||||
- return backend;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
if (getenv("WAYLAND_DISPLAY") || getenv("WAYLAND_SOCKET")) {
|
||||
@@ -328,8 +326,8 @@
|
||||
goto error;
|
||||
}
|
||||
|
||||
- wlr_multi_backend_add(backend, wl_backend);
|
||||
- return backend;
|
||||
+ wlr_multi_backend_add(multi, wl_backend);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
@@ -341,8 +339,8 @@
|
||||
goto error;
|
||||
}
|
||||
|
||||
- wlr_multi_backend_add(backend, x11_backend);
|
||||
- return backend;
|
||||
+ wlr_multi_backend_add(multi, x11_backend);
|
||||
+ goto success;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -352,23 +350,22 @@
|
||||
#endif
|
||||
|
||||
// Attempt DRM+libinput
|
||||
- multi->session = session_create_and_wait(display);
|
||||
- if (!multi->session) {
|
||||
+#if WLR_HAS_SESSION
|
||||
+ session = session_create_and_wait(display);
|
||||
+#endif
|
||||
+ if (!session) {
|
||||
wlr_log(WLR_ERROR, "Failed to start a DRM session");
|
||||
- wlr_backend_destroy(backend);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
#if WLR_HAS_LIBINPUT_BACKEND
|
||||
- struct wlr_backend *libinput = wlr_libinput_backend_create(display,
|
||||
- multi->session);
|
||||
+ struct wlr_backend *libinput =
|
||||
+ wlr_libinput_backend_create(display, session);
|
||||
if (!libinput) {
|
||||
wlr_log(WLR_ERROR, "Failed to start libinput backend");
|
||||
- wlr_session_destroy(multi->session);
|
||||
- wlr_backend_destroy(backend);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
- wlr_multi_backend_add(backend, libinput);
|
||||
+ wlr_multi_backend_add(multi, libinput);
|
||||
#else
|
||||
if (env_parse_bool("WLR_LIBINPUT_NO_DEVICES")) {
|
||||
wlr_log(WLR_INFO, "WLR_LIBINPUT_NO_DEVICES is set, "
|
||||
@@ -377,28 +374,31 @@
|
||||
wlr_log(WLR_ERROR, "libinput support is not compiled in, "
|
||||
"refusing to start");
|
||||
wlr_log(WLR_ERROR, "Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check");
|
||||
- wlr_session_destroy(multi->session);
|
||||
- wlr_backend_destroy(backend);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WLR_HAS_DRM_BACKEND
|
||||
struct wlr_backend *primary_drm =
|
||||
- attempt_drm_backend(display, backend, multi->session);
|
||||
+ attempt_drm_backend(display, multi, session);
|
||||
if (!primary_drm) {
|
||||
wlr_log(WLR_ERROR, "Failed to open any DRM device");
|
||||
- wlr_session_destroy(multi->session);
|
||||
- wlr_backend_destroy(backend);
|
||||
- return NULL;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
- drm_backend_monitor_create(backend, primary_drm, multi->session);
|
||||
-
|
||||
- return backend;
|
||||
+ drm_backend_monitor_create(multi, primary_drm, session);
|
||||
#endif
|
||||
|
||||
+success:
|
||||
+ if (session_ptr != NULL) {
|
||||
+ *session_ptr = session;
|
||||
+ }
|
||||
+ return multi;
|
||||
+
|
||||
error:
|
||||
- wlr_backend_destroy(backend);
|
||||
+ wlr_backend_destroy(multi);
|
||||
+#if WLR_HAS_SESSION
|
||||
+ wlr_session_destroy(session);
|
||||
+#endif
|
||||
return NULL;
|
||||
}
|
||||
diff -uNr a/backend/drm/meson.build b/backend/drm/meson.build
|
||||
--- a/backend/drm/meson.build
|
||||
+++ b/backend/drm/meson.build
|
||||
@@ -1,3 +1,7 @@
|
||||
+if not features['session']
|
||||
+ subdir_done()
|
||||
+endif
|
||||
+
|
||||
hwdata = dependency('hwdata', required: false, native: true)
|
||||
if hwdata.found()
|
||||
hwdata_dir = hwdata.get_variable(pkgconfig: 'pkgdatadir')
|
||||
diff -uNr a/backend/libinput/meson.build b/backend/libinput/meson.build
|
||||
--- a/backend/libinput/meson.build
|
||||
+++ b/backend/libinput/meson.build
|
||||
@@ -10,7 +10,7 @@
|
||||
not_found_message: '\n'.join(msg),
|
||||
)
|
||||
|
||||
-if not libinput.found()
|
||||
+if not (libinput.found() and features['session'])
|
||||
subdir_done()
|
||||
endif
|
||||
|
||||
diff -uNr a/backend/meson.build b/backend/meson.build
|
||||
--- a/backend/meson.build
|
||||
+++ b/backend/meson.build
|
||||
@@ -8,6 +11,16 @@
|
||||
backends = []
|
||||
endif
|
||||
|
||||
+session_required = 'drm' in backends or 'libinput' in backends or get_option('session').enabled()
|
||||
+if get_option('session').disabled()
|
||||
+ if session_required
|
||||
+ error('Session support is required for the DRM or libinput backends')
|
||||
+ endif
|
||||
+ session_required = disabler()
|
||||
+endif
|
||||
+
|
||||
+subdir('session')
|
||||
+
|
||||
foreach backend : all_backends
|
||||
if backend in backends or 'auto' in backends
|
||||
subdir(backend)
|
||||
@@ -17,5 +30,3 @@
|
||||
subdir('multi')
|
||||
subdir('wayland')
|
||||
subdir('headless')
|
||||
-
|
||||
-subdir('session')
|
||||
diff -uNr a/backend/multi/backend.c b/backend/multi/backend.c
|
||||
--- a/backend/multi/backend.c
|
||||
+++ b/backend/multi/backend.c
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
-#include <wlr/backend/session.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "backend/backend.h"
|
||||
@@ -63,12 +62,6 @@
|
||||
free(backend);
|
||||
}
|
||||
|
||||
-static struct wlr_session *multi_backend_get_session(
|
||||
- struct wlr_backend *_backend) {
|
||||
- struct wlr_multi_backend *backend = multi_backend_from_backend(_backend);
|
||||
- return backend->session;
|
||||
-}
|
||||
-
|
||||
static clockid_t multi_backend_get_presentation_clock(
|
||||
struct wlr_backend *backend) {
|
||||
struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
|
||||
@@ -121,7 +114,6 @@
|
||||
static const struct wlr_backend_impl backend_impl = {
|
||||
.start = multi_backend_start,
|
||||
.destroy = multi_backend_destroy,
|
||||
- .get_session = multi_backend_get_session,
|
||||
.get_presentation_clock = multi_backend_get_presentation_clock,
|
||||
.get_drm_fd = multi_backend_get_drm_fd,
|
||||
.get_buffer_caps = multi_backend_get_buffer_caps,
|
||||
diff -uNr a/backend/session/meson.build b/backend/session/meson.build
|
||||
--- a/backend/session/meson.build
|
||||
+++ b/backend/session/meson.build
|
||||
@@ -1,7 +1,17 @@
|
||||
-libseat = dependency('libseat',
|
||||
+msg = 'Required for session support.'
|
||||
+udev = dependency('libudev', required: session_required, not_found_message: msg)
|
||||
+libseat = dependency(
|
||||
+ 'libseat',
|
||||
version: '>=0.2.0',
|
||||
fallback: 'seatd',
|
||||
- default_options: ['server=disabled', 'man-pages=disabled'],
|
||||
+ default_options: ['server=disabled', 'man-pages=disabled', 'examples=disabled'],
|
||||
+ required: session_required,
|
||||
+ not_found_message: msg,
|
||||
)
|
||||
+if not (udev.found() and libseat.found())
|
||||
+ subdir_done()
|
||||
+endif
|
||||
+
|
||||
wlr_files += files('session.c')
|
||||
-wlr_deps += libseat
|
||||
+wlr_deps += [udev, libseat]
|
||||
+features += { 'session': true }
|
||||
diff -uNr a/backend/session/session.c b/backend/session/session.c
|
||||
--- a/backend/session/session.c
|
||||
+++ b/backend/session/session.c
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
-#include <time.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/config.h>
|
||||
@@ -17,6 +16,7 @@
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include "backend/session/session.h"
|
||||
+#include "util/time.h"
|
||||
|
||||
#include <libseat.h>
|
||||
|
||||
@@ -436,12 +436,6 @@
|
||||
return en;
|
||||
}
|
||||
|
||||
-static uint64_t get_current_time_ms(void) {
|
||||
- struct timespec ts = {0};
|
||||
- clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
- return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
|
||||
-}
|
||||
-
|
||||
struct find_gpus_add_handler {
|
||||
bool added;
|
||||
struct wl_listener listener;
|
||||
@@ -476,8 +470,8 @@
|
||||
handler.listener.notify = find_gpus_handle_add;
|
||||
wl_signal_add(&session->events.add_drm_card, &handler.listener);
|
||||
|
||||
- uint64_t started_at = get_current_time_ms();
|
||||
- uint64_t timeout = WAIT_GPU_TIMEOUT;
|
||||
+ int64_t started_at = get_current_time_msec();
|
||||
+ int64_t timeout = WAIT_GPU_TIMEOUT;
|
||||
struct wl_event_loop *event_loop =
|
||||
wl_display_get_event_loop(session->display);
|
||||
while (!handler.added) {
|
||||
@@ -489,7 +483,7 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
- uint64_t now = get_current_time_ms();
|
||||
+ int64_t now = get_current_time_msec();
|
||||
if (now >= started_at + WAIT_GPU_TIMEOUT) {
|
||||
break;
|
||||
}
|
||||
diff -uNr a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c
|
||||
--- a/examples/fullscreen-shell.c
|
||||
+++ b/examples/fullscreen-shell.c
|
||||
@@ -205,7 +205,7 @@
|
||||
|
||||
struct fullscreen_server server = {0};
|
||||
server.wl_display = wl_display_create();
|
||||
- server.backend = wlr_backend_autocreate(server.wl_display);
|
||||
+ server.backend = wlr_backend_autocreate(server.wl_display, NULL);
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
wlr_renderer_init_wl_display(server.renderer, server.wl_display);
|
||||
server.allocator = wlr_allocator_autocreate(server.backend,
|
||||
diff -uNr a/examples/multi-pointer.c b/examples/multi-pointer.c
|
||||
--- a/examples/multi-pointer.c
|
||||
+++ b/examples/multi-pointer.c
|
||||
@@ -272,7 +272,7 @@
|
||||
.clear_color = { 0.25f, 0.25f, 0.25f, 1 },
|
||||
.display = display,
|
||||
};
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/output-layout.c b/examples/output-layout.c
|
||||
--- a/examples/output-layout.c
|
||||
+++ b/examples/output-layout.c
|
||||
@@ -268,7 +268,7 @@
|
||||
state.layout = wlr_output_layout_create();
|
||||
clock_gettime(CLOCK_MONOTONIC, &state.ts_last);
|
||||
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/pointer.c b/examples/pointer.c
|
||||
--- a/examples/pointer.c
|
||||
+++ b/examples/pointer.c
|
||||
@@ -333,7 +333,7 @@
|
||||
.display = display
|
||||
};
|
||||
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/quads.c b/examples/quads.c
|
||||
--- a/examples/quads.c
|
||||
+++ b/examples/quads.c
|
||||
@@ -189,7 +189,7 @@
|
||||
};
|
||||
wl_list_init(&state.outputs);
|
||||
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/rotation.c b/examples/rotation.c
|
||||
--- a/examples/rotation.c
|
||||
+++ b/examples/rotation.c
|
||||
@@ -239,7 +239,7 @@
|
||||
};
|
||||
wl_list_init(&state.outputs);
|
||||
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/scene-graph.c b/examples/scene-graph.c
|
||||
--- a/examples/scene-graph.c
|
||||
+++ b/examples/scene-graph.c
|
||||
@@ -157,7 +157,7 @@
|
||||
struct server server = {0};
|
||||
server.surface_offset = 0;
|
||||
server.display = wl_display_create();
|
||||
- server.backend = wlr_backend_autocreate(server.display);
|
||||
+ server.backend = wlr_backend_autocreate(server.display, NULL);
|
||||
server.scene = wlr_scene_create();
|
||||
|
||||
server.renderer = wlr_renderer_autocreate(server.backend);
|
||||
diff -uNr a/examples/simple.c b/examples/simple.c
|
||||
--- a/examples/simple.c
|
||||
+++ b/examples/simple.c
|
||||
@@ -172,7 +172,7 @@
|
||||
.last_frame = { 0 },
|
||||
.display = display
|
||||
};
|
||||
- struct wlr_backend *backend = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *backend = wlr_backend_autocreate(display, NULL);
|
||||
if (!backend) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/tablet.c b/examples/tablet.c
|
||||
--- a/examples/tablet.c
|
||||
+++ b/examples/tablet.c
|
||||
@@ -355,7 +355,7 @@
|
||||
};
|
||||
wl_list_init(&state.tablet_pads);
|
||||
wl_list_init(&state.tablet_tools);
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/examples/touch.c b/examples/touch.c
|
||||
--- a/examples/touch.c
|
||||
+++ b/examples/touch.c
|
||||
@@ -248,7 +248,7 @@
|
||||
wl_list_init(&state.touch_points);
|
||||
wl_list_init(&state.touch);
|
||||
|
||||
- struct wlr_backend *wlr = wlr_backend_autocreate(display);
|
||||
+ struct wlr_backend *wlr = wlr_backend_autocreate(display, NULL);
|
||||
if (!wlr) {
|
||||
exit(1);
|
||||
}
|
||||
diff -uNr a/include/backend/multi.h b/include/backend/multi.h
|
||||
--- a/include/backend/multi.h
|
||||
+++ b/include/backend/multi.h
|
||||
@@ -4,11 +4,9 @@
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/backend/multi.h>
|
||||
-#include <wlr/backend/session.h>
|
||||
|
||||
struct wlr_multi_backend {
|
||||
struct wlr_backend backend;
|
||||
- struct wlr_session *session;
|
||||
|
||||
struct wl_list backends;
|
||||
|
||||
diff -uNr a/include/meson.build b/include/meson.build
|
||||
--- a/include/meson.build
|
||||
+++ b/include/meson.build
|
||||
@@ -22,6 +22,9 @@
|
||||
if not features.get('vulkan-renderer')
|
||||
exclude_files += 'render/vulkan.h'
|
||||
endif
|
||||
+if not features.get('session')
|
||||
+ exclude_files += 'backend/session.h'
|
||||
+endif
|
||||
|
||||
install_subdir('wlr',
|
||||
install_dir: get_option('includedir'),
|
||||
diff -uNr a/include/meson.build.orig b/include/meson.build.orig
|
||||
--- a/include/meson.build.orig 1970-01-01 08:00:00.000000000 +0800
|
||||
+++ b/include/meson.build.orig
|
||||
@@ -0,0 +1,29 @@
|
||||
+subdir('wlr')
|
||||
+
|
||||
+exclude_files = ['meson.build', 'config.h.in', 'version.h.in']
|
||||
+if not features.get('drm-backend')
|
||||
+ exclude_files += 'backend/drm.h'
|
||||
+ exclude_files += 'types/wlr_drm_lease_v1.h'
|
||||
+endif
|
||||
+if not features.get('libinput-backend')
|
||||
+ exclude_files += 'backend/libinput.h'
|
||||
+endif
|
||||
+if not features.get('x11-backend')
|
||||
+ exclude_files += 'backend/x11.h'
|
||||
+endif
|
||||
+if not features.get('xwayland')
|
||||
+ exclude_files += 'xwayland.h'
|
||||
+else
|
||||
+ subdir('xwayland')
|
||||
+endif
|
||||
+if not features.get('gles2-renderer')
|
||||
+ exclude_files += ['render/egl.h', 'render/gles2.h']
|
||||
+endif
|
||||
+if not features.get('vulkan-renderer')
|
||||
+ exclude_files += 'render/vulkan.h'
|
||||
+endif
|
||||
+
|
||||
+install_subdir('wlr',
|
||||
+ install_dir: get_option('includedir'),
|
||||
+ exclude_files: exclude_files,
|
||||
+)
|
||||
diff -uNr a/include/render/gles2.h b/include/render/gles2.h
|
||||
--- a/include/render/gles2.h
|
||||
+++ b/include/render/gles2.h
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
-#include <wlr/backend.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/gles2.h>
|
||||
#include <wlr/render/interface.h>
|
||||
diff -uNr a/include/util/time.h b/include/util/time.h
|
||||
--- a/include/util/time.h
|
||||
+++ b/include/util/time.h
|
||||
@@ -6,7 +6,7 @@
|
||||
/**
|
||||
* Get the current time, in milliseconds.
|
||||
*/
|
||||
-uint32_t get_current_time_msec(void);
|
||||
+int64_t get_current_time_msec(void);
|
||||
|
||||
/**
|
||||
* Convert a timespec to milliseconds.
|
||||
diff -uNr a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h
|
||||
--- a/include/wlr/backend/interface.h
|
||||
+++ b/include/wlr/backend/interface.h
|
||||
@@ -16,7 +16,6 @@
|
||||
struct wlr_backend_impl {
|
||||
bool (*start)(struct wlr_backend *backend);
|
||||
void (*destroy)(struct wlr_backend *backend);
|
||||
- struct wlr_session *(*get_session)(struct wlr_backend *backend);
|
||||
clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
|
||||
int (*get_drm_fd)(struct wlr_backend *backend);
|
||||
uint32_t (*get_buffer_caps)(struct wlr_backend *backend);
|
||||
diff -uNr a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h
|
||||
--- a/include/wlr/backend/multi.h
|
||||
+++ b/include/wlr/backend/multi.h
|
||||
@@ -10,7 +10,6 @@
|
||||
#define WLR_BACKEND_MULTI_H
|
||||
|
||||
#include <wlr/backend.h>
|
||||
-#include <wlr/backend/session.h>
|
||||
|
||||
/**
|
||||
* Creates a multi-backend. Multi-backends wrap an arbitrary number of backends
|
||||
diff -uNr a/include/wlr/backend/session.h b/include/wlr/backend/session.h
|
||||
--- a/include/wlr/backend/session.h
|
||||
+++ b/include/wlr/backend/session.h
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef WLR_BACKEND_SESSION_H
|
||||
#define WLR_BACKEND_SESSION_H
|
||||
|
||||
-#include <libudev.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/types.h>
|
||||
#include <wayland-server-core.h>
|
||||
diff -uNr a/include/wlr/backend.h b/include/wlr/backend.h
|
||||
--- a/include/wlr/backend.h
|
||||
+++ b/include/wlr/backend.h
|
||||
@@ -10,8 +10,8 @@
|
||||
#define WLR_BACKEND_H
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
-#include <wlr/backend/session.h>
|
||||
|
||||
+struct wlr_session;
|
||||
struct wlr_backend_impl;
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,12 @@
|
||||
* Automatically initializes the most suitable backend given the environment.
|
||||
* Will always return a multi-backend. The backend is created but not started.
|
||||
* Returns NULL on failure.
|
||||
+ *
|
||||
+ * If session_ptr is not NULL, it's populated with the session which has been
|
||||
+ * created with the backend, if any.
|
||||
*/
|
||||
-struct wlr_backend *wlr_backend_autocreate(struct wl_display *display);
|
||||
+struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
|
||||
+ struct wlr_session **session_ptr);
|
||||
/**
|
||||
* Start the backend. This may signal new_input or new_output immediately, but
|
||||
* may also wait until the display's event loop begins. Returns false on
|
||||
@@ -48,11 +52,6 @@
|
||||
*/
|
||||
void wlr_backend_destroy(struct wlr_backend *backend);
|
||||
/**
|
||||
- * Obtains the struct wlr_session reference from this backend if there is any.
|
||||
- * Might return NULL for backends that don't use a session.
|
||||
- */
|
||||
-struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend);
|
||||
-/**
|
||||
* Returns the clock used by the backend for presentation feedback.
|
||||
*/
|
||||
clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend);
|
||||
diff -uNr a/include/wlr/config.h.in b/include/wlr/config.h.in
|
||||
--- a/include/wlr/config.h.in
|
||||
+++ b/include/wlr/config.h.in
|
||||
@@ -12,4 +12,6 @@
|
||||
|
||||
#mesondefine WLR_HAS_XWAYLAND
|
||||
|
||||
+#mesondefine WLR_HAS_SESSION
|
||||
+
|
||||
#endif
|
||||
diff -uNr a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h
|
||||
--- a/include/wlr/render/gles2.h
|
||||
+++ b/include/wlr/render/gles2.h
|
||||
@@ -10,7 +10,6 @@
|
||||
#define WLR_RENDER_GLES2_H
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
-#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
|
||||
struct wlr_egl;
|
||||
diff -uNr a/include/wlr/render/pixman.h b/include/wlr/render/pixman.h
|
||||
--- a/include/wlr/render/pixman.h
|
||||
+++ b/include/wlr/render/pixman.h
|
||||
@@ -10,7 +10,6 @@
|
||||
#define WLR_RENDER_PIXMAN_H
|
||||
|
||||
#include <pixman.h>
|
||||
-#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
|
||||
struct wlr_renderer *wlr_pixman_renderer_create(void);
|
||||
diff -uNr a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h
|
||||
--- a/include/wlr/render/wlr_renderer.h
|
||||
+++ b/include/wlr/render/wlr_renderer.h
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-server-core.h>
|
||||
-#include <wlr/backend.h>
|
||||
#include <wlr/render/wlr_texture.h>
|
||||
|
||||
+struct wlr_backend;
|
||||
struct wlr_renderer_impl;
|
||||
struct wlr_drm_format_set;
|
||||
struct wlr_buffer;
|
||||
diff -uNr a/meson.build b/meson.build
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -93,6 +93,7 @@
|
||||
'gles2-renderer': false,
|
||||
'vulkan-renderer': false,
|
||||
'gbm-allocator': false,
|
||||
+ 'session': false,
|
||||
}
|
||||
internal_features = {
|
||||
'xcb-errors': false,
|
||||
@@ -129,7 +129,6 @@
|
||||
],
|
||||
)
|
||||
xkbcommon = dependency('xkbcommon')
|
||||
-udev = dependency('libudev')
|
||||
pixman = dependency('pixman-1')
|
||||
math = cc.find_library('m')
|
||||
rt = cc.find_library('rt')
|
||||
@@ -138,7 +138,6 @@
|
||||
wayland_server,
|
||||
drm,
|
||||
xkbcommon,
|
||||
- udev,
|
||||
pixman,
|
||||
math,
|
||||
rt,
|
||||
diff -uNr a/meson_options.txt b/meson_options.txt
|
||||
--- a/meson_options.txt
|
||||
+++ b/meson_options.txt
|
||||
@@ -6,3 +6,4 @@
|
||||
option('backends', type: 'array', choices: ['auto', 'drm', 'libinput', 'x11'], value: ['auto'], description: 'Select built-in backends')
|
||||
option('allocators', type: 'array', choices: ['auto', 'gbm'], value: ['auto'],
|
||||
description: 'Select built-in allocators')
|
||||
+option('session', type: 'feature', value: 'auto', description: 'Enable session support')
|
||||
diff -uNr a/render/vulkan/vulkan.c b/render/vulkan/vulkan.c
|
||||
--- a/render/vulkan/vulkan.c
|
||||
+++ b/render/vulkan/vulkan.c
|
||||
@@ -12,6 +12,10 @@
|
||||
#include <wlr/config.h>
|
||||
#include "render/vulkan.h"
|
||||
|
||||
+#if defined(__linux__)
|
||||
+#include <sys/sysmacros.h>
|
||||
+#endif
|
||||
+
|
||||
static bool check_extension(const VkExtensionProperties *avail,
|
||||
uint32_t avail_len, const char *name) {
|
||||
for (size_t i = 0; i < avail_len; i++) {
|
||||
diff -uNr a/tinywl/tinywl.c b/tinywl/tinywl.c
|
||||
--- a/tinywl/tinywl.c
|
||||
+++ b/tinywl/tinywl.c
|
||||
@@ -828,7 +828,7 @@
|
||||
* output hardware. The autocreate option will choose the most suitable
|
||||
* backend based on the current environment, such as opening an X11 window
|
||||
* if an X11 server is running. */
|
||||
- server.backend = wlr_backend_autocreate(server.wl_display);
|
||||
+ server.backend = wlr_backend_autocreate(server.wl_display, NULL);
|
||||
if (server.backend == NULL) {
|
||||
wlr_log(WLR_ERROR, "failed to create wlr_backend");
|
||||
return 1;
|
||||
diff -uNr a/util/time.c b/util/time.c
|
||||
--- a/util/time.c
|
||||
+++ b/util/time.c
|
||||
@@ -15,7 +15,7 @@
|
||||
r->tv_nsec = nsec % NSEC_PER_SEC;
|
||||
}
|
||||
|
||||
-uint32_t get_current_time_msec(void) {
|
||||
+int64_t get_current_time_msec(void) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return timespec_to_msec(&now);
|
|
@ -0,0 +1,14 @@
|
|||
--- a/protocol/meson.build
|
||||
+++ b/protocol/meson.build
|
||||
@@ -6,10 +6,7 @@
|
||||
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
|
||||
|
||||
wayland_scanner_dep = dependency('wayland-scanner', native: true)
|
||||
-wayland_scanner = find_program(
|
||||
- wayland_scanner_dep.get_variable('wayland_scanner'),
|
||||
- native: true,
|
||||
-)
|
||||
+wayland_scanner = 'wayland-scanner'
|
||||
|
||||
protocols = {
|
||||
# Stable upstream protocols
|
|
@ -0,0 +1,71 @@
|
|||
--- a/util/shm.c
|
||||
+++ b/util/shm.c
|
||||
@@ -9,6 +9,68 @@
|
||||
#include <wlr/config.h>
|
||||
#include "util/shm.h"
|
||||
|
||||
+#ifdef __ANDROID__
|
||||
+#include <alloca.h>
|
||||
+static int shm_unlink(const char *name) {
|
||||
+ size_t namelen;
|
||||
+ char *fname;
|
||||
+
|
||||
+ /* Construct the filename. */
|
||||
+ while (name[0] == '/') ++name;
|
||||
+
|
||||
+ if (name[0] == '\0') {
|
||||
+ /* The name "/" is not supported. */
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ namelen = strlen(name);
|
||||
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
||||
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
||||
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
||||
+
|
||||
+ return unlink(fname);
|
||||
+}
|
||||
+
|
||||
+static int shm_open(const char *name, int oflag, mode_t mode) {
|
||||
+ size_t namelen;
|
||||
+ char *fname;
|
||||
+ int fd;
|
||||
+
|
||||
+ /* Construct the filename. */
|
||||
+ while (name[0] == '/') ++name;
|
||||
+
|
||||
+ if (name[0] == '\0') {
|
||||
+ /* The name "/" is not supported. */
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ namelen = strlen(name);
|
||||
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
||||
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
||||
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
||||
+
|
||||
+ fd = open(fname, oflag, mode);
|
||||
+ if (fd != -1) {
|
||||
+ /* We got a descriptor. Now set the FD_CLOEXEC bit. */
|
||||
+ int flags = fcntl(fd, F_GETFD, 0);
|
||||
+ flags |= FD_CLOEXEC;
|
||||
+ flags = fcntl(fd, F_SETFD, flags);
|
||||
+
|
||||
+ if (flags == -1) {
|
||||
+ /* Something went wrong. We cannot return the descriptor. */
|
||||
+ int save_errno = errno;
|
||||
+ close(fd);
|
||||
+ fd = -1;
|
||||
+ errno = save_errno;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return fd;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#define RANDNAME_PATTERN "/wlroots-XXXXXX"
|
||||
|
||||
static void randname(char *buf) {
|
|
@ -0,0 +1,45 @@
|
|||
--- a/xwayland/sockets.c
|
||||
+++ b/xwayland/sockets.c
|
||||
@@ -14,11 +14,11 @@
|
||||
#include <wlr/util/log.h>
|
||||
#include "sockets.h"
|
||||
|
||||
-static const char lock_fmt[] = "/tmp/.X%d-lock";
|
||||
-static const char socket_dir[] = "/tmp/.X11-unix";
|
||||
-static const char socket_fmt[] = "/tmp/.X11-unix/X%d";
|
||||
+static const char lock_fmt[] = "@TERMUX_PREFIX@/tmp/.X%d-lock";
|
||||
+static const char socket_dir[] = "@TERMUX_PREFIX@/tmp/.X11-unix";
|
||||
+static const char socket_fmt[] = "@TERMUX_PREFIX@/tmp/.X11-unix/X%d";
|
||||
#ifndef __linux__
|
||||
-static const char socket_fmt2[] = "/tmp/.X11-unix/X%d_";
|
||||
+static const char socket_fmt2[] = "@TERMUX_PREFIX@/tmp/.X11-unix/X%d_";
|
||||
#endif
|
||||
|
||||
bool set_cloexec(int fd, bool cloexec) {
|
||||
--- a/xwayland/server.c
|
||||
+++ b/xwayland/server.c
|
||||
@@ -18,6 +18,13 @@
|
||||
#include "sockets.h"
|
||||
#include "xwayland/config.h"
|
||||
|
||||
+#ifdef __TERMUX__
|
||||
+#ifdef XWAYLAND_PATH
|
||||
+#undef XWAYLAND_PATH
|
||||
+#endif
|
||||
+#define XWAYLAND_PATH "@TERMUX_PREFIX@/bin/Xwayland"
|
||||
+#endif
|
||||
+
|
||||
static void safe_close(int fd) {
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
--- a/examples/gamma-control.c
|
||||
+++ b/examples/gamma-control.c
|
||||
@@ -23,7 +23,7 @@
|
||||
static struct zwlr_gamma_control_manager_v1 *gamma_control_manager = NULL;
|
||||
|
||||
static int create_anonymous_file(off_t size) {
|
||||
- char template[] = "/tmp/wlroots-shared-XXXXXX";
|
||||
+ char template[] = "@TERMUX_PREFIX@/tmp/wlroots-shared-XXXXXX";
|
||||
int fd = mkstemp(template);
|
||||
if (fd < 0) {
|
||||
return -1;
|
|
@ -0,0 +1,24 @@
|
|||
TERMUX_PKG_HOMEPAGE=https://gitlab.freedesktop.org/wlroots/wlroots
|
||||
TERMUX_PKG_DESCRIPTION="Modular wayland compositor library"
|
||||
TERMUX_PKG_LICENSE="MIT"
|
||||
TERMUX_PKG_MAINTAINER="@termux"
|
||||
TERMUX_PKG_VERSION="0.16.2"
|
||||
TERMUX_PKG_SRCURL=https://gitlab.freedesktop.org/wlroots/wlroots/-/archive/${TERMUX_PKG_VERSION}/wlroots-${TERMUX_PKG_VERSION}.tar.bz2
|
||||
TERMUX_PKG_SHA256=afea2cc740344c4e86749cf4908e07692e183cb14a3db854d24dec454c664b88
|
||||
TERMUX_PKG_DEPENDS="libdrm, libglvnd, libpixman, libwayland, libxcb, libxkbcommon, xcb-util-renderutil, xcb-util-wm"
|
||||
TERMUX_PKG_BUILD_DEPENDS="libglvnd-dev, libwayland-cross-scanner, libwayland-protocols, xwayland"
|
||||
TERMUX_PKG_RECOMMENDS="xwayland"
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
||||
-Dexamples=false
|
||||
-Dxwayland=enabled
|
||||
-Dsession=disabled
|
||||
-Dbackends=x11
|
||||
-Drenderers=gles2
|
||||
"
|
||||
|
||||
termux_step_pre_configure() {
|
||||
export PATH="$TERMUX_PREFIX/opt/libwayland/cross/bin:$PATH"
|
||||
|
||||
# XXX: use alloca for shm_open
|
||||
export CPPFLAGS+=" -Wno-alloca"
|
||||
}
|
Loading…
Reference in New Issue