Search code examples
clinuxmouseeventxlib

Errors while trying to get mouse click coordinates


I'm trying to run the code from this topic (first answer): getting mouseclick coordinates with Xlib and it gives me some errors.

Output:

$ ./a.out
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

Solution

  • Should use: gcc c.cc -lX11
    And change one string to: XSelectInput(display, root, ButtonReleaseMask);