Added snooper, a tool to test the gtk_key_snooper_install() function
This commit is contained in:
parent
f2ceab47ef
commit
ee1d021a7f
1
Makefile
1
Makefile
|
@ -35,6 +35,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/layout.h \
|
$(PACKAGE)-$(VERSION)/src/layout.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/tools/plug.c \
|
$(PACKAGE)-$(VERSION)/tools/plug.c \
|
||||||
|
$(PACKAGE)-$(VERSION)/tools/snooper.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/xkey.c \
|
$(PACKAGE)-$(VERSION)/tools/xkey.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
plug
|
plug
|
||||||
|
snooper
|
||||||
xkey
|
xkey
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = plug xkey
|
TARGETS = plug snooper xkey
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -23,6 +23,13 @@ plug_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
plug: $(plug_OBJS)
|
plug: $(plug_OBJS)
|
||||||
$(CC) -o plug $(plug_OBJS) $(plug_LDFLAGS)
|
$(CC) -o plug $(plug_OBJS) $(plug_LDFLAGS)
|
||||||
|
|
||||||
|
snooper_OBJS = snooper.o
|
||||||
|
snooper_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
|
snooper_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
|
snooper: $(snooper_OBJS)
|
||||||
|
$(CC) -o snooper $(snooper_OBJS) $(snooper_LDFLAGS)
|
||||||
|
|
||||||
xkey_OBJS = xkey.o
|
xkey_OBJS = xkey.o
|
||||||
xkey_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
xkey_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
xkey_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lXtst
|
xkey_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lXtst
|
||||||
|
@ -33,11 +40,14 @@ xkey: $(xkey_OBJS)
|
||||||
plug.o: plug.c
|
plug.o: plug.c
|
||||||
$(CC) $(plug_CFLAGS) -c plug.c
|
$(CC) $(plug_CFLAGS) -c plug.c
|
||||||
|
|
||||||
|
snooper.o: snooper.c
|
||||||
|
$(CC) $(snooper_CFLAGS) -c snooper.c
|
||||||
|
|
||||||
xkey.o: xkey.c
|
xkey.o: xkey.c
|
||||||
$(CC) $(xkey_CFLAGS) -c xkey.c
|
$(CC) $(xkey_CFLAGS) -c xkey.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(plug_OBJS) $(xkey_OBJS)
|
$(RM) -- $(plug_OBJS) $(snooper_OBJS) $(xkey_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
targets=plug,xkey
|
targets=plug,snooper,xkey
|
||||||
cflags_force=-W `pkg-config --cflags gtk+-2.0`
|
cflags_force=-W `pkg-config --cflags gtk+-2.0`
|
||||||
cflags=-Wall -g -O2
|
cflags=-Wall -g -O2
|
||||||
ldflags_force=`pkg-config --libs gtk+-2.0`
|
ldflags_force=`pkg-config --libs gtk+-2.0`
|
||||||
|
@ -8,6 +8,10 @@ dist=Makefile
|
||||||
type=binary
|
type=binary
|
||||||
sources=plug.c
|
sources=plug.c
|
||||||
|
|
||||||
|
[snooper]
|
||||||
|
type=binary
|
||||||
|
sources=snooper.c
|
||||||
|
|
||||||
[xkey]
|
[xkey]
|
||||||
type=binary
|
type=binary
|
||||||
sources=xkey.c
|
sources=xkey.c
|
||||||
|
|
70
tools/snooper.c
Normal file
70
tools/snooper.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Keyboard */
|
||||||
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* prototypes */
|
||||||
|
/* callbacks */
|
||||||
|
static gint _snooper_on_key_snoop(GtkWidget * grab, GdkEventKey * event,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
/* callbacks */
|
||||||
|
/* snooper_on_key_snoop */
|
||||||
|
static gint _snooper_on_key_snoop(GtkWidget * grab, GdkEventKey * event,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usage */
|
||||||
|
static int _usage(void)
|
||||||
|
{
|
||||||
|
fputs("Usage: snooper\n", stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* main */
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
int o;
|
||||||
|
guint id;
|
||||||
|
|
||||||
|
gtk_init(&argc, &argv);
|
||||||
|
while((o = getopt(argc, argv, "")) != -1)
|
||||||
|
switch(o)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return _usage();
|
||||||
|
}
|
||||||
|
if(optind != argc)
|
||||||
|
return _usage();
|
||||||
|
id = gtk_key_snooper_install(_snooper_on_key_snoop, NULL);
|
||||||
|
gtk_main();
|
||||||
|
gtk_key_snooper_remove(id);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user