Get current cursor type (XC_xterm, XC_cross...)

Jochen Baier Jochen.Baier at stud.uni-karlsruhe.de
Thu Jul 28 19:07:15 PDT 2005


hi,

i am searching for a way to detect if i clicked on a text entry after 
clicked inside a window. for example
if i clicked on the google search input field. (middle mousebutton is 
grabbed)

my idea was to look if the current cursor changed to "XC_xterm", but with
XQueryPointer to find the innermost window and 
XTestCompareCursorWithWindow i had no success.
(see code below)

somebody have a idea ?

thanks, jochen



"not working example ;) "

Window get_cursor_window (Window parent)
{

  Window root_return, child_return=None, runner;
  int root_x_return, root_y_return, win_x_return, win_y_return;
  unsigned int mask_return;
  Window new_child=parent;

  while (1) {
 
    if (XQueryPointer(display_xlib, new_child, &root_return, 
&child_return, &root_x_return,
          &root_y_return, &win_x_return,  &win_y_return,&mask_return) ) {
         
          if (child_return == None) {
            break;
          } else {
            new_child=child_return;
            child_return=None;
          }
         
    } else break;
 
  }

   return new_child;
}


XGrabButton(display_xlib, 2, AnyModifier, root_xlib, True, 
ButtonReleaseMask |
      ButtonPressMask, GrabModeAsync, GrabModeAsync , root_xlib, None);

........


Cursor cur=XCreateFontCursor (display_xlib, XC_xterm);
Window test=get_cursor_window (xev->xany.window);
     
if (XTestCompareCursorWithWindow(display_xlib, test, cur))
  printf ("found XC_xterm cursor\n");









More information about the xorg mailing list