Cursor hang on left press event while moving the window
I have a problem when I use the Xlib API on the openmotif window manager. I can reproduce the problem with Xorg 1.17.4. The hang is reproducible with these simple steps:
- left click on the title bar
- try to move the window (don't release the left button)
- the cursor is hung on the "PRESS" event.
NOTE: If I left click with the physical mouse the cursor get unfroze from the "PRESS" status.
[user@computer ]# rpm -qa xorg-x11-server*
xorg-x11-server-common-1.17.4-17.el6.x86_64
xorg-x11-server-Xorg-1.17.4-17.el6.x86_64
xorg-x11-server-Xvfb-1.17.4-17.el6.x86_64
xorg-x11-server-utils-7.7-14.el6.x86_64
[user@computer ]# rpm -q openmotif
openmotif-2.3.3-9.el6.x86_64
I can reproduce the problem with this simple C code:
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBstr.h>
Display *try_open_display(void)
{
Display *xdisplay = NULL;
void *find_x_client_state = NULL;
char_t *display;
display = get_env("DISPLAY");
do
{
xdisplay = XOpenDisplay(NULL);
if (xdisplay == NULL)
{
find_x_client_state = find_x_client_on_display(display, find_x_client_state);
}
}
while (xdisplay == NULL && find_x_client_state != NULL);
find_x_client_cleanup(find_x_client_state);
return xdisplay;
}
void runXlibTest (void)
{
int index;
int cursor_x_current = 0;
int cursor_y_current = 0;
int cursor_x_root = 0;
int cursor_y_root = 0;
unsigned int mask_return;
Display *xwm_disp;
Window window_returned;
xwm_disp = try_open_display();
XQueryPointer(xwm_disp, XRootWindow(xwm_disp, 0), &window_returned, &window_returned, &cursor_x_root, &cursor_y_root, &cursor_x_current, &cursor_y_current, &mask_return);
//Move forward
printf("Move Forward\n");
printf("PRESS\n");
XTestFakeButtonEvent(xwm_disp,Button1,1,CurrentTime);
XSync(xwm_disp,0);
for(index = 0 ; index < 100 ; index++)
{
XTestFakeMotionEvent(xwm_disp,0,cursor_x_root + index,cursor_y_root + index,CurrentTime);
XSync(xwm_disp,0);
usleep(5000);
}
printf("RELEASE\n");
XTestFakeButtonEvent(xwm_disp,Button1,0,CurrentTime);
XSync(xwm_disp,0);
usleep(5000);
//Move back
printf("Move Back\n");
printf("PRESS\n");
XTestFakeButtonEvent(xwm_disp,Button1,1,CurrentTime);
XSync(xwm_disp,0);
for(index = 99 ; index >= 0 ; index--)
{
XTestFakeMotionEvent(xwm_disp,0,cursor_x_root + index,cursor_y_root + index,CurrentTime);
XSync(xwm_disp,0);
usleep(5000);
}
printf("RELEASE\n");
XTestFakeButtonEvent(xwm_disp,Button1,0,CurrentTime);
XSync(xwm_disp,0);
XFlush(xwm_disp);
}
void main()
{
for(int index = 0 ; index < 10 ; index++)
{
runXlibTest();
}
}
This code move the cursor forward and back from current cursor position (x,y) to (x + 99, y + 99) and this repeated for 10 times:
- Perform a left button PRESS
- Move diagonally the pointer (down direction)
- Perform a left button RELEASE
- Perform a left button PRESS
- Move diagonally the pointer (up direction)
- Perform a left button RELEASE
The test program work flawlessly if no window title is present under the cursor. However if the cursor is positioned on the title bar of the terminal application when the program is run then it get stuck on the first PRESS + MOVE sequence:
NOTE: The problem is not reproducible if a different window manager is used.
I don't know if this issue might be related to that: #860 (closed)