This is the mail archive of the
cygwin-xfree
mailing list for the Cygwin XFree86 project.
An issue with libX11?
- From: Angelo Graziosi <angelo dot graziosi at alice dot it>
- To: cygwin-xfree at cygwin dot com
- Date: Sun, 09 Nov 2014 16:38:27 +0100
- Subject: An issue with libX11?
- Authentication-results: sourceware.org; auth=none
- Reply-to: cygwin-xfree at cygwin dot com
- Reply-to: cygwin-xfree at cygwin dot com
From another application I have an issue with libX11 which I can
reproduce with the following STC,
$ cat getch_test.c
/*
gcc getch_test.c -lX11 -o getch_test.out
DISPLAY=127.0.0.1:0.0 ./getch_test.out
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
Display *dis;
Window win;
int fun()
{
XEvent event;
char c;
printf("1\n");
while(1)
{
printf("2\n");
XNextEvent(dis, &event);
printf("3\n");
if (event.type == KeyPress)
{
c = (char) XLookupKeysym(&event.xkey, 0);
return (int) c;
}
}
}
int main()
{
dis = XOpenDisplay(NULL);
win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 1, 1, 500, 500,
0, BlackPixel (dis, 0), BlackPixel(dis, 0));
XMapWindow(dis, win);
XFlush(dis);
printf("Press a key:\n");
fun();
/*Sleep 5 seconds before closing.*/
//sleep(5);
return (0);
}
Running it, one gets
$ DISPLAY=127.0.0.1:0.0 ./getch_test.out
Press a key:
1
2
HANGS
it does not print "3", so it seems it does not return from
XNextEvent(dis, &event);
I am not an X11 expert, so it could be I am doing the wrong things but
the same code runs fine on OSX+XQuartz and GCC-4.9.1.
For completeness, I start the Cygwin X server with a link on status bar
(W7+Cygwin64) whose target is:
C:\cygwin64\bin\run.exe --quote bash -l -c "rm -rf /tmp/.X*; XWin
-multiwindow -clipboard -silent-dup-error 2>/dev/null &"
Ciao,
Angelo.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ: http://x.cygwin.com/docs/faq/