Bug 2710 - X Test extensions mix strings
Summary: X Test extensions mix strings
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/other (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Stuart Anderson
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-12 08:04 UTC by Thorsten Staerk
Modified: 2006-04-01 00:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Thorsten Staerk 2005-03-12 08:04:40 UTC
I wrote a test program that shall simulate a user typing "test" on the 
keyboard. I am using your Xtest extension for that. 
The program simulates "ttes" instead of "test". 
 
The same problem can be seen in Xautomation from 
http://hoopajoo.net/projects/xautomation.html 
 
Here is my test program simkey.c: 
// This program demonstrates a bug in the X test extension 
// Compile and link this program like this: gcc -I/usr/X11R6/include 
-L/usr/X11R6/lib -o simkey simkey.c -lX11 -lXtst 
 
#include <X11/extensions/XTest.h> 
#include <X11/keysym.h> 
#include <stdio.h> 
 
int main(int argc, char *argv[]) 
{ 
  Display* disp = XOpenDisplay(NULL); 
  { 
    char *t="test"; 
    char *s; 
    int i; 
    for (i=0;i<=3;i++) 
    { 
      strncpy(s,&t[i],1); 
      XTestFakeKeyEvent( disp, XKeysymToKeycode (disp, *s), True, CurrentTime); 
      XTestFakeKeyEvent( disp, XKeysymToKeycode (disp, *s), False, 
CurrentTime); 
    } 
  } 
  XCloseDisplay(disp); 
}
Comment 1 Adam Jackson 2005-05-30 11:28:09 UTC
product shift, xorg -> xtest.
Comment 2 Daniel Stone 2006-04-01 17:51:15 UTC
does flushing xlib's buffer -- XFlush(dpy, FALSE); -- after each character,
help?  if not, does using XSync instead of XFlush help?
Comment 3 Thorsten Staerk 2006-04-01 18:25:58 UTC
Time has passed, my compiler has changed to GCC 4. Here's my adapted test 
program: 
 
/* This program demonstrates a bug in the X test extension  
Compile and link this program like this: gcc -I/usr/X11R6/include 
-L/usr/X11R6/lib -o simkey simkey.c -lX11 -lXtst  
*/ 
  
#include <X11/extensions/XTest.h>  
#include <X11/keysym.h>  
#include <stdio.h>  
  
int main(int argc, char *argv[])  
{  
  Display* disp = XOpenDisplay(NULL);  
  {  
    char *t="test";  
    char *s;  
    int i;  
    for (i=0;i<=3;i++)  
    {  
      s=&t[i];  
      XTestFakeKeyEvent( disp, XKeysymToKeycode (disp, *s), True, CurrentTime);  
      XTestFakeKeyEvent( disp, XKeysymToKeycode (disp, *s), False,  
CurrentTime);  
    }  
  }  
  XCloseDisplay(disp);  
} 
Comment 4 Thorsten Staerk 2006-04-01 18:27:27 UTC
XFlush(disp) brings the solution. 
Comment 5 Thorsten Staerk 2006-04-01 18:28:22 UTC
err... thanks, you really made my day !!! 


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.