Add support for using the XTest extension in wxUIActionSimulator

Fixes wxUIActionSimulator under wxGTK3, see #17530.
This commit is contained in:
Scott Talbert
2016-05-17 20:54:22 -04:00
committed by Vadim Zeitlin
parent a31a7522c4
commit a4716916b7
14 changed files with 194 additions and 0 deletions

124
configure vendored
View File

@@ -945,6 +945,8 @@ WEBKIT_LIBS
WEBKIT_CFLAGS WEBKIT_CFLAGS
COND_PYTHON COND_PYTHON
PYTHON PYTHON
XTST_LIBS
XTST_CFLAGS
LIBNOTIFY_LIBS LIBNOTIFY_LIBS
LIBNOTIFY_CFLAGS LIBNOTIFY_CFLAGS
GNOMEVFS_LIBS GNOMEVFS_LIBS
@@ -1092,6 +1094,7 @@ with_gtkprint
with_gnomevfs with_gnomevfs
with_libnotify with_libnotify
with_opengl with_opengl
with_xtest
with_dmalloc with_dmalloc
with_sdl with_sdl
with_regex with_regex
@@ -1397,6 +1400,8 @@ GNOMEVFS_CFLAGS
GNOMEVFS_LIBS GNOMEVFS_LIBS
LIBNOTIFY_CFLAGS LIBNOTIFY_CFLAGS
LIBNOTIFY_LIBS LIBNOTIFY_LIBS
XTST_CFLAGS
XTST_LIBS
WEBKIT_CFLAGS WEBKIT_CFLAGS
WEBKIT_LIBS WEBKIT_LIBS
CAIRO_CFLAGS CAIRO_CFLAGS
@@ -2318,6 +2323,7 @@ Optional Packages:
--with-gnomevfs use GNOME VFS for associating MIME types --with-gnomevfs use GNOME VFS for associating MIME types
--with-libnotify use libnotify for notifications --with-libnotify use libnotify for notifications
--with-opengl use OpenGL (or Mesa) --with-opengl use OpenGL (or Mesa)
--with-xtest use XTest extension
--with-dmalloc use dmalloc library (http://dmalloc.com/) --with-dmalloc use dmalloc library (http://dmalloc.com/)
--with-sdl use SDL for audio on Unix --with-sdl use SDL for audio on Unix
--with-regex enable support for wxRegEx class --with-regex enable support for wxRegEx class
@@ -2391,6 +2397,8 @@ Some influential environment variables:
C compiler flags for LIBNOTIFY, overriding pkg-config C compiler flags for LIBNOTIFY, overriding pkg-config
LIBNOTIFY_LIBS LIBNOTIFY_LIBS
linker flags for LIBNOTIFY, overriding pkg-config linker flags for LIBNOTIFY, overriding pkg-config
XTST_CFLAGS C compiler flags for XTST, overriding pkg-config
XTST_LIBS linker flags for XTST, overriding pkg-config
WEBKIT_CFLAGS WEBKIT_CFLAGS
C compiler flags for WEBKIT, overriding pkg-config C compiler flags for WEBKIT, overriding pkg-config
WEBKIT_LIBS linker flags for WEBKIT, overriding pkg-config WEBKIT_LIBS linker flags for WEBKIT, overriding pkg-config
@@ -4823,6 +4831,35 @@ fi
eval "$wx_cv_use_opengl" eval "$wx_cv_use_opengl"
withstring=
defaultval=$wxUSE_ALL_FEATURES
if test -z "$defaultval"; then
if test x"$withstring" = xwithout; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --with-xtest was given.
if test "${with_xtest+set}" = set; then :
withval=$with_xtest;
if test "$withval" = yes; then
wx_cv_use_xtest='wxUSE_XTEST=yes'
else
wx_cv_use_xtest='wxUSE_XTEST=no'
fi
else
wx_cv_use_xtest='wxUSE_XTEST=${'DEFAULT_wxUSE_XTEST":-$defaultval}"
fi
eval "$wx_cv_use_xtest"
fi fi
@@ -33532,6 +33569,93 @@ if test "$wxUSE_UIACTIONSIMULATOR" = "yes" ; then
$as_echo "#define wxUSE_UIACTIONSIMULATOR 1" >>confdefs.h $as_echo "#define wxUSE_UIACTIONSIMULATOR 1" >>confdefs.h
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS uiaction" SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS uiaction"
if test "$wxUSE_XTEST" = "yes" ; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XTST" >&5
$as_echo_n "checking for XTST... " >&6; }
if test -n "$PKG_CONFIG"; then
if test -n "$XTST_CFLAGS"; then
pkg_cv_XTST_CFLAGS="$XTST_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"xtst\""; } >&5
($PKG_CONFIG --exists --print-errors "xtst") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_XTST_CFLAGS=`$PKG_CONFIG --cflags "xtst" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$XTST_LIBS"; then
pkg_cv_XTST_LIBS="$XTST_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"xtst\""; } >&5
($PKG_CONFIG --exists --print-errors "xtst") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_XTST_LIBS=`$PKG_CONFIG --libs "xtst" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
XTST_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "xtst"`
else
XTST_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xtst"`
fi
# Put the nasty error message in config.log where it belongs
echo "$XTST_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: XTest extension not found" >&5
$as_echo "$as_me: WARNING: XTest extension not found" >&2;}
wxUSE_XTEST="no"
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: XTest extension not found" >&5
$as_echo "$as_me: WARNING: XTest extension not found" >&2;}
wxUSE_XTEST="no"
else
XTST_CFLAGS=$pkg_cv_XTST_CFLAGS
XTST_LIBS=$pkg_cv_XTST_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
GUI_TK_LIBRARY="$GUI_TK_LIBRARY $XTST_LIBS"
CFLAGS="$XTST_CFLAGS $CFLAGS"
CXXFLAGS="$XTST_CFLAGS $CXXFLAGS"
$as_echo "#define wxUSE_XTEST 1" >>confdefs.h
fi
fi
fi fi
if test "$wxUSE_DC_TRANSFORM_MATRIX" = "yes" ; then if test "$wxUSE_DC_TRANSFORM_MATRIX" = "yes" ; then

