Search code examples
c++x11xlib

Get relative position of mouse in a window in x11


I need to get the relative position of mouse pointer in the window in which it is clicked, i've coded to capture the click event, but when i use this code


result = XQueryPointer(disp, XRootWindow(disp,0),&win, &win, &root_x, &root_y, &win_x, &win_y, &mask_return);

it shows the global position of mouse when printing win_x and win_y

only window i have is "win" the display is "disp"


Solution

  • Found out evt.xbutton.x and evt.xbutton.y returns window relative mouse co ordinates