From e640bac86708e05dfbe6ea811fba7b188b04bc2b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 27 Aug 2018 11:14:05 +1000 Subject: [PATCH] tools: fix grab handling in libinput debug-gui The libinput context's user_data was used for deciding whether to grab the event device but also to hold the struct window data for the debug-gui. Worked fine for the initial batch of devices, but any device coming in late would just use the first field of the struct window to decide whether to grab or not. Fixes #122 Signed-off-by: Peter Hutterer --- tools/libinput-debug-gui.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c index 1cf81117..06ea0b81 100644 --- a/tools/libinput-debug-gui.c +++ b/tools/libinput-debug-gui.c @@ -55,6 +55,7 @@ struct point { }; struct window { + bool grab; struct tools_options options; GtkWidget *win; @@ -455,8 +456,6 @@ map_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data) static void window_init(struct window *w) { - memset(w, 0, sizeof(*w)); - w->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_events(w->win, 0); gtk_window_set_title(GTK_WINDOW(w->win), "libinput debugging tool"); @@ -922,12 +921,11 @@ usage(void) { int main(int argc, char **argv) { - struct window w; + struct window w = {0}; struct tools_options options; struct libinput *li; enum tools_backend backend = BACKEND_UDEV; const char *seat_or_device = "seat0"; - bool grab = false; bool verbose = false; gtk_init(&argc, &argv); @@ -974,7 +972,7 @@ main(int argc, char **argv) seat_or_device = optarg; break; case OPT_GRAB: - grab = true; + w.grab = true; break; case OPT_VERBOSE: verbose = true; @@ -994,7 +992,7 @@ main(int argc, char **argv) return 1; } - li = tools_open_backend(backend, seat_or_device, verbose, &grab); + li = tools_open_backend(backend, seat_or_device, verbose, &w.grab); if (!li) return 1;