mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-30 07:10:08 +01:00
Merge branch 'work/demoportal' into 'main'
Let oeffis-demo-tool start ei-demo-client optionally See merge request libinput/libei!284
This commit is contained in:
commit
0fe37ee401
1 changed files with 77 additions and 1 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
|
@ -67,8 +68,76 @@ static void start_debug_events(int fd)
|
|||
}
|
||||
}
|
||||
|
||||
static void start_demo_client(int fd)
|
||||
{
|
||||
pid_t pid = fork();
|
||||
assert(pid != -1);
|
||||
|
||||
if (pid == 0) {
|
||||
_cleanup_free_ char *fdstr = xaprintf("%d", fd);
|
||||
execl(MESON_BUILDDIR "/ei-demo-client",
|
||||
"ei-demo-client",
|
||||
"--socketfd", fdstr, NULL);
|
||||
fprintf(stderr, "Failed to fork: %m\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
usage(FILE *fp, const char *argv0)
|
||||
{
|
||||
fprintf(fp,
|
||||
"Usage: %s [--debug|--sendevents]\n"
|
||||
"\n"
|
||||
"Connect to the EIS implementation via the remote desktop portal.\n"
|
||||
"Afterwards the specified action is taken.\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" --debug print communication with the EIS implementation (default)\n"
|
||||
" --sendevents send emulated keyboard and pointer events in a loop\n",
|
||||
argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
enum {
|
||||
DEBUG,
|
||||
CLIENT,
|
||||
} action = DEBUG;
|
||||
|
||||
while (1) {
|
||||
enum {
|
||||
OPT_DEBUG,
|
||||
OPT_SENDEVENTS,
|
||||
};
|
||||
static struct option long_opts[] = {
|
||||
{"debug", required_argument, 0, OPT_DEBUG},
|
||||
{"sendevents", no_argument, 0, OPT_SENDEVENTS},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{.name = NULL},
|
||||
};
|
||||
|
||||
int optind = 0;
|
||||
int c = getopt_long(argc, argv, "h", long_opts, &optind);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch(c) {
|
||||
case 'h':
|
||||
usage(stdout, argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
case OPT_DEBUG:
|
||||
action = DEBUG;
|
||||
break;
|
||||
case OPT_SENDEVENTS:
|
||||
action = CLIENT;
|
||||
break;
|
||||
default:
|
||||
usage(stderr, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
_unref_(oeffis) *oeffis = oeffis_new(NULL);
|
||||
|
||||
signal(SIGINT, sighandler);
|
||||
|
|
@ -103,7 +172,14 @@ int main(int argc, char **argv)
|
|||
* cause the compositor or the portal to invalidate
|
||||
* our EIS fd.
|
||||
*/
|
||||
start_debug_events(eisfd);
|
||||
switch (action) {
|
||||
case DEBUG:
|
||||
start_debug_events(eisfd);
|
||||
break;
|
||||
case CLIENT:
|
||||
start_demo_client(eisfd);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OEFFIS_EVENT_DISCONNECTED:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue