screen-relay 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/Makefile +165 -0
- package/README.md +113 -2
- package/THIRD-PARTY-NOTICES.md +75 -0
- package/dist/cli/client.d.ts +28 -0
- package/dist/cli/commands.d.ts +52 -0
- package/dist/cli/config.d.ts +32 -0
- package/dist/cli/format.d.ts +15 -0
- package/dist/cli/help.d.ts +5 -0
- package/dist/cli/host/common.d.ts +23 -0
- package/dist/cli/host/doctor.d.ts +2 -0
- package/dist/cli/host/packages.d.ts +13 -0
- package/dist/cli/host/session_commands.d.ts +8 -0
- package/dist/cli/host/setup.d.ts +22 -0
- package/dist/cli/host/state.d.ts +23 -0
- package/dist/cli/host/supervisor.d.ts +91 -0
- package/dist/cli/host/watcher.d.ts +4 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/mode.d.ts +14 -0
- package/dist/cli/output.d.ts +24 -0
- package/dist/cli/parser.d.ts +6 -0
- package/dist/cli/relay.mjs +12247 -0
- package/dist/cli/skills.d.ts +21 -0
- package/dist/cli/theme.d.ts +14 -0
- package/dist/protocol/errors.d.ts +155 -0
- package/dist/protocol/index.d.ts +119 -0
- package/dist/protocol/index.js +418 -0
- package/dist/sdk/index.d.ts +77 -0
- package/dist/sdk/index.js +724 -0
- package/dist/viewer/index.html +96 -0
- package/dist/viewer/viewer.js +1052 -0
- package/package.json +50 -4
- package/packages.tsv +38 -0
- package/skills/core/SKILL.md +169 -0
- package/skills/core/references/cli.md +119 -0
- package/skills/core/references/config.md +48 -0
- package/skills/core/references/macos.md +50 -0
- package/skills/core/references/sdk.md +69 -0
- package/skills/core/references/troubleshooting.md +33 -0
- package/skills/core/references/wayland.md +47 -0
- package/skills/screen-relay/SKILL.md +24 -0
- package/skills/vercel-sandbox/SKILL.md +68 -0
- package/src/engine/backends/linux/keycodes.hpp +35 -0
- package/src/engine/backends/linux/wayland/capture.cpp +298 -0
- package/src/engine/backends/linux/wayland/input.cpp +559 -0
- package/src/engine/backends/linux/wayland/keymap.cpp +118 -0
- package/src/engine/backends/linux/wayland/keymap.hpp +54 -0
- package/src/engine/backends/linux/wayland/protocols/virtual-keyboard-unstable-v1.xml +112 -0
- package/src/engine/backends/linux/wayland/protocols/wlr-screencopy-unstable-v1.xml +234 -0
- package/src/engine/backends/linux/wayland/protocols/wlr-virtual-pointer-unstable-v1.xml +152 -0
- package/src/engine/backends/linux/wayland/wayland.cpp +166 -0
- package/src/engine/backends/linux/wayland/wayland.hpp +60 -0
- package/src/engine/backends/linux/x11/capture.cpp +206 -0
- package/src/engine/backends/linux/x11/input.cpp +266 -0
- package/src/engine/backends/macos/capture.mm +367 -0
- package/src/engine/backends/macos/display.hpp +20 -0
- package/src/engine/backends/macos/display.mm +84 -0
- package/src/engine/backends/macos/input.mm +287 -0
- package/src/engine/backends/macos/keys.hpp +34 -0
- package/src/engine/backends/windows/capture.cpp +393 -0
- package/src/engine/backends/windows/input.cpp +274 -0
- package/src/engine/backends/windows/output.cpp +65 -0
- package/src/engine/backends/windows/output.hpp +26 -0
- package/src/engine/core/capture-bucket.hpp +40 -0
- package/src/engine/core/capture-source.hpp +59 -0
- package/src/engine/core/capture.cpp +565 -0
- package/src/engine/core/capture.hpp +58 -0
- package/src/engine/core/color.cpp +176 -0
- package/src/engine/core/color.hpp +16 -0
- package/src/engine/core/cpu-budget.hpp +196 -0
- package/src/engine/core/flow.hpp +317 -0
- package/src/engine/core/input.cpp +98 -0
- package/src/engine/core/input.hpp +115 -0
- package/src/engine/core/wait.cpp +125 -0
- package/src/engine/core/wait.hpp +41 -0
- package/src/engine/server/backend.cpp +65 -0
- package/src/engine/server/backend.hpp +18 -0
- package/src/engine/server/config.cpp +257 -0
- package/src/engine/server/config.hpp +24 -0
- package/src/engine/server/main.cpp +82 -0
- package/src/engine/server/metrics.cpp +47 -0
- package/src/engine/server/metrics.hpp +10 -0
- package/src/engine/server/screenshot.cpp +108 -0
- package/src/engine/server/screenshot.hpp +31 -0
- package/src/engine/server/server.cpp +531 -0
- package/src/engine/server/server.hpp +88 -0
- package/src/engine/server/wire.cpp +65 -0
- package/src/engine/server/wire.hpp +27 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#include "wayland.hpp"
|
|
2
|
+
#include <algorithm>
|
|
3
|
+
#include <cstdlib>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
|
|
7
|
+
namespace relay::wayland {
|
|
8
|
+
struct OutputInfo {
|
|
9
|
+
wl_output* proxy = nullptr;
|
|
10
|
+
std::string name;
|
|
11
|
+
uint32_t version = 0;
|
|
12
|
+
int width = 0;
|
|
13
|
+
int height = 0;
|
|
14
|
+
|
|
15
|
+
~OutputInfo() {
|
|
16
|
+
if (proxy) wl_output_destroy(proxy);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
namespace {
|
|
21
|
+
std::string selectedOutputName;
|
|
22
|
+
|
|
23
|
+
struct RegistryState {
|
|
24
|
+
Connection* connection;
|
|
25
|
+
std::vector<std::unique_ptr<OutputInfo>> outputs;
|
|
26
|
+
bool outputListenerFailed = false;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
void outputNoop(void*, wl_output*, int32_t, int32_t, int32_t, int32_t, int32_t,
|
|
30
|
+
const char*, const char*, int32_t) {}
|
|
31
|
+
void outputNoop(void*, wl_output*) {}
|
|
32
|
+
void outputNoop(void*, wl_output*, int32_t) {}
|
|
33
|
+
void outputNoop(void*, wl_output*, const char*) {}
|
|
34
|
+
|
|
35
|
+
void outputMode(void* data, wl_output*, uint32_t flags, int32_t width, int32_t height, int32_t) {
|
|
36
|
+
auto* output = static_cast<OutputInfo*>(data);
|
|
37
|
+
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
|
38
|
+
output->width = width;
|
|
39
|
+
output->height = height;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void outputName(void* data, wl_output*, const char* name) {
|
|
44
|
+
static_cast<OutputInfo*>(data)->name = name ? name : "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const wl_output_listener outputListener = {
|
|
48
|
+
outputNoop, outputMode, outputNoop, outputNoop, outputName, outputNoop
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
void global(void* data, wl_registry* registry, uint32_t name, const char* interface, uint32_t version) {
|
|
52
|
+
auto* state = static_cast<RegistryState*>(data);
|
|
53
|
+
auto& connection = *state->connection;
|
|
54
|
+
if (state->outputListenerFailed) return;
|
|
55
|
+
if (std::strcmp(interface, wl_shm_interface.name) == 0 && !connection.shm) {
|
|
56
|
+
connection.shm = static_cast<wl_shm*>(wl_registry_bind(registry, name, &wl_shm_interface, std::min(version, 1u)));
|
|
57
|
+
} else if (std::strcmp(interface, wl_output_interface.name) == 0) {
|
|
58
|
+
auto output = std::make_unique<OutputInfo>();
|
|
59
|
+
output->version = version;
|
|
60
|
+
output->proxy = static_cast<wl_output*>(wl_registry_bind(registry, name, &wl_output_interface, std::min(version, 4u)));
|
|
61
|
+
if (wl_output_add_listener(output->proxy, &outputListener, output.get()) < 0) {
|
|
62
|
+
state->outputListenerFailed = true;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
state->outputs.push_back(std::move(output));
|
|
66
|
+
} else if (std::strcmp(interface, zwlr_screencopy_manager_v1_interface.name) == 0 && !connection.screencopyManager) {
|
|
67
|
+
connection.screencopyManager = static_cast<zwlr_screencopy_manager_v1*>(wl_registry_bind(
|
|
68
|
+
registry, name, &zwlr_screencopy_manager_v1_interface, std::min(version, 3u)));
|
|
69
|
+
} else if (std::strcmp(interface, zwp_virtual_keyboard_manager_v1_interface.name) == 0 && !connection.virtualKeyboardManager) {
|
|
70
|
+
connection.virtualKeyboardManager = static_cast<zwp_virtual_keyboard_manager_v1*>(wl_registry_bind(
|
|
71
|
+
registry, name, &zwp_virtual_keyboard_manager_v1_interface, 1));
|
|
72
|
+
} else if (std::strcmp(interface, zwlr_virtual_pointer_manager_v1_interface.name) == 0 &&
|
|
73
|
+
version >= 2 && !connection.virtualPointerManager) {
|
|
74
|
+
connection.virtualPointerManager = static_cast<zwlr_virtual_pointer_manager_v1*>(wl_registry_bind(
|
|
75
|
+
registry, name, &zwlr_virtual_pointer_manager_v1_interface, 2));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void globalRemove(void*, wl_registry*, uint32_t) {}
|
|
80
|
+
|
|
81
|
+
const wl_registry_listener registryListener = {global, globalRemove};
|
|
82
|
+
|
|
83
|
+
std::string availableOutputs(const std::vector<std::unique_ptr<OutputInfo>>& outputs) {
|
|
84
|
+
std::string names;
|
|
85
|
+
for (const auto& output : outputs) {
|
|
86
|
+
if (!names.empty()) names += ", ";
|
|
87
|
+
names += output->name.empty() ? "<unnamed>" : output->name;
|
|
88
|
+
}
|
|
89
|
+
return names.empty() ? "(none)" : names;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Connection::Connection() {
|
|
94
|
+
display = wl_display_connect(nullptr);
|
|
95
|
+
if (!display) {
|
|
96
|
+
const char* name = std::getenv("WAYLAND_DISPLAY");
|
|
97
|
+
throw std::runtime_error("Cannot connect to Wayland display '" + std::string(name ? name : "wayland-0") +
|
|
98
|
+
"'; check WAYLAND_DISPLAY and XDG_RUNTIME_DIR");
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
initialize();
|
|
102
|
+
} catch (...) {
|
|
103
|
+
cleanup();
|
|
104
|
+
throw;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Connection::~Connection() { cleanup(); }
|
|
109
|
+
|
|
110
|
+
void Connection::initialize() {
|
|
111
|
+
registry_ = wl_display_get_registry(display);
|
|
112
|
+
if (!registry_) throw std::runtime_error("Could not get Wayland registry");
|
|
113
|
+
RegistryState state{this, {}, false};
|
|
114
|
+
if (wl_registry_add_listener(registry_, ®istryListener, &state) < 0)
|
|
115
|
+
throw std::runtime_error("Could not listen to Wayland registry");
|
|
116
|
+
if (wl_display_roundtrip(display) < 0) throw std::runtime_error("Wayland registry roundtrip failed");
|
|
117
|
+
if (state.outputListenerFailed) throw std::runtime_error("Could not listen to wl_output");
|
|
118
|
+
if (wl_display_roundtrip(display) < 0) throw std::runtime_error("Wayland output roundtrip failed");
|
|
119
|
+
if (state.outputListenerFailed) throw std::runtime_error("Could not listen to wl_output");
|
|
120
|
+
auto selected = state.outputs.begin();
|
|
121
|
+
if (!selectedOutputName.empty()) {
|
|
122
|
+
selected = std::find_if(state.outputs.begin(), state.outputs.end(), [](const auto& output) {
|
|
123
|
+
return output->name == selectedOutputName;
|
|
124
|
+
});
|
|
125
|
+
if (selected == state.outputs.end()) {
|
|
126
|
+
std::string message = "Unknown Wayland output '" + selectedOutputName + "'; available outputs: " +
|
|
127
|
+
availableOutputs(state.outputs);
|
|
128
|
+
if (std::any_of(state.outputs.begin(), state.outputs.end(), [](const auto& output) {
|
|
129
|
+
return output->version < 4;
|
|
130
|
+
}))
|
|
131
|
+
message += "; output names require wl_output version 4";
|
|
132
|
+
throw std::runtime_error(message);
|
|
133
|
+
}
|
|
134
|
+
} else if (selected == state.outputs.end()) {
|
|
135
|
+
throw std::runtime_error("No Wayland outputs available; available outputs: (none)");
|
|
136
|
+
}
|
|
137
|
+
outputInfo_ = std::move(*selected);
|
|
138
|
+
output = outputInfo_->proxy;
|
|
139
|
+
width = outputInfo_->width;
|
|
140
|
+
height = outputInfo_->height;
|
|
141
|
+
wl_registry_destroy(registry_);
|
|
142
|
+
registry_ = nullptr;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
void Connection::cleanup() {
|
|
146
|
+
if (virtualPointerManager) zwlr_virtual_pointer_manager_v1_destroy(virtualPointerManager);
|
|
147
|
+
if (virtualKeyboardManager) zwp_virtual_keyboard_manager_v1_destroy(virtualKeyboardManager);
|
|
148
|
+
if (screencopyManager) zwlr_screencopy_manager_v1_destroy(screencopyManager);
|
|
149
|
+
if (shm) wl_shm_destroy(shm);
|
|
150
|
+
if (registry_) wl_registry_destroy(registry_);
|
|
151
|
+
outputInfo_.reset();
|
|
152
|
+
if (display) wl_display_disconnect(display);
|
|
153
|
+
virtualPointerManager = nullptr;
|
|
154
|
+
virtualKeyboardManager = nullptr;
|
|
155
|
+
screencopyManager = nullptr;
|
|
156
|
+
shm = nullptr;
|
|
157
|
+
registry_ = nullptr;
|
|
158
|
+
output = nullptr;
|
|
159
|
+
display = nullptr;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
bool initializeNativeBackend(const std::string& output) {
|
|
163
|
+
selectedOutputName = output;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "virtual-keyboard-unstable-v1-client-protocol.h"
|
|
4
|
+
#include "wlr-screencopy-unstable-v1-client-protocol.h"
|
|
5
|
+
#include "wlr-virtual-pointer-unstable-v1-client-protocol.h"
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <sys/mman.h>
|
|
10
|
+
#include <unistd.h>
|
|
11
|
+
#include <vector>
|
|
12
|
+
#include <wayland-client.h>
|
|
13
|
+
|
|
14
|
+
namespace relay::wayland {
|
|
15
|
+
struct OutputInfo;
|
|
16
|
+
|
|
17
|
+
inline void require(bool ok, const char* message) {
|
|
18
|
+
if (!ok) throw std::runtime_error(message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class FileDescriptor {
|
|
22
|
+
public:
|
|
23
|
+
explicit FileDescriptor(int fd = -1) : fd_(fd) {}
|
|
24
|
+
~FileDescriptor() { if (fd_ >= 0) ::close(fd_); }
|
|
25
|
+
FileDescriptor(const FileDescriptor&) = delete;
|
|
26
|
+
FileDescriptor& operator=(const FileDescriptor&) = delete;
|
|
27
|
+
int get() const { return fd_; }
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
int fd_;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
inline FileDescriptor createMemfd(const char* name) {
|
|
34
|
+
return FileDescriptor(::memfd_create(name, MFD_CLOEXEC));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
struct Connection {
|
|
38
|
+
wl_display* display = nullptr;
|
|
39
|
+
wl_shm* shm = nullptr;
|
|
40
|
+
wl_output* output = nullptr;
|
|
41
|
+
int width = 0;
|
|
42
|
+
int height = 0;
|
|
43
|
+
zwlr_screencopy_manager_v1* screencopyManager = nullptr;
|
|
44
|
+
zwp_virtual_keyboard_manager_v1* virtualKeyboardManager = nullptr;
|
|
45
|
+
zwlr_virtual_pointer_manager_v1* virtualPointerManager = nullptr;
|
|
46
|
+
|
|
47
|
+
Connection();
|
|
48
|
+
~Connection();
|
|
49
|
+
Connection(const Connection&) = delete;
|
|
50
|
+
Connection& operator=(const Connection&) = delete;
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
wl_registry* registry_ = nullptr;
|
|
54
|
+
std::unique_ptr<OutputInfo> outputInfo_;
|
|
55
|
+
void initialize();
|
|
56
|
+
void cleanup();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
bool initializeNativeBackend(const std::string& output);
|
|
60
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#include "core/capture-source.hpp"
|
|
2
|
+
#include <X11/Xlib.h>
|
|
3
|
+
#include <X11/Xutil.h>
|
|
4
|
+
#include <X11/extensions/Xdamage.h>
|
|
5
|
+
#include <X11/extensions/XShm.h>
|
|
6
|
+
#include <X11/extensions/Xfixes.h>
|
|
7
|
+
#include <sys/shm.h>
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <stdexcept>
|
|
10
|
+
#include <mutex>
|
|
11
|
+
#include <algorithm>
|
|
12
|
+
#include <memory>
|
|
13
|
+
#include <vector>
|
|
14
|
+
namespace relay {
|
|
15
|
+
namespace {
|
|
16
|
+
void require(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
|
17
|
+
// Xlib's handler is process-wide; the attach probe is limited to this Display.
|
|
18
|
+
std::atomic<Display*> probe_display{nullptr};
|
|
19
|
+
std::atomic<bool> probe_error{false};
|
|
20
|
+
std::atomic<XErrorHandler> previous_handler{nullptr};
|
|
21
|
+
std::mutex attach_mutex;
|
|
22
|
+
int attachError(Display* display, XErrorEvent* event) {
|
|
23
|
+
if (display == probe_display.load()) { probe_error = true; return 0; }
|
|
24
|
+
const auto previous = previous_handler.load();
|
|
25
|
+
return previous ? previous(display, event) : 0;
|
|
26
|
+
}
|
|
27
|
+
class X11CaptureSource final : public CaptureSource {
|
|
28
|
+
Display* display = nullptr;
|
|
29
|
+
Damage damage = 0;
|
|
30
|
+
XserverRegion parts = 0;
|
|
31
|
+
std::vector<DamageRect> rects;
|
|
32
|
+
bool rects_valid = false;
|
|
33
|
+
XImage* image = nullptr;
|
|
34
|
+
XShmSegmentInfo shm{};
|
|
35
|
+
bool attached = false;
|
|
36
|
+
int damage_event = 0;
|
|
37
|
+
int cursor_event = 0;
|
|
38
|
+
int width = 0, height = 0;
|
|
39
|
+
bool cursor_dirty = true;
|
|
40
|
+
public:
|
|
41
|
+
X11CaptureSource() { shm.shmid = -1; shm.shmaddr = reinterpret_cast<char*>(-1); }
|
|
42
|
+
~X11CaptureSource() override {
|
|
43
|
+
if (attached) { XShmDetach(display, &shm); XSync(display, False); }
|
|
44
|
+
if (image) { image->data = nullptr; XDestroyImage(image); }
|
|
45
|
+
if (shm.shmaddr != reinterpret_cast<char*>(-1)) shmdt(shm.shmaddr);
|
|
46
|
+
if (shm.shmid >= 0) shmctl(shm.shmid, IPC_RMID, nullptr);
|
|
47
|
+
if (parts) XFixesDestroyRegion(display, parts);
|
|
48
|
+
if (damage) XDamageDestroy(display, damage);
|
|
49
|
+
if (display) XCloseDisplay(display);
|
|
50
|
+
}
|
|
51
|
+
void init() {
|
|
52
|
+
display = XOpenDisplay(nullptr);
|
|
53
|
+
require(display, "opening X display failed");
|
|
54
|
+
int ignored;
|
|
55
|
+
require(XDamageQueryExtension(display, &damage_event, &ignored), "XDamage unavailable");
|
|
56
|
+
int major = 1, minor = 0;
|
|
57
|
+
require(XFixesQueryExtension(display, &cursor_event, &ignored) &&
|
|
58
|
+
XFixesQueryVersion(display, &major, &minor) && major >= 1, "XFixes cursor tracking unavailable");
|
|
59
|
+
require(XShmQueryExtension(display), "MIT-SHM unavailable");
|
|
60
|
+
const int screen = DefaultScreen(display);
|
|
61
|
+
width = DisplayWidth(display, screen); height = DisplayHeight(display, screen);
|
|
62
|
+
image = XShmCreateImage(display, DefaultVisual(display, screen), DefaultDepth(display, screen),
|
|
63
|
+
ZPixmap, nullptr, &shm, width, height);
|
|
64
|
+
require(image && image->bytes_per_line >= width * 4 && image->bytes_per_line <= width * 8 &&
|
|
65
|
+
image->bits_per_pixel == 32 && image->red_mask == 0xff0000 &&
|
|
66
|
+
image->green_mask == 0xff00 && image->blue_mask == 0xff,
|
|
67
|
+
"unsupported X image masks, depth, or stride");
|
|
68
|
+
require(image->byte_order == LSBFirst || image->byte_order == MSBFirst,
|
|
69
|
+
"unsupported X image byte order");
|
|
70
|
+
const size_t size = static_cast<size_t>(image->bytes_per_line) * image->height;
|
|
71
|
+
shm.shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600);
|
|
72
|
+
require(shm.shmid >= 0, "shmget failed");
|
|
73
|
+
shm.shmaddr = static_cast<char*>(shmat(shm.shmid, nullptr, 0));
|
|
74
|
+
require(shm.shmaddr != reinterpret_cast<char*>(-1), "shmat failed");
|
|
75
|
+
image->data = shm.shmaddr; shm.readOnly = False;
|
|
76
|
+
std::lock_guard<std::mutex> lock(attach_mutex);
|
|
77
|
+
XSync(display, False);
|
|
78
|
+
probe_display = display; probe_error = false;
|
|
79
|
+
previous_handler = XSetErrorHandler(attachError);
|
|
80
|
+
const bool requested = XShmAttach(display, &shm);
|
|
81
|
+
XSync(display, False);
|
|
82
|
+
XSetErrorHandler(previous_handler.load()); probe_display = nullptr;
|
|
83
|
+
attached = requested && !probe_error;
|
|
84
|
+
require(attached, "XShmAttach failed");
|
|
85
|
+
require(shmctl(shm.shmid, IPC_RMID, nullptr) == 0, "marking shared memory for removal failed");
|
|
86
|
+
shm.shmid = -1;
|
|
87
|
+
damage = XDamageCreate(display, RootWindow(display, screen), XDamageReportNonEmpty);
|
|
88
|
+
require(damage != 0, "creating XDamage failed");
|
|
89
|
+
parts = XFixesCreateRegion(display, nullptr, 0);
|
|
90
|
+
XFixesSelectCursorInput(display, RootWindow(display, screen), XFixesDisplayCursorNotifyMask);
|
|
91
|
+
XFlush(display);
|
|
92
|
+
}
|
|
93
|
+
int fd() const override { return ConnectionNumber(display); }
|
|
94
|
+
std::pair<int, int> dimensions() const override { return {width, height}; }
|
|
95
|
+
bool drainDamage() override {
|
|
96
|
+
bool dirty = false;
|
|
97
|
+
while (XPending(display)) {
|
|
98
|
+
XEvent event; XNextEvent(display, &event);
|
|
99
|
+
if (event.type == damage_event + XDamageNotify) dirty = true;
|
|
100
|
+
if (event.type == cursor_event + XFixesCursorNotify) cursor_dirty = true;
|
|
101
|
+
}
|
|
102
|
+
return dirty;
|
|
103
|
+
}
|
|
104
|
+
bool cursorSupported() const override { return true; }
|
|
105
|
+
std::optional<CursorImage> cursor(bool force) override {
|
|
106
|
+
if (!force && !cursor_dirty) return std::nullopt;
|
|
107
|
+
cursor_dirty = false;
|
|
108
|
+
std::unique_ptr<XFixesCursorImage, decltype(&XFree)> image(XFixesGetCursorImage(display), &XFree);
|
|
109
|
+
CursorImage result;
|
|
110
|
+
// Bound an application-provided image; never leave a previous shape stuck on failure.
|
|
111
|
+
if (!image || !image->width || !image->height ||
|
|
112
|
+
image->width > CursorImage::max_extent || image->height > CursorImage::max_extent ||
|
|
113
|
+
image->xhot >= image->width || image->yhot >= image->height) return result;
|
|
114
|
+
result.width = image->width; result.height = image->height;
|
|
115
|
+
result.xhot = image->xhot; result.yhot = image->yhot;
|
|
116
|
+
result.rgba.resize(size_t(result.width) * result.height * 4);
|
|
117
|
+
for (size_t pixel = 0; pixel < result.rgba.size() / 4; ++pixel) {
|
|
118
|
+
// Xlib uses unsigned long even on LP64; XFixes colors are premultiplied ARGB.
|
|
119
|
+
const uint32_t argb = uint32_t(image->pixels[pixel]);
|
|
120
|
+
const unsigned alpha = argb >> 24;
|
|
121
|
+
for (unsigned channel = 0; channel < 3; ++channel) {
|
|
122
|
+
const unsigned component = (argb >> (16 - channel * 8)) & 255;
|
|
123
|
+
result.rgba[pixel * 4 + channel] = alpha ? std::min(255u, (component * 255 + alpha / 2) / alpha) : 0;
|
|
124
|
+
}
|
|
125
|
+
result.rgba[pixel * 4 + 3] = alpha;
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
PixelFormat pixelFormat() const override {
|
|
130
|
+
return image->byte_order == LSBFirst ? PixelFormat::BGRA : PixelFormat::ARGB;
|
|
131
|
+
}
|
|
132
|
+
bool changedRects(std::vector<DamageRect>& out) override {
|
|
133
|
+
if (!rects_valid) return false;
|
|
134
|
+
out = rects;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
void collectDamage() {
|
|
138
|
+
XDamageSubtract(display, damage, None, parts);
|
|
139
|
+
rects.clear(); rects_valid = false;
|
|
140
|
+
int count = 0;
|
|
141
|
+
std::unique_ptr<XRectangle, decltype(&XFree)> fetched(XFixesFetchRegion(display, parts, &count), &XFree);
|
|
142
|
+
if (fetched && count > 0) {
|
|
143
|
+
for (int i = 0; i < count; ++i)
|
|
144
|
+
rects.push_back({fetched.get()[i].x, fetched.get()[i].y, fetched.get()[i].width, fetched.get()[i].height});
|
|
145
|
+
rects_valid = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
FrameView grab(int x, int y, int width, int height) {
|
|
149
|
+
const Window root = RootWindow(display, DefaultScreen(display));
|
|
150
|
+
if (x == 0 && y == 0 && width == image->width && height == image->height) {
|
|
151
|
+
require(XShmGetImage(display, root, image, 0, 0, AllPlanes), "XShmGetImage failed");
|
|
152
|
+
return {reinterpret_cast<const uint8_t*>(image->data), image->bytes_per_line,
|
|
153
|
+
image->width, image->height, pixelFormat(), 0, 0};
|
|
154
|
+
}
|
|
155
|
+
XImage* scratch = XShmCreateImage(display, DefaultVisual(display, DefaultScreen(display)),
|
|
156
|
+
DefaultDepth(display, DefaultScreen(display)), ZPixmap,
|
|
157
|
+
shm.shmaddr, &shm, width, height);
|
|
158
|
+
require(scratch, "creating sub-rect X image failed");
|
|
159
|
+
scratch->data = shm.shmaddr;
|
|
160
|
+
require(scratch->bytes_per_line == width * 4, "unexpected sub-rect X image stride");
|
|
161
|
+
const bool ok = XShmGetImage(display, root, scratch, x, y, AllPlanes);
|
|
162
|
+
FrameView view{reinterpret_cast<const uint8_t*>(scratch->data), scratch->bytes_per_line,
|
|
163
|
+
width, height, pixelFormat(), x, y};
|
|
164
|
+
scratch->data = nullptr;
|
|
165
|
+
XDestroyImage(scratch);
|
|
166
|
+
require(ok, "XShmGetImage failed");
|
|
167
|
+
return view;
|
|
168
|
+
}
|
|
169
|
+
FrameView capture() override {
|
|
170
|
+
collectDamage();
|
|
171
|
+
return grab(0, 0, image->width, image->height);
|
|
172
|
+
}
|
|
173
|
+
FrameView captureChanged(bool full) override {
|
|
174
|
+
collectDamage();
|
|
175
|
+
if (full || !rects_valid || rects.empty() || pixelFormat() == PixelFormat::ARGB)
|
|
176
|
+
return grab(0, 0, image->width, image->height);
|
|
177
|
+
int x0 = image->width, y0 = image->height, x1 = 0, y1 = 0;
|
|
178
|
+
for (const auto& r : rects) {
|
|
179
|
+
if (r.width <= 0 || r.height <= 0) continue;
|
|
180
|
+
x0 = std::min(x0, std::clamp(r.x, 0, image->width));
|
|
181
|
+
y0 = std::min(y0, std::clamp(r.y, 0, image->height));
|
|
182
|
+
x1 = std::max(x1, std::clamp(r.x + r.width, 0, image->width));
|
|
183
|
+
y1 = std::max(y1, std::clamp(r.y + r.height, 0, image->height));
|
|
184
|
+
}
|
|
185
|
+
if (x1 <= x0 || y1 <= y0) return grab(0, 0, image->width, image->height);
|
|
186
|
+
x0 &= ~15; y0 &= ~15;
|
|
187
|
+
x1 = std::min((x1 + 15) & ~15, image->width);
|
|
188
|
+
y1 = std::min((y1 + 15) & ~15, image->height);
|
|
189
|
+
return grab(x0, y0, x1 - x0, y1 - y0);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
namespace x11 {
|
|
194
|
+
bool initializeNativeBackend(const std::string&) {
|
|
195
|
+
static std::once_flag once;
|
|
196
|
+
static bool initialized = false;
|
|
197
|
+
std::call_once(once, [] { initialized = XInitThreads() != 0; });
|
|
198
|
+
return initialized;
|
|
199
|
+
}
|
|
200
|
+
std::unique_ptr<CaptureSource> makeCaptureSource() {
|
|
201
|
+
auto source = std::make_unique<X11CaptureSource>();
|
|
202
|
+
source->init();
|
|
203
|
+
return source;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#include "core/input.hpp"
|
|
2
|
+
#include "backends/linux/keycodes.hpp"
|
|
3
|
+
#include <X11/Xlib.h>
|
|
4
|
+
#include <X11/XKBlib.h>
|
|
5
|
+
#include <X11/keysym.h>
|
|
6
|
+
#include <X11/extensions/XTest.h>
|
|
7
|
+
#include <chrono>
|
|
8
|
+
#include <condition_variable>
|
|
9
|
+
#include <map>
|
|
10
|
+
#include <mutex>
|
|
11
|
+
#include <set>
|
|
12
|
+
#include <stdexcept>
|
|
13
|
+
#include <thread>
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace relay {
|
|
17
|
+
namespace {
|
|
18
|
+
constexpr size_t spareCount = 16;
|
|
19
|
+
/// Minimum time between tapping a spare keycode and rebinding it.
|
|
20
|
+
constexpr std::chrono::milliseconds spareReuse(50);
|
|
21
|
+
/// Minimum time between two keyboard mapping changes, so clients refresh their keysym cache first.
|
|
22
|
+
constexpr std::chrono::milliseconds spareBind(12);
|
|
23
|
+
using TimePoint = std::chrono::steady_clock::time_point;
|
|
24
|
+
KeySym textKeysym(uint32_t codepoint) {
|
|
25
|
+
if (codepoint == '\n') return XK_Return;
|
|
26
|
+
if (codepoint == '\t') return XK_Tab;
|
|
27
|
+
return codepoint <= 0xff ? KeySym(codepoint) : KeySym(0x01000000u | codepoint);
|
|
28
|
+
}
|
|
29
|
+
/// Applies queued input on one thread that owns the X connection, with spare keycode reuse paced for late readers.
|
|
30
|
+
class X11Input final : public InputBackend {
|
|
31
|
+
struct Spare {
|
|
32
|
+
KeyCode code = 0;
|
|
33
|
+
KeySym symbol = NoSymbol;
|
|
34
|
+
uint64_t used = 0;
|
|
35
|
+
TimePoint tapped{};
|
|
36
|
+
};
|
|
37
|
+
Display* display = nullptr;
|
|
38
|
+
uint16_t width = 0, height = 0;
|
|
39
|
+
int columns = 1;
|
|
40
|
+
uint64_t typed = 0;
|
|
41
|
+
std::map<KeySym, KeyCode> layout;
|
|
42
|
+
std::set<KeyCode> modifiers;
|
|
43
|
+
std::vector<Spare> spares;
|
|
44
|
+
std::set<unsigned> held;
|
|
45
|
+
TimePoint bound{}, lastTap{};
|
|
46
|
+
mutable std::mutex mutex;
|
|
47
|
+
std::condition_variable wake;
|
|
48
|
+
InputQueue queue;
|
|
49
|
+
bool stopping = false;
|
|
50
|
+
std::thread worker;
|
|
51
|
+
public:
|
|
52
|
+
X11Input() {
|
|
53
|
+
display = XOpenDisplay(nullptr);
|
|
54
|
+
if (!display) throw std::runtime_error("X11 input display unavailable; Wayland is unsupported");
|
|
55
|
+
int event, error, major, minor;
|
|
56
|
+
const int screen = DefaultScreen(display);
|
|
57
|
+
const int root_width = DisplayWidth(display, screen), root_height = DisplayHeight(display, screen);
|
|
58
|
+
if (!XTestQueryExtension(display, &event, &error, &major, &minor)) {
|
|
59
|
+
XCloseDisplay(display); display = nullptr;
|
|
60
|
+
throw std::runtime_error("input requires the XTest extension");
|
|
61
|
+
}
|
|
62
|
+
width = uint16_t(root_width); height = uint16_t(root_height);
|
|
63
|
+
findSpares();
|
|
64
|
+
findModifiers();
|
|
65
|
+
worker = std::thread([this] { run(); });
|
|
66
|
+
}
|
|
67
|
+
~X11Input() override {
|
|
68
|
+
{ std::lock_guard<std::mutex> lock(mutex); stopping = true; }
|
|
69
|
+
wake.notify_all();
|
|
70
|
+
if (worker.joinable()) worker.join();
|
|
71
|
+
XCloseDisplay(display);
|
|
72
|
+
}
|
|
73
|
+
std::pair<uint16_t, uint16_t> dimensions() const override { return {width, height}; }
|
|
74
|
+
const char* name() const override { return "x11"; }
|
|
75
|
+
std::optional<NativeKey> nativeKey(uint16_t usage) const override {
|
|
76
|
+
const int keycode = hidKeycode(usage);
|
|
77
|
+
if (!keycode) return std::nullopt;
|
|
78
|
+
return NativeKey(keycode + 8);
|
|
79
|
+
}
|
|
80
|
+
bool typeText(uint32_t codepoint) override {
|
|
81
|
+
const KeySym symbol = textKeysym(codepoint);
|
|
82
|
+
if (symbol == NoSymbol || (spares.empty() && !layout.count(symbol))) return false;
|
|
83
|
+
InputJob job{InputJob::Kind::text};
|
|
84
|
+
job.codepoint = codepoint;
|
|
85
|
+
post(job);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
void pressKey(NativeKey key) override {
|
|
89
|
+
InputJob job{InputJob::Kind::key};
|
|
90
|
+
job.code = key; job.press = true;
|
|
91
|
+
post(job);
|
|
92
|
+
}
|
|
93
|
+
void releaseKey(NativeKey key) override {
|
|
94
|
+
InputJob job{InputJob::Kind::key};
|
|
95
|
+
job.code = key;
|
|
96
|
+
post(job);
|
|
97
|
+
}
|
|
98
|
+
void pressButton(unsigned button) override {
|
|
99
|
+
InputJob job{InputJob::Kind::button};
|
|
100
|
+
job.number = button; job.press = true;
|
|
101
|
+
post(job);
|
|
102
|
+
}
|
|
103
|
+
void releaseButton(unsigned button) override {
|
|
104
|
+
InputJob job{InputJob::Kind::button};
|
|
105
|
+
job.number = button;
|
|
106
|
+
post(job);
|
|
107
|
+
}
|
|
108
|
+
void move(int x, int y) override {
|
|
109
|
+
InputJob job{InputJob::Kind::motion};
|
|
110
|
+
job.x = x; job.y = y;
|
|
111
|
+
post(job);
|
|
112
|
+
}
|
|
113
|
+
void scroll(unsigned axis, int notches) override {
|
|
114
|
+
InputJob job{InputJob::Kind::scroll};
|
|
115
|
+
job.number = axis; job.notches = notches;
|
|
116
|
+
post(job);
|
|
117
|
+
}
|
|
118
|
+
void resetLocks() override { post(InputJob{InputJob::Kind::locks}); }
|
|
119
|
+
void fence(std::shared_ptr<InputFence> mark) override {
|
|
120
|
+
InputJob job{InputJob::Kind::fence};
|
|
121
|
+
job.fence = std::move(mark);
|
|
122
|
+
post(job);
|
|
123
|
+
}
|
|
124
|
+
void cancel() override {
|
|
125
|
+
{ std::lock_guard<std::mutex> lock(mutex); queue.cancel(); }
|
|
126
|
+
wake.notify_one();
|
|
127
|
+
}
|
|
128
|
+
void flush() override { post(InputJob{InputJob::Kind::flush}); }
|
|
129
|
+
size_t pending() const override {
|
|
130
|
+
std::lock_guard<std::mutex> lock(mutex);
|
|
131
|
+
return queue.pending();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private:
|
|
135
|
+
void post(InputJob job) {
|
|
136
|
+
{ std::lock_guard<std::mutex> lock(mutex); queue.post(std::move(job)); }
|
|
137
|
+
wake.notify_one();
|
|
138
|
+
}
|
|
139
|
+
void run() {
|
|
140
|
+
std::unique_lock<std::mutex> lock(mutex);
|
|
141
|
+
for (;;) {
|
|
142
|
+
wake.wait(lock, [this] { return stopping || !queue.empty(); });
|
|
143
|
+
if (stopping) queue.cancel();
|
|
144
|
+
if (queue.empty()) break;
|
|
145
|
+
const InputJob job = queue.take();
|
|
146
|
+
lock.unlock();
|
|
147
|
+
apply(job);
|
|
148
|
+
lock.lock();
|
|
149
|
+
}
|
|
150
|
+
lock.unlock();
|
|
151
|
+
for (const auto key : held) XTestFakeKeyEvent(display, key, False, CurrentTime);
|
|
152
|
+
held.clear();
|
|
153
|
+
XSync(display, False);
|
|
154
|
+
pace(lastTap + spareReuse);
|
|
155
|
+
restoreSpares();
|
|
156
|
+
XSync(display, False);
|
|
157
|
+
}
|
|
158
|
+
void apply(const InputJob& job) {
|
|
159
|
+
switch (job.kind) {
|
|
160
|
+
case InputJob::Kind::key:
|
|
161
|
+
if (job.press) held.insert(job.code); else held.erase(job.code);
|
|
162
|
+
XTestFakeKeyEvent(display, job.code, job.press, CurrentTime);
|
|
163
|
+
break;
|
|
164
|
+
case InputJob::Kind::text: type(job.codepoint); break;
|
|
165
|
+
case InputJob::Kind::button: XTestFakeButtonEvent(display, job.number, job.press, CurrentTime); break;
|
|
166
|
+
case InputJob::Kind::motion: XTestFakeMotionEvent(display, DefaultScreen(display), job.x, job.y, CurrentTime); break;
|
|
167
|
+
case InputJob::Kind::scroll: wheel(job.number, job.notches); break;
|
|
168
|
+
case InputJob::Kind::locks: XkbLockModifiers(display, XkbUseCoreKbd, LockMask, 0); break;
|
|
169
|
+
case InputJob::Kind::flush: XFlush(display); break;
|
|
170
|
+
case InputJob::Kind::fence: XSync(display, False); job.complete(); break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
void type(uint32_t codepoint) {
|
|
174
|
+
const KeySym symbol = textKeysym(codepoint);
|
|
175
|
+
for (auto& spare : spares) {
|
|
176
|
+
if (spare.symbol != symbol) continue;
|
|
177
|
+
tap(spare);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const KeyCode found = XKeysymToKeycode(display, symbol);
|
|
181
|
+
if (found && !held.count(found) && XkbKeycodeToKeysym(display, found, 0, 0) == symbol) {
|
|
182
|
+
tapKey(found);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
Spare* spare = nullptr;
|
|
186
|
+
for (auto& candidate : spares) if (!spare || candidate.used < spare->used) spare = &candidate;
|
|
187
|
+
if (!spare) return;
|
|
188
|
+
pace(spare->tapped + spareReuse);
|
|
189
|
+
bind(*spare, symbol);
|
|
190
|
+
tap(*spare);
|
|
191
|
+
}
|
|
192
|
+
void tap(Spare& spare) {
|
|
193
|
+
tapKey(spare.code);
|
|
194
|
+
spare.used = ++typed;
|
|
195
|
+
spare.tapped = lastTap = std::chrono::steady_clock::now();
|
|
196
|
+
}
|
|
197
|
+
/// Taps code with held modifiers lifted for the tap and pressed again right after.
|
|
198
|
+
void tapKey(KeyCode code) {
|
|
199
|
+
std::vector<KeyCode> lifted;
|
|
200
|
+
for (const auto modifier : held)
|
|
201
|
+
if (modifier != code && modifiers.count(modifier)) lifted.push_back(modifier);
|
|
202
|
+
for (const auto modifier : lifted) XTestFakeKeyEvent(display, modifier, False, CurrentTime);
|
|
203
|
+
XTestFakeKeyEvent(display, code, True, CurrentTime);
|
|
204
|
+
XTestFakeKeyEvent(display, code, False, CurrentTime);
|
|
205
|
+
for (auto it = lifted.rbegin(); it != lifted.rend(); ++it) XTestFakeKeyEvent(display, *it, True, CurrentTime);
|
|
206
|
+
}
|
|
207
|
+
void pace(TimePoint ready) {
|
|
208
|
+
const auto now = std::chrono::steady_clock::now();
|
|
209
|
+
if (ready > now) std::this_thread::sleep_for(ready - now);
|
|
210
|
+
}
|
|
211
|
+
void wheel(unsigned axis, int notches) {
|
|
212
|
+
const unsigned button = axis == 0 ? (notches > 0 ? 5 : 4) : (notches > 0 ? 7 : 6);
|
|
213
|
+
for (int n = 0; n < (notches < 0 ? -notches : notches); ++n) {
|
|
214
|
+
XTestFakeButtonEvent(display, button, True, CurrentTime);
|
|
215
|
+
XTestFakeButtonEvent(display, button, False, CurrentTime);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
void bind(Spare& spare, KeySym symbol) {
|
|
219
|
+
pace(bound + spareBind);
|
|
220
|
+
std::vector<KeySym> symbols(size_t(columns), symbol);
|
|
221
|
+
XChangeKeyboardMapping(display, spare.code, columns, symbols.data(), 1);
|
|
222
|
+
spare.symbol = symbol;
|
|
223
|
+
bound = std::chrono::steady_clock::now();
|
|
224
|
+
}
|
|
225
|
+
void restoreSpares() {
|
|
226
|
+
for (auto& spare : spares) unbind(spare);
|
|
227
|
+
bound = std::chrono::steady_clock::now();
|
|
228
|
+
}
|
|
229
|
+
void unbind(Spare& spare) {
|
|
230
|
+
if (spare.symbol == NoSymbol) return;
|
|
231
|
+
std::vector<KeySym> symbols(size_t(columns), NoSymbol);
|
|
232
|
+
XChangeKeyboardMapping(display, spare.code, columns, symbols.data(), 1);
|
|
233
|
+
spare.symbol = NoSymbol;
|
|
234
|
+
}
|
|
235
|
+
void findModifiers() {
|
|
236
|
+
XModifierKeymap* map = XGetModifierMapping(display);
|
|
237
|
+
if (!map) return;
|
|
238
|
+
for (int index = 0; index < 8 * map->max_keypermod; ++index)
|
|
239
|
+
if (const KeyCode code = map->modifiermap[index]) modifiers.insert(code);
|
|
240
|
+
XFreeModifiermap(map);
|
|
241
|
+
}
|
|
242
|
+
void findSpares() {
|
|
243
|
+
int min = 0, max = 0, count = 0;
|
|
244
|
+
XDisplayKeycodes(display, &min, &max);
|
|
245
|
+
if (max < min) return;
|
|
246
|
+
KeySym* keysyms = XGetKeyboardMapping(display, KeyCode(min), max - min + 1, &count);
|
|
247
|
+
if (!keysyms || count < 1) { if (keysyms) XFree(keysyms); return; }
|
|
248
|
+
columns = count;
|
|
249
|
+
for (int index = 0; index <= max - min; ++index) {
|
|
250
|
+
const KeySym symbol = keysyms[index * count];
|
|
251
|
+
if (symbol != NoSymbol) { layout.emplace(symbol, KeyCode(min + index)); continue; }
|
|
252
|
+
bool empty = true;
|
|
253
|
+
for (int column = 0; column < count; ++column)
|
|
254
|
+
if (keysyms[index * count + column] != NoSymbol) { empty = false; break; }
|
|
255
|
+
if (empty && spares.size() < spareCount) spares.push_back(Spare{KeyCode(min + index), NoSymbol, 0, {}});
|
|
256
|
+
}
|
|
257
|
+
XFree(keysyms);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
} // namespace
|
|
261
|
+
namespace x11 {
|
|
262
|
+
std::unique_ptr<InputBackend> makeInputBackend() {
|
|
263
|
+
return std::make_unique<X11Input>();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} // namespace relay
|