virtualkeyboard: Add options to skip releasing pressed keys on close and to skip sharing key states (#11214)
This commit is contained in:
parent
6491bb4fb7
commit
2be309de1d
23 changed files with 416 additions and 137 deletions
|
|
@ -876,3 +876,55 @@ bool isNvidiaDriverVersionAtLeast(int threshold) {
|
|||
|
||||
return driverMajor >= threshold;
|
||||
}
|
||||
|
||||
std::expected<std::string, std::string> binaryNameForWlClient(wl_client* client) {
|
||||
if (!client)
|
||||
return std::unexpected("client unknown");
|
||||
|
||||
pid_t pid = 0;
|
||||
wl_client_get_credentials(client, &pid, nullptr, nullptr);
|
||||
|
||||
return binaryNameForPid(pid);
|
||||
}
|
||||
|
||||
std::expected<std::string, std::string> binaryNameForPid(pid_t pid) {
|
||||
if (pid <= 0)
|
||||
return std::unexpected("No pid for client");
|
||||
|
||||
#if defined(KERN_PROC_PATHNAME)
|
||||
int mib[] = {
|
||||
CTL_KERN,
|
||||
#if defined(__NetBSD__)
|
||||
KERN_PROC_ARGS,
|
||||
pid,
|
||||
KERN_PROC_PATHNAME,
|
||||
#else
|
||||
KERN_PROC,
|
||||
KERN_PROC_PATHNAME,
|
||||
pid,
|
||||
#endif
|
||||
};
|
||||
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||
char exe[PATH_MAX] = "/nonexistent";
|
||||
size_t sz = sizeof(exe);
|
||||
sysctl(mib, miblen, &exe, &sz, NULL, 0);
|
||||
std::string path = exe;
|
||||
#else
|
||||
std::string path = std::format("/proc/{}/exe", (uint64_t)pid);
|
||||
#endif
|
||||
std::error_code ec;
|
||||
|
||||
std::string fullPath = std::filesystem::canonical(path, ec);
|
||||
|
||||
if (ec)
|
||||
return std::unexpected("canonical failed");
|
||||
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
std::string deviceNameToInternalString(std::string in) {
|
||||
std::ranges::replace(in, ' ', '-');
|
||||
std::ranges::replace(in, '\n', '-');
|
||||
std::ranges::transform(in, in.begin(), ::tolower);
|
||||
return in;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue