I develop a plugin for compiz window manager. I want to draw a transformed window texture and send an event to that window. When a transformed window is renderer I grab pointer to take control off all xevents, the main part of compiz function which grabs pointer looks like this:
status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow(), true,
POINTER_GRAB_MASK,
GrabModeAsync, GrabModeAsync,
privateScreen.rootWindow(), cursor,
CurrentTime);
When a pointer is grabbed I recalculate button press coordinates and I use XSendEvent to send events to the destination window. It works fine for google chrome window or for a simple xwindow application like this: link Unfortunately it doesn't work correctly for a window which performs OpenGL rendering - I have tested SDL and GLFW. Such window receives click events but with different parameters (xbutton.x_root, xbutton.y_root, xbutton.x, xbutton.y) than I specified in XSendEvent. Each time when I send an event those parameters contains the same values which seem to be the mouse position before xgrabpointer was called. When a pointer is not grabbed events (from XSendEvent) are received correctly. There must be some specific relation between xsendevent, xgrabpointer and a window which performs OpenGL rendering. Moreover clients (windows) implementation may differ because my code doesn't work only for that specific windows or maybe I do something wrong ?
Edit1
Let's consider following example: I have a fullscreen window, then I can use a plugin to draw transformed window texture (for example scale transformation (0.5, 0.5, 1.0)), but X11 still sees a fullscreen window, so when I click on the region outside a transformed texture event go to the window. When I grab pointer in the plugin I'm the only receiver off all events, then I can recalculate cooridnates based on my window transfomation and send them to the window.
Edit2 When I use Freeglut all events are sent correctly to the destination window when pointer is grabbed. There have to be some differences between library implementations.