[Xfce4-commits] <xfce4-clipman-plugin:master> Add optional build dependency for XTEST extension

Mike Massonnet noreply at xfce.org
Thu Oct 20 11:42:04 CEST 2011


Updating branch refs/heads/master
         to c239358133414d0207ec38403755fc07c853655a (commit)
       from aaeab388d4c53ca6133ad1f96144a9e286953423 (commit)

commit c239358133414d0207ec38403755fc07c853655a
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Wed Oct 19 10:30:39 2011 +0200

    Add optional build dependency for XTEST extension
    
    Include a test program that uses XTestFakeKeyEvent() to emulate Shift+Insert
    in order to "paste" content, works also for Ctrl+v.
    
    XTEST extension will be optional until an option is included in the settings
    dialog, then it will be a hard-dependency.

 configure.ac.in       |   12 +++++++-
 tests/Makefile.am     |    6 ++-
 tests/test_xfakekey.c |   77 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 72d3fec..93adc1c 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -65,6 +65,16 @@ XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.8.0])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.8.0])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.8.0])
 
+dnl ****************************************
+dnl *** Check for xtst (XTEST extension) ***
+dnl ****************************************
+XDT_CHECK_OPTIONAL_PACKAGE([LIBXTST], [xtst], [1.0.0])
+if test x"$LIBXTST_FOUND" = x"yes"; then
+	enable_libxtst=yes
+else
+	enable_libxtst=no
+fi
+
 dnl ***************************
 dnl *** Check for libunique ***
 dnl ***************************
@@ -164,6 +174,6 @@ echo
 echo "Build Configuration:"
 echo
 echo "    * Debug Support:    $enable_debug"
+echo "    * XTEST extension:  $enable_libxtst"
 echo "    * Unique:           $enable_unique"
 echo
-
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 96c9589..b63eb2d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,7 +9,7 @@ INCLUDES =								\
 	-DLOCALEDIR=\"$(localedir)\"					\
 	$(NULL)
 
-check_PROGRAMS = test-actions test-daemon test-targets
+check_PROGRAMS = test-actions test-daemon test-targets test-xfakekey
 test_actions_SOURCES = test_actions.c ../panel-plugin/actions.c ../panel-plugin/actions.h ../panel-plugin/common.h
 test_actions_CFLAGS = @GTK_CFLAGS@ @EXO_CFLAGS@ @LIBXFCE4UTIL_CFLAGS@ @LIBXFCE4UI_CFLAGS@
 test_actions_LDADD = @GTK_LIBS@ @EXO_LIBS@ @LIBXFCE4UTIL_LIBS@ @LIBXFCE4UI_LIBS@
@@ -19,4 +19,6 @@ test_daemon_LDADD = $(top_builddir)/daemon/libdaemon.la @GTK_LIBS@
 test_targets_SOURCES = test_targets.c
 test_targets_CFLAGS = @GTK_CFLAGS@
 test_targets_LDADD = @GTK_LIBS@
-
+test_xfakekey_SOURCES = test_xfakekey.c
+test_xfakekey_CFLAGS = @GTK_CFLAGS@ @LIBX11_CFLAGS@ @LIBXTST_CFLAGS@
+test_xfakekey_LDADD = @GTK_LIBS@ @LIBX11_LIBS@ @LIBXTST_LIBS@
diff --git a/tests/test_xfakekey.c b/tests/test_xfakekey.c
new file mode 100644
index 0000000..6891804
--- /dev/null
+++ b/tests/test_xfakekey.c
@@ -0,0 +1,77 @@
+#include <config.h>
+#ifdef HAVE_LIBXTST
+#include <X11/Xlib.h>
+#include <X11/extensions/XTest.h>
+#include <X11/keysym.h>
+#include <stdio.h>
+
+int main () {
+        Display *display = XOpenDisplay (NULL);
+        int dummyi;
+        if (display == NULL)
+                return 1;
+        printf ("XTest: %d\n", XQueryExtension (display, "XTEST", &dummyi, &dummyi, &dummyi));
+
+        int ret = -1;
+        KeySym key_sym;
+        KeyCode key_code;
+        key_sym = XStringToKeysym ("1");
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+        key_sym = XStringToKeysym ("2");
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+        key_sym = XStringToKeysym ("3");
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+        key_sym = XK_Return;
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+
+        printf ("XTestFakeKeyEvent: %d\n", ret);
+
+/*        key_sym = XK_Control_L;
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        key_sym = XK_v;
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+        key_sym = XK_Control_L;
+        key_code = XKeysymToKeycode (display, key_sym);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+
+        printf ("XTestFakeKeyEvent: %d\n", ret);
+*/
+        key_sym = XK_Shift_L;
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        key_sym = XK_Insert;
+        key_code = XKeysymToKeycode (display, key_sym);
+        XTestFakeKeyEvent (display, key_code, True, CurrentTime);
+        key_sym = XK_Insert;
+        key_code = XKeysymToKeycode (display, key_sym);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+        key_sym = XK_Shift_L;
+        key_code = XKeysymToKeycode (display, key_sym);
+        ret = XTestFakeKeyEvent (display, key_code, False, CurrentTime);
+
+        printf ("XTestFakeKeyEvent: %d\n", ret);
+
+        printf ("Closing display in 5s...\n");
+        usleep (5000000);
+        XCloseDisplay (display);
+
+        return 0;
+}
+#else
+#include <stdio.h>
+int main() {
+        printf ("No XTEST support.\n");
+        return 0;
+}
+#endif
\ No newline at end of file


More information about the Xfce4-commits mailing list