[PATCH libinput 8/8] tools: use the new shared lib from event-gui
Peter Hutterer
peter.hutterer at who-t.net
Thu Dec 18 15:16:23 PST 2014
This gives the event gui the ability to use the path backend, and any
configuration toggles given on the commandline.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
tools/Makefile.am | 2 +-
tools/event-gui.c | 50 ++++++++++----------------------------------------
2 files changed, 11 insertions(+), 41 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 6dd64c9..cebcd72 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,7 @@ if BUILD_EVENTGUI
noinst_PROGRAMS += event-gui
event_gui_SOURCES = event-gui.c
-event_gui_LDADD = ../src/libinput.la $(CAIRO_LIBS) $(GTK_LIBS) $(LIBUDEV_LIBS)
+event_gui_LDADD = ../src/libinput.la libshared.la $(CAIRO_LIBS) $(GTK_LIBS) $(LIBUDEV_LIBS)
event_gui_CFLAGS = $(CAIRO_CFLAGS) $(GTK_CFLAGS) $(LIBUDEV_CFLAGS)
event_gui_LDFLAGS = -no-install
endif
diff --git a/tools/event-gui.c b/tools/event-gui.c
index b6d21b6..b950f92 100644
--- a/tools/event-gui.c
+++ b/tools/event-gui.c
@@ -27,7 +27,6 @@
#include <cairo.h>
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -40,8 +39,12 @@
#include <libinput.h>
#include <libinput-util.h>
+#include "shared.h"
+
#define clip(val_, min_, max_) min((max_), max((min_), (val_)))
+struct tools_options options;
+
struct touch {
int active;
int x, y;
@@ -95,12 +98,6 @@ msg(const char *fmt, ...)
va_end(args);
}
-static void
-usage(void)
-{
- printf("%s [path/to/device]\n", program_invocation_short_name);
-}
-
static gboolean
draw(GtkWidget *widget, cairo_t *cr, gpointer data)
{
@@ -491,35 +488,6 @@ sockets_init(struct libinput *li)
}
static int
-parse_opts(int argc, char *argv[])
-{
- while (1) {
- static struct option long_options[] = {
- { "help", no_argument, 0, 'h' },
- };
-
- int option_index = 0;
- int c;
-
- c = getopt_long(argc, argv, "h", long_options,
- &option_index);
- if (c == -1)
- break;
-
- switch(c) {
- case 'h':
- usage();
- return 0;
- default:
- usage();
- return 1;
- }
- }
-
- return 0;
-}
-
-static int
open_restricted(const char *path, int flags, void *user_data)
{
int fd = open(path, flags);
@@ -546,16 +514,18 @@ main(int argc, char *argv[])
gtk_init(&argc, &argv);
- if (parse_opts(argc, argv) != 0)
+ tools_init_options(&options);
+
+ if (tools_parse_args(argc, argv, &options) != 0)
return 1;
udev = udev_new();
if (!udev)
error("Failed to initialize udev\n");
- li = libinput_udev_create_context(&interface, &w, udev);
- if (!li || libinput_udev_assign_seat(li, "seat0") != 0)
- error("Failed to initialize context from udev\n");
+ li = tools_open_backend(&options, &interface);
+ if (!li)
+ return 1;
window_init(&w);
sockets_init(li);
--
2.1.0
More information about the wayland-devel
mailing list