tools: use the new shared lib from event-gui
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 18 Dec 2014 04:47:54 +0000 (14:47 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 23 Dec 2014 00:50:31 +0000 (10:50 +1000)
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@who-t.net>
tools/Makefile.am
tools/event-gui.c

index 6dd64c94c4b4102d6a41785859df05717680863d..cebcd729547e57e9411292e7b1700cb1a76ad179 100644 (file)
@@ -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
index b6d21b66606bb8b006f7d2567a9de7a77ecdfa2a..b950f92cc59f055f7e4a622e97ac608df53a3304 100644 (file)
@@ -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>
 #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)
 {
@@ -490,35 +487,6 @@ sockets_init(struct libinput *li)
        g_io_add_watch(c, G_IO_IN, handle_event_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)
 {
@@ -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);