/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Function that would check the color of the current mouse pointer.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void
checkColorPointer( int rx,
int ry )
{
Display *dpy;
Window rootWin;
char *fname = (char *) 0;
char *display_str = (char *) 0;
XImage *xi;
int x0, y0;
unsigned RDwidth, RDheight;
unsigned int RDflags = 0;
Is this your own solution to the question that you earlier posted? I think the code can`t work. If I remember correctly, there isn`t any way to get this information about the cursor, and taking the screen image (with outdated X routines) won`t help. One of the questions in the X faq deals with making screen-dumps that include the X cursor, and that question points out that getting information about the cursor is not possible.
XImage *XReadDisplay (
Display *dpy,
Window src,
int x,
int y,
unsigned int w,
unsigned int h,
unsigned long hints,
unsigned long *hints_return);
PREDEFINED VALUES
XRD_READ_ALPHA
tells the server to read alpha planes into the upper 8
bits of the pixel value.
XRD_IGNORE_NORMAL_LAYER
tells the server to ignore windows in the normal layer.
This is the layer the root window is in.
XRD_TRANSPARENT
tells the server to ignore pixels that are transparent,
and read the color value of underlying pixels.
Normally, transparent pixels are returned as if they
were visible.
XRD_READ_POINTER
tells the server to include the mouse pointer in the
returned image.
Window root, child;
int rx, ry, wx, wy;
unsigned int mask;
XQueryPointer(display, win, &root, &child, &rx, &ry, &wx, &wy, &mask);
checkColorPointer( rx+3, ry);
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Function that would check the color of the current mouse pointer.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void
checkColorPointer( int rx,
int ry )
{
Display *dpy;
Window rootWin;
char *fname = (char *) 0;
char *display_str = (char *) 0;
XImage *xi;
int x0, y0;
unsigned RDwidth, RDheight;
unsigned int RDflags = 0;
XColor rgb;
Colormap colormap;
RDflags |= XRD_READ_POINTER;
x0 = rx;
y0 = ry;
RDwidth = SQUARE_SCREEN_SHOT;
RDheight = SQUARE_SCREEN_SHOT;
if( display_str == (char *) 0 )
{
display_str = "";
}
if( fname == (char *) 0 )
{
fname = "pointerImage.rgb";
}
dpy = XOpenDisplay(display_str);
if (dpy == 0)
{
printf("Unable to open display
");
exit(1);
}
rootWin = RootWindow( dpy, DefaultScreen(dpy));
if ( ( RDwidth != 0 ) && ( RDheight != 0 ) )
{
XGrabServer( dpy ); /* Try to grab the X server to "pause" it*/
XSync( dpy, False );
xi = XReadDisplay( dpy, rootWin, x0, y0, RDwidth, RDheight, RDflags, 0);
rgb.pixel = XGetPixel(xi, 0, 0);
colormap = DefaultColormap(dpy, DefaultScreen(dpy));
XQueryColor(dpy, colormap, &rgb);
printf("
Pixel %3ld -- Red %02x -- Green %02x -- Blue %02x
", rgb.pixel, rgb.red>>=8, rgb.green>>=8, rgb.blue>>=8);
}
XDestroyImage(xi);
XCloseDisplay(dpy);
}
Is this your own solution to the question that you earlier posted? I think the code can`t work. If I remember correctly, there isn`t any way to get this information about the cursor, and taking the screen image (with outdated X routines) won`t help. One of the questions in the X faq deals with making screen-dumps that include the X cursor, and that question points out that getting information about the cursor is not possible.
This is possible, I made it
XImage *XReadDisplay (
Display *dpy,
Window src,
int x,
int y,
unsigned int w,
unsigned int h,
unsigned long hints,
unsigned long *hints_return);
PREDEFINED VALUES
XRD_READ_ALPHA
tells the server to read alpha planes into the upper 8
bits of the pixel value.
XRD_IGNORE_NORMAL_LAYER
tells the server to ignore windows in the normal layer.
This is the layer the root window is in.
XRD_TRANSPARENT
tells the server to ignore pixels that are transparent,
and read the color value of underlying pixels.
Normally, transparent pixels are returned as if they
were visible.
XRD_READ_POINTER
tells the server to include the mouse pointer in the
returned image.
I`d love to see the implementation. If you can share it, email me at dbl@motifzone.net. Thx.
Sorry my friend but I try, give me a other email adress ...
The original message was received at Mon, 20 Aug 2001 112739 -0400 (EDT)
from smtp.discreet.com [209.58.5.130]
----- The following addresses had permanent fatal errors -----
----- Transcript of session follows -----
... while talking to radiskull.ics.com.
>>> RCPT To
<<< 550 ... User unknown
550 ... User unknown
Reporting-MTA dns; ics.com
Received-From-MTA DNS; smtp.discreet.com
Arrival-Date Mon, 20 Aug 2001 112739 -0400 (EDT)
Final-Recipient RFC822; dbl@motifzone.net
Action failed
Status 5.1.1
Remote-MTA DNS; radiskull.ics.com
Diagnostic-Code SMTP; 550 ... User unknown
Last-Attempt-Date Mon, 20 Aug 2001 112740 -0400 (EDT)
Then try me at dbl@ics.com directly. Thanks.