hi everybody,
I am new to X-Programming under *nix. Here is a
demo program that just use several standard X-Lib
functions. However, it runs with various problems
under different platforms.
//Demo.c
#include <stdio.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
Display *display;
Window win;
static int g_scan=0;
int my_create();
void my_close();
int process_event(XEvent report);
int eventloop();
void main(void)
{
my_create();
for(;;)
{
if(eventloop()== 1) break;
}
XCloseDisplay(display);
}
int my_create()
{
display = XOpenDisplay(NULL);
if (display == NULL)
{
fprintf(stderr, "Failed to open display
");
return 0;
}
win = atol(getenv("WINDOWID"));
XSelectInput(display, win, KeyPressMask);
}
int process_event(XEvent report)
{
KeySym key;
switch(report.type)
{
case KeyPress:
key = XLookupKeysym(&report.xkey, 0);
printf("myl:%x
", key);
switch(key)
{
case(0xFF1b): /* esc */
g_scan = 0x1;
break;
default:
break;
}
break;
default:
break;
}
return 0;
}
int eventloop()
{
XEvent xev;
int scan=0;
XNextEvent(display, &xev);
scan = process_event(xev);
return scan;
}
I. Red Hat Linux 7.1 XFree86-libs-4.0.3-5
glibc-common-2.2.2-10
Following error messsge has been got.
X Error of failed request: BadAccess (attempt to
access private resource denied)
Major opcode of failed request: 2
(X_ChangeWindowAttributes)
Serial number of failed request: 8
Current serial number in output stream: 8
II. SCO OpenServer or SCO UnixWare
I don't know how to get the XLib version of them.
The promgram seems work well at first. However, after
you drag the Term Window to move it or switching
between different windows, the program will lost key
input(you can still see what you type, because echo is
on), you can't see the Hex code of what you type in.
Thank you for your concern.
__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/
_______________________________________________
Newbie mailing list
[EMAIL PROTECTED]
*** To unsubscribe , or change message options, see:
http://XFree86.Org/mailman/listinfo/newbie