mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-01 10:35:43 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b70199bf4d |
No files matched your search
@@ -7,7 +7,6 @@
|
||||
#include "droiddeck-ahb-v1-server-protocol.h"
|
||||
#include <android/hardware_buffer.h>
|
||||
#include <errno.h>
|
||||
#include <linux/sync_file.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
@@ -146,12 +145,6 @@ static void handle_released(uint64_t id, int fd) {
|
||||
if (poll(&p, 1, 0) > 0) {
|
||||
close(fd);
|
||||
} else {
|
||||
if (ab->fence_src) {
|
||||
struct sync_merge_data m = {.name = "droiddeck-release", .fd2 = fd};
|
||||
if (ioctl(ab->fence_fd, SYNC_IOC_MERGE, &m) == 0) { close(fd); fd = m.fence; }
|
||||
wl_event_source_remove(ab->fence_src);
|
||||
close(ab->fence_fd);
|
||||
}
|
||||
ab->fence_fd = fd;
|
||||
ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab);
|
||||
if (!ab->fence_src) { close(fd); ab->fence_fd = -1; }
|
||||
@@ -159,7 +152,6 @@ static void handle_released(uint64_t id, int fd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ab->fence_src) return;
|
||||
send_deferred_release(ab);
|
||||
maybe_free(ab);
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ object BwrapSpawner {
|
||||
private const val PRELOAD_DIR = "/run/droiddeck-preload"
|
||||
private const val NET_LINK = "etc/droiddeck-net"
|
||||
|
||||
private const val ZYPAK_SHIM = "#!/bin/sh\nprogram=\$1\nshift\nexec \"\$program\" --no-sandbox \"\$@\"\n"
|
||||
private const val ZYPAK_SHIM = "#!/bin/sh\nprogram=\$1\nshift\nif [ -n \"\${ELECTRON_RUN_AS_NODE:-}\" ]; then\n exec \"\$program\" \"\$@\"\nfi\nexec \"\$program\" --no-sandbox \"\$@\"\n"
|
||||
|
||||
private fun zypakShims(binds: List<Bind>, root: File, dir: File): List<Bind> {
|
||||
val wrappers = listOf("/app/bin/zypak-wrapper.sh", "/app/bin/zypak-wrapper").filter { guest ->
|
||||
|
||||
@@ -263,6 +263,21 @@ class BwrapSpawnerPlanTest {
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
fun runShim(mode: String?, program: String): List<String> {
|
||||
val executable = File(dir, program).apply { writeText("#!/bin/sh\nprintf '%s\\n' \"\$@\"\n"); setExecutable(true) }
|
||||
val process = ProcessBuilder("/bin/sh", shim.host, executable.path, "argument with spaces", "--user-flag")
|
||||
if (mode == null) process.environment().remove("ELECTRON_RUN_AS_NODE")
|
||||
else process.environment()["ELECTRON_RUN_AS_NODE"] = mode
|
||||
val child = process.start()
|
||||
val output = child.inputStream.bufferedReader().readLines()
|
||||
assertEquals(0, child.waitFor())
|
||||
return output
|
||||
}
|
||||
val args = listOf("argument with spaces", "--user-flag")
|
||||
assertEquals(args, runShim("1", "code"))
|
||||
assertEquals(args, runShim("0", "another-electron-app"))
|
||||
assertEquals(listOf("--no-sandbox") + args, runShim(null, "code"))
|
||||
assertEquals(listOf("--no-sandbox") + args, runShim("", "another-electron-app"))
|
||||
assertFalse(plan.binds.any { it.guest == "/app/bin/zypak-wrapper" })
|
||||
assertTrue(File(app, "bin/zypak-wrapper.sh").readText().contains("zypak-helper"))
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ library list, before anything is published.
|
||||
trip to Xwayland on the paint thread; with no image, wlserver's position is used as upstream does.
|
||||
- `0101-nested-wayland-cursor-routing.patch` - this app: `gamescope_cursor_composite=2` lets the
|
||||
nested Wayland session paint its cursor in the output using the real X pointer position; client
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, and so is Gamescope's
|
||||
default host-cursor fallback, which would otherwise show a second arrow until Gamescope gets
|
||||
keyboard focus. Empty client cursor images and Gamescope's hidden flag still suppress the
|
||||
painted cursor.
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, while Gamescope's original
|
||||
default host-cursor fallback is preserved when its no-keyboard-focus policy selects it. Empty
|
||||
client cursor images and Gamescope's hidden flag still suppress the painted cursor.
|
||||
- `0110-wayland-backend-touch.patch` - this app: the nested Wayland backend bound only the host's
|
||||
pointer and keyboard, so a finger on the phone's screen never reached Steam. It now binds
|
||||
`wl_touch` too and hands each finger to wlserver's touch path (`wlserver_touchdown` / `motion` /
|
||||
|
||||
@@ -74,7 +74,7 @@ index 0000000..d7c21da
|
||||
+
|
||||
+ constexpr bool CursorShouldBeForwardedToHost( int cursorCompositeMode, bool useHostCursorFallback )
|
||||
+ {
|
||||
+ return cursorCompositeMode != 2;
|
||||
+ return cursorCompositeMode != 2 || useHostCursorFallback;
|
||||
+ }
|
||||
+
|
||||
+ constexpr bool CursorImageShouldBePainted( bool imageEmpty, bool cursorHidden )
|
||||
@@ -176,10 +176,10 @@ index 0000000..9c622db
|
||||
+ REQUIRE( CursorShouldBeComposited( 2, false, false, true, false ) );
|
||||
+}
|
||||
+
|
||||
+TEST_CASE("manual composition never forwards a cursor to the host", "[cursor_routing]")
|
||||
+TEST_CASE("manual composition retains only the no-focus default cursor fallback", "[cursor_routing]")
|
||||
+{
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, false ) );
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 1, false ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 0, false ) );
|
||||
+}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f7dd44d2
|
||||
GAMESCOPE_SHA256=a034c36d44f9bca4abc804bda3958c8d303f1ce304fb677375e5d7aa233287a9
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f3a45b31
|
||||
GAMESCOPE_SHA256=3908af87b2ee8a328e9780fc805c6a7bddd11d7405b9992d717b94e16c019313
|
||||
@@ -35,21 +35,13 @@ STRUCT
|
||||
static struct wl_list g_bufs;
|
||||
static struct wl_event_loop *g_loop;
|
||||
static int g_import_failed_logged;
|
||||
static int import_ok, imports, imported_flags, deferred_releases, frees, sources, removes, merge_ok, merges;
|
||||
static struct wl_event_source g_sources[4];
|
||||
static struct wl_event_source *g_removed;
|
||||
static int import_ok, imports, imported_flags, deferred_releases, frees, sources;
|
||||
static struct wl_event_source g_source;
|
||||
void wl_list_init(struct wl_list *l) { l->prev = l; l->next = l; }
|
||||
void wl_list_insert(struct wl_list *l, struct wl_list *e) {
|
||||
e->next = l->next; e->prev = l; l->next->prev = e; l->next = e;
|
||||
}
|
||||
static int fake_ioctl(int fd, unsigned long req, void *arg) {
|
||||
if (req == SYNC_IOC_MERGE) {
|
||||
struct sync_merge_data *m = arg;
|
||||
assert(fd >= 0 && m->fd2 >= 0 && fd != m->fd2);
|
||||
++merges;
|
||||
if (!merge_ok) { errno = ENOTTY; return -1; }
|
||||
m->fence = dup(m->fd2); return 0;
|
||||
}
|
||||
struct droiddeck_dma_buf_sync_file *f = arg;
|
||||
(void)fd;
|
||||
assert(req == DROIDDECK_DMA_BUF_IOCTL_IMPORT_SYNC_FILE);
|
||||
@@ -62,17 +54,13 @@ static int droiddeck_dmabuf_fd(struct dmabuf_buffer *b) { return b->fd; }
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; }
|
||||
static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t m,
|
||||
int (*cb)(int, uint32_t, void *), void *d) {
|
||||
(void)l; (void)fd; (void)m; (void)cb; (void)d; return &g_sources[sources++];
|
||||
(void)l; (void)fd; (void)m; (void)cb; (void)d; ++sources; return &g_source;
|
||||
}
|
||||
static void wl_event_source_remove(struct wl_event_source *s) { assert(s); ++removes; g_removed = s; }
|
||||
static int on_fence_readable(int fd, uint32_t mask, void *data) { (void)fd; (void)mask; (void)data; return 0; }
|
||||
static void send_deferred_release(struct ahb_buf *ab) { ++deferred_releases; ab->release_pending = 0; }
|
||||
static void maybe_free(struct ahb_buf *ab) { (void)ab; ++frees; }
|
||||
FUNCTIONS
|
||||
static void reset(void) {
|
||||
import_ok = imports = imported_flags = deferred_releases = frees = sources = removes = merge_ok = merges = 0;
|
||||
g_removed = NULL;
|
||||
}
|
||||
static void reset(void) { import_ok = imports = imported_flags = deferred_releases = frees = sources = 0; }
|
||||
static void run(int display, int can_import, int fence_signalled) {
|
||||
reset();
|
||||
wl_list_init(&g_bufs);
|
||||
@@ -90,48 +78,12 @@ static void run(int display, int can_import, int fence_signalled) {
|
||||
assert(deferred_releases == 1 && frees == 1 && !ab.fence_src && ab.fence_fd == -1);
|
||||
errno = 0; assert(fcntl(fds[0], F_GETFD) == -1 && errno == EBADF);
|
||||
} else {
|
||||
assert(deferred_releases == 0 && sources == 1 && ab.fence_src == &g_sources[0] && ab.fence_fd == fds[0]);
|
||||
assert(deferred_releases == 0 && sources == 1 && ab.fence_src == &g_source && ab.fence_fd == fds[0]);
|
||||
close(fds[0]);
|
||||
}
|
||||
close(fds[1]);
|
||||
}
|
||||
static int closed(int fd) { errno = 0; return fcntl(fd, F_GETFD) == -1 && errno == EBADF; }
|
||||
static void rerelease(int can_merge, int second_import, int second_signalled) {
|
||||
reset();
|
||||
wl_list_init(&g_bufs);
|
||||
struct dmabuf_buffer b = {.fd = 7};
|
||||
struct ahb_buf ab;
|
||||
memset(&ab, 0, sizeof(ab));
|
||||
ab.id = 42; ab.b = &b; ab.on_layer = 1; ab.release_pending = 1; ab.fence_fd = -1;
|
||||
wl_list_insert(&g_bufs, &ab.link);
|
||||
int first[2], second[2];
|
||||
assert(pipe(first) == 0 && pipe(second) == 0);
|
||||
handle_released(42, first[0]);
|
||||
assert(ab.fence_src == &g_sources[0] && ab.fence_fd == first[0] && deferred_releases == 0);
|
||||
ab.on_layer = 1;
|
||||
if (second_signalled) assert(write(second[1], "x", 1) == 1);
|
||||
import_ok = second_import; merge_ok = can_merge;
|
||||
handle_released(42, second[0]);
|
||||
assert(!ab.on_layer && deferred_releases == 0 && frees == 0);
|
||||
if (second_import || second_signalled) {
|
||||
assert(removes == 0 && merges == 0 && sources == 1 && ab.fence_src == &g_sources[0] && ab.fence_fd == first[0]);
|
||||
assert(closed(second[0]));
|
||||
close(first[0]);
|
||||
} else {
|
||||
assert(merges == 1 && removes == 1 && g_removed == &g_sources[0]);
|
||||
assert(sources == 2 && ab.fence_src == &g_sources[1] && ab.fence_fd >= 0);
|
||||
assert(closed(first[0]));
|
||||
if (can_merge) assert(closed(second[0]) && ab.fence_fd != second[0]);
|
||||
else assert(ab.fence_fd == second[0]);
|
||||
close(ab.fence_fd);
|
||||
}
|
||||
close(first[1]); close(second[1]);
|
||||
}
|
||||
int main(int argc, char **argv) {
|
||||
if (argc == 5 && !strcmp(argv[1], "rerelease")) {
|
||||
rerelease(atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
|
||||
return 0;
|
||||
}
|
||||
assert(argc == 4);
|
||||
run(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
|
||||
return 0;
|
||||
@@ -151,7 +103,7 @@ class ZeroCopyReleaseAtLatchTest(unittest.TestCase):
|
||||
ahb, re.M))
|
||||
struct = re.search(r'struct ahb_buf \{.*?\n\};', ahb, re.S).group()
|
||||
functions = '\n'.join(function(ahb, n) for n in ('find_buf', 'handle_released'))
|
||||
source = HARNESS.replace('DEFINES', '#include <fcntl.h>\n#include <linux/sync_file.h>\n#include <sys/ioctl.h>\n' + defines)
|
||||
source = HARNESS.replace('DEFINES', '#include <fcntl.h>\n#include <sys/ioctl.h>\n' + defines)
|
||||
source = source.replace('STRUCT', struct).replace('FUNCTIONS', functions)
|
||||
cls.tmp = tempfile.TemporaryDirectory(prefix='droiddeck-release-latch-')
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
@@ -184,23 +136,6 @@ class ZeroCopyReleaseAtLatchTest(unittest.TestCase):
|
||||
def test_signalled_fence_releases_without_waiting(self):
|
||||
self.scenario(1, 0, 1)
|
||||
|
||||
def rerelease(self, can_merge, second_import, second_signalled):
|
||||
result = subprocess.run([str(self.binary), 'rerelease', str(can_merge), str(second_import), str(second_signalled)],
|
||||
capture_output=True, text=True, timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_second_unsignalled_fence_merges_into_the_pending_wait(self):
|
||||
self.rerelease(1, 0, 0)
|
||||
|
||||
def test_second_unsignalled_fence_replaces_the_wait_when_merge_fails(self):
|
||||
self.rerelease(0, 0, 0)
|
||||
|
||||
def test_second_imported_fence_keeps_the_pending_wait(self):
|
||||
self.rerelease(1, 1, 0)
|
||||
|
||||
def test_second_signalled_fence_keeps_the_pending_wait(self):
|
||||
self.rerelease(1, 0, 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user