View File

@@ -542,6 +542,7 @@ WX_ARG_WITHOUT(gtkprint, [ --without-gtkprint don't use GTK printing sup
WX_ARG_WITH(gnomevfs, [ --with-gnomevfs use GNOME VFS for associating MIME types], wxUSE_LIBGNOMEVFS) WX_ARG_WITH(gnomevfs, [ --with-gnomevfs use GNOME VFS for associating MIME types], wxUSE_LIBGNOMEVFS)
WX_ARG_WITH(libnotify, [ --with-libnotify use libnotify for notifications], wxUSE_LIBNOTIFY) WX_ARG_WITH(libnotify, [ --with-libnotify use libnotify for notifications], wxUSE_LIBNOTIFY)
WX_ARG_WITH(opengl, [ --with-opengl use OpenGL (or Mesa)], wxUSE_OPENGL) WX_ARG_WITH(opengl, [ --with-opengl use OpenGL (or Mesa)], wxUSE_OPENGL)
WX_ARG_WITH(xtest, [ --with-xtest use XTest extension], wxUSE_XTEST)
fi fi
dnl for GUI only dnl for GUI only
@@ -6360,6 +6361,20 @@ fi
if test "$wxUSE_UIACTIONSIMULATOR" = "yes" ; then if test "$wxUSE_UIACTIONSIMULATOR" = "yes" ; then
AC_DEFINE(wxUSE_UIACTIONSIMULATOR) AC_DEFINE(wxUSE_UIACTIONSIMULATOR)
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS uiaction" SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS uiaction"
if test "$wxUSE_XTEST" = "yes" ; then
PKG_CHECK_MODULES(XTST, xtst,
[
GUI_TK_LIBRARY="$GUI_TK_LIBRARY $XTST_LIBS"
CFLAGS="$XTST_CFLAGS $CFLAGS"
CXXFLAGS="$XTST_CFLAGS $CXXFLAGS"
AC_DEFINE(wxUSE_XTEST)
],
[
AC_MSG_WARN([XTest extension not found])
wxUSE_XTEST="no"
]
)
fi
fi fi
if test "$wxUSE_DC_TRANSFORM_MATRIX" = "yes" ; then if test "$wxUSE_DC_TRANSFORM_MATRIX" = "yes" ; then

View File

@@ -85,6 +85,7 @@ All (GUI):
wxGTK: wxGTK:
- Make wxUIActionSimulator work with GTK+ 3 (Scott Talbert).
- Implement setting link colours in wxHyperlinkCtrl for GTK+3 (Hanmac). - Implement setting link colours in wxHyperlinkCtrl for GTK+3 (Hanmac).
- Support background colour in wxDataViewCtrl attributes. - Support background colour in wxDataViewCtrl attributes.
- Improve wxSpinCtrl best size calculation. - Improve wxSpinCtrl best size calculation.

View File

@@ -267,6 +267,7 @@ library:
@itemdef{wxUSE_LIBSDL, Use SDL for wxSound implementation.} @itemdef{wxUSE_LIBSDL, Use SDL for wxSound implementation.}
@itemdef{wxUSE_PLUGINS, See also wxUSE_LIBSDL.} @itemdef{wxUSE_PLUGINS, See also wxUSE_LIBSDL.}
@itemdef{wxUSE_UNIX, Enabled on Unix Platform.} @itemdef{wxUSE_UNIX, Enabled on Unix Platform.}
@itemdef(wxUSE_XTEST, Use XTest extension.}
@endDefList @endDefList

View File

@@ -1403,6 +1403,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1231,6 +1231,14 @@
# endif # endif
#endif /* !defined(wxUSE_XRC) */ #endif /* !defined(wxUSE_XRC) */
#ifndef wxUSE_XTEST
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_XTEST must be defined, please read comment near the top of this file."
# else
# define wxUSE_XTEST 0
# endif
#endif /* !defined(wxUSE_XTEST) */
#endif /* wxUSE_GUI */ #endif /* wxUSE_GUI */
/* /*

View File

@@ -1404,6 +1404,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1404,6 +1404,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1404,6 +1404,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1405,6 +1405,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1400,6 +1400,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1403,6 +1403,9 @@
// Compile wxUIActionSimulator class? // Compile wxUIActionSimulator class?
#define wxUSE_UIACTIONSIMULATOR 1 #define wxUSE_UIACTIONSIMULATOR 1
// Use the XTest extension for wxUIActionSimulator?
#define wxUSE_XTEST 1
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDC classes for various output formats // wxDC classes for various output formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -570,6 +570,8 @@
#define wxUSE_UIACTIONSIMULATOR 0 #define wxUSE_UIACTIONSIMULATOR 0
#define wxUSE_XTEST 0
#define wxUSE_POSTSCRIPT 0 #define wxUSE_POSTSCRIPT 0

View File

@@ -20,6 +20,9 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#if wxUSE_XTEST
#include <X11/extensions/XTest.h>
#endif
#include "wx/unix/utilsx11.h" #include "wx/unix/utilsx11.h"
@@ -48,6 +51,10 @@ void SendButtonEvent(int button, bool isDown)
wxX11Display display; wxX11Display display;
wxCHECK_RET(display, "No display available!"); wxCHECK_RET(display, "No display available!");
#if wxUSE_XTEST
XTestFakeButtonEvent(display, xbutton, isDown, 0);
#else // !wxUSE_XTEST
XEvent event; XEvent event;
memset(&event, 0x00, sizeof(event)); memset(&event, 0x00, sizeof(event));
@@ -71,6 +78,7 @@ void SendButtonEvent(int button, bool isDown)
} }
XSendEvent(display, PointerWindow, True, 0xfff, &event); XSendEvent(display, PointerWindow, True, 0xfff, &event);
#endif // !wxUSE_XTEST
} }
} // anonymous namespace } // anonymous namespace
@@ -86,8 +94,13 @@ bool wxUIActionSimulator::MouseMove(long x, long y)
wxX11Display display; wxX11Display display;
wxASSERT_MSG(display, "No display available!"); wxASSERT_MSG(display, "No display available!");
#if wxUSE_XTEST
XTestFakeMotionEvent(display, -1, x, y, 0);
#else // !wxUSE_XTEST
Window root = display.DefaultRoot(); Window root = display.DefaultRoot();
XWarpPointer(display, None, root, 0, 0, 0, 0, x, y); XWarpPointer(display, None, root, 0, 0, 0, 0, x, y);
#endif // !wxUSE_XTEST
// At least with wxGTK we must always process the pending events before the // At least with wxGTK we must always process the pending events before the
// mouse position change really takes effect, so just do it from here // mouse position change really takes effect, so just do it from here
@@ -130,6 +143,14 @@ bool wxUIActionSimulator::DoKey(int keycode, int modifiers, bool isDown)
if ( xkeycode == NoSymbol ) if ( xkeycode == NoSymbol )
return false; return false;
#if wxUSE_XTEST
wxUnusedVar(modifiers);
wxUnusedVar(mask);
wxUnusedVar(type);
XTestFakeKeyEvent(display, xkeycode, isDown, 0);
return true;
#else // !wxUSE_XTEST
Window focus; Window focus;
int revert; int revert;
XGetInputFocus(display, &focus, &revert); XGetInputFocus(display, &focus, &revert);
@@ -164,6 +185,7 @@ bool wxUIActionSimulator::DoKey(int keycode, int modifiers, bool isDown)
XSendEvent(event.display, event.window, True, mask, (XEvent*) &event); XSendEvent(event.display, event.window, True, mask, (XEvent*) &event);
return true; return true;
#endif // !wxUSE_XTEST
} }
#endif // wxUSE_UIACTIONSIMULATOR #endif // wxUSE_UIACTIONSIMULATOR