--- a/XWorkstation.st Wed Mar 27 15:22:26 2019 +0100
+++ b/XWorkstation.st Mon Apr 01 14:58:35 2019 +0200
@@ -237,6 +237,10 @@
# endif
#endif
+#ifdef XTEST
+# include <X11/extensions/XTest.h>
+#endif
+
#if defined(someMachine)
/*
* if nformats cannot be found in the Display structure ...
@@ -1015,7 +1019,8 @@
This is the devices mask."
%{ /* NOCONTEXT */
- RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask));
+ RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask
+ | Button4MotionMask | Button5MotionMask));
%}.
^ nil
!
@@ -1066,20 +1071,30 @@
%}
!
-buttonMotionMask:aButton
- "return the state-mask for button1 in motion events state-field.
+buttonMotionMask:aButtonNr
+ "return the state-mask for button<n> in motion events state-field.
This is the devices mask."
%{ /* NOCONTEXT */
- if (aButton == __MKSMALLINT(1)) {
+ if (aButtonNr == __MKSMALLINT(1)) {
RETURN (__MKSMALLINT(Button1MotionMask));
}
- if (aButton == __MKSMALLINT(2)) {
+ if (aButtonNr == __MKSMALLINT(2)) {
RETURN (__MKSMALLINT(Button2MotionMask));
}
- if (aButton == __MKSMALLINT(3)) {
+ if (aButtonNr == __MKSMALLINT(3)) {
RETURN (__MKSMALLINT(Button3MotionMask));
}
+ if (aButtonNr == __MKSMALLINT(4)) {
+ RETURN (__MKSMALLINT(Button4MotionMask));
+ }
+ if (aButtonNr == __MKSMALLINT(5)) {
+ RETURN (__MKSMALLINT(Button5MotionMask));
+ }
+ if (aButtonNr == @symbol(all)) {
+ RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask
+ | Button4MotionMask | Button5MotionMask));
+ }
%}.
^ nil
!
@@ -6405,7 +6420,7 @@
RETURN (false);
}
-# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask)
+# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask)
# define ae ((XAnyEvent *)&ev)
# define ee ((XExposeEvent *)&ev)
@@ -7034,6 +7049,13 @@
!
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId
+ ^ self
+ sendKeyOrButtonEvent:typeSymbol
+ x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask
+ toViewId:targetId useXTest:false
+!
+
+sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId useXTest:useXTestBoolean
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view.
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease.
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...);
@@ -7066,9 +7088,13 @@
KeySym keySym, *syms;
int screen = __intVal(__INST(screen));
int nSyms;
+ int isButtonEvent = 0, isKeyEvent = 0;
if ((typeSymbol == @symbol(keyPress))
|| (typeSymbol == @symbol(keyRelease))) {
+ isKeyEvent = 1;
+ ev.xany.type = (typeSymbol == @symbol(keyPress))
+ ? KeyPress : KeyRelease;
if (__isStringLike(keySymCodeOrButtonNr)) {
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr));
} else {
@@ -7111,6 +7137,10 @@
} else {
if ((typeSymbol == @symbol(buttonPress))
|| (typeSymbol == @symbol(buttonRelease))) {
+ isButtonEvent = 1;
+ ev.xany.type = (typeSymbol == @symbol(buttonPress))
+ ? ButtonPress : ButtonRelease;
+
if (__isSmallInteger(keySymCodeOrButtonNr)) {
ev.xbutton.button = __intVal(keySymCodeOrButtonNr);
} else {
@@ -7122,15 +7152,6 @@
}
}
- if (typeSymbol == @symbol(keyPress))
- ev.xany.type = KeyPress;
- else if (typeSymbol == @symbol(keyRelease))
- ev.xany.type = KeyRelease;
- else if (typeSymbol == @symbol(buttonPress))
- ev.xany.type = ButtonPress;
- else if (typeSymbol == @symbol(buttonRelease))
- ev.xany.type = ButtonRelease;
-
if (__isExternalAddress(targetId)) {
target = __WindowVal(targetId);
} else {
@@ -7146,7 +7167,18 @@
ev.xkey.time = CurrentTime;
ENTER_XLIB();
- result = XSendEvent(dpy, target, False, 0 , &ev);
+#ifdef XTEST
+ if (useXTestBoolean == true) {
+ if (isButtonEvent) {
+ XTestFakeButtonEvent(dpy, ev.xbutton.button, ev.xany.type == ButtonPress, CurrentTime);
+ } else {
+ XTestFakeKeyEvent(dpy, ev.xkey.keycode, ev.xany.type == KeyPress, CurrentTime);
+ }
+ } else
+#endif
+ {
+ result = XSendEvent(dpy, target, False, 0 , &ev);
+ }
LEAVE_XLIB();
if ((result == BadValue) || (result == BadWindow)) {
DPRINTF(("bad status\n"));
@@ -8037,8 +8069,8 @@
!
getFontWithFoundry:foundry family:family weight:weight
- slant:slant spacing:spc pixelSize:pSize size:size
- encoding:encoding
+ slant:slant spacing:spc pixelSize:pSize size:size
+ encoding:encoding
"get the specified font, if not available, return nil.
Individual attributes can be left empty (i.e. '') or nil to match any.
@@ -8059,40 +8091,40 @@
"this works only on 'Release >= 3' - X-servers"
"name is:
- -foundry-family -weight -slant-
- sony helvetica bold r
- adobe courier medium i
- msic fixed o
- ... ...
+ -foundry-family -weight -slant-
+ sony helvetica bold r
+ adobe courier medium i
+ msic fixed o
+ ... ...
"
size isNil ifTrue:[
- sizeMatch := '*'
+ sizeMatch := '*'
] ifFalse:[
- sizeMatch := size printString , '0'
+ sizeMatch := size printString , '0'
].
foundryMatch := foundry ? '*'.
familyMatch := family ? '*'.
weightMatch := weight ? '*'.
slantMatch := slant ? '*'.
- spcMatch := spc ? '*'.
+ spcMatch := spc ? '*'.
pSize isNil ifTrue:[
- pSizeMatch := '*'
+ pSizeMatch := '*'
] ifFalse:[
- pSizeMatch := pSize printString
+ pSizeMatch := pSize printString
].
encodingMatch := encoding ? '*'.
theName := ('-' , foundryMatch,
- '-' , familyMatch,
- '-' , weightMatch ,
- '-' , slantMatch ,
- '-' , spcMatch ,
- '-*' ,
- '-' , pSizeMatch ,
- '-' , sizeMatch ,
- '-*-*-*-*' ,
- '-' , encodingMatch).
+ '-' , familyMatch,
+ '-' , weightMatch ,
+ '-' , slantMatch ,
+ '-' , spcMatch ,
+ '-*' ,
+ '-' , pSizeMatch ,
+ '-' , sizeMatch ,
+ '-*-*-*-*' ,
+ '-' , encodingMatch).
"/ Transcript showCR:theName; endEntry.
@@ -8101,24 +8133,24 @@
"
Display
- getFontWithFoundry:'*'
- family:'courier'
- weight:'medium'
- slant:'r'
- spacing:nil
- pixelSize:nil
- size:13
- encoding:#'iso8859-1'.
+ getFontWithFoundry:'*'
+ family:'courier'
+ weight:'medium'
+ slant:'r'
+ spacing:nil
+ pixelSize:nil
+ size:13
+ encoding:#'iso8859-1'.
Display
- getFontWithFoundry:'*'
- family:'courier'
- weight:'medium'
- slant:'r'
- spacing:nil
- pixelSize:nil
- size:13
- encoding:#'iso10646-1'
+ getFontWithFoundry:'*'
+ family:'courier'
+ weight:'medium'
+ slant:'r'
+ spacing:nil
+ pixelSize:nil
+ size:13
+ encoding:#'iso10646-1'
"
"Modified: / 10-04-1997 / 19:15:44 / cg"
@@ -10621,9 +10653,7 @@
"return an integer for masking out any button from a
buttonStates value."
- "/ should use ``Display buttonXMotionMask bitOr:....''
-
- ^ 256 + 512 + 1024
+ ^ self buttonMotionMask:#all
"Modified: 23.3.1996 / 12:41:33 / cg"
"Created: 23.3.1996 / 12:46:35 / cg"
@@ -10683,9 +10713,7 @@
"return an integer for masking out the left button from a
buttonStates value"
- "/ should use ``Display button1MotionMask''
-
- ^ 256
+ ^ self button1MotionMask
"Modified: 23.3.1996 / 12:41:33 / cg"
!
@@ -10694,9 +10722,7 @@
"return an integer for masking out the middle button from a
buttonStates value"
- "/ should use ``Display button2MotionMask''
-
- ^ 512
+ ^ self button2MotionMask
"Modified: 23.3.1996 / 12:41:43 / cg"
!
@@ -10742,9 +10768,7 @@
"return an integer for masking out the right button from a
buttonStates value"
- "/ should use ``Display button3MotionMask''
-
- ^ 1024
+ ^ self button3MotionMask
"Modified: 23.3.1996 / 12:41:52 / cg"
!