mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-05 21:50:15 +01:00
Allow passing a fd to ei-demo-client
Like in ei-debug-events
This commit is contained in:
parent
ebde54f3b3
commit
cf4ab5e73f
1 changed files with 14 additions and 0 deletions
|
|
@ -57,6 +57,7 @@
|
|||
#include "src/util-mem.h"
|
||||
#include "src/util-memmap.h"
|
||||
#include "src/util-color.h"
|
||||
#include "src/util-io.h"
|
||||
#include "src/util-strings.h"
|
||||
#include "src/util-time.h"
|
||||
|
||||
|
|
@ -184,6 +185,7 @@ usage(FILE *fp, const char *argv0)
|
|||
"Options:\n"
|
||||
" --socket Use the socket backend. The socket path is $LIBEI_SOCKET if set, \n"
|
||||
" otherwise $XDG_RUNTIME_DIR/eis-0\n"
|
||||
" --socketfd Use the given fd as socket to the EIS implementation\n"
|
||||
" --verbose Enable debugging output\n"
|
||||
" --receiver Create a receiver EIS context, receiving events instead of sending them\n"
|
||||
" --interval Interval in milliseconds between polling\n"
|
||||
|
|
@ -196,7 +198,9 @@ int main(int argc, char **argv)
|
|||
{
|
||||
enum {
|
||||
SOCKET,
|
||||
FD,
|
||||
} backend = SOCKET;
|
||||
_cleanup_close_ int socketfd = -1;
|
||||
bool verbose = false;
|
||||
bool receiver = false;
|
||||
unsigned int interval = 2000;
|
||||
|
|
@ -210,9 +214,11 @@ int main(int argc, char **argv)
|
|||
OPT_RECEIVER,
|
||||
OPT_INTERVAL,
|
||||
OPT_ITERATIONS,
|
||||
OPT_SOCKETFD,
|
||||
};
|
||||
static struct option long_opts[] = {
|
||||
{"socket", no_argument, 0, OPT_BACKEND_SOCKET},
|
||||
{"socketfd", required_argument, 0, OPT_SOCKETFD},
|
||||
{"verbose", no_argument, 0, OPT_VERBOSE},
|
||||
{"receiver", no_argument, 0, OPT_RECEIVER},
|
||||
{"interval", required_argument, 0, OPT_INTERVAL},
|
||||
|
|
@ -236,6 +242,12 @@ int main(int argc, char **argv)
|
|||
case OPT_BACKEND_SOCKET:
|
||||
backend = SOCKET;
|
||||
break;
|
||||
case OPT_SOCKETFD:
|
||||
backend = FD;
|
||||
if (!xatoi(optarg, &socketfd)) {
|
||||
fprintf(stderr, "Invalid socketfd: %s", optarg);
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case OPT_RECEIVER:
|
||||
receiver = true;
|
||||
|
|
@ -270,6 +282,8 @@ int main(int argc, char **argv)
|
|||
const char SOCKETNAME[] = "eis-0";
|
||||
colorprint("connecting to %s\n", SOCKETNAME);
|
||||
rc = ei_setup_backend_socket(ei, getenv("LIBEI_SOCKET") ? NULL : SOCKETNAME);
|
||||
} else if (backend == FD) {
|
||||
rc = ei_setup_backend_fd(ei, socketfd);
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue