My apps needs to know when it's window is moved (I need to know the exact position of my app's window relative to the screen (root window / absolute position) - e.g. the one returned by xcb_translate_coordinates
with dst_window set to the root window of a screen).
The problem is that I need to receive an event if my window is moved by user. I've added the XCB_EVENT_MASK_STRUCTURE_NOTIFY
to the event mask as suggested here on SO, my app only get the event when it's relative position to the window manager's frame is changed (which in turns, the X server doesn't fire any event to my app if the window is moved by user, because it doesn't change the relative position to the window manager's frame). For additional info, here is the window creation code:
uint32_t events = XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_KEY_PRESS;
xcb_create_window(conn, XCB_COPY_FROM_PARENT, main_window, scr->root, 0, 0, width, height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
scr->root_visual, XCB_CW_EVENT_MASK , &events);
xcb_map_window(conn, main_window);
I've tried this in my desktop session and Xephyr, with Xfwm4, Openbox and metacity, both in compositing mode and non compositing mode, and all yields the same result.
What is the solution so that I can be notified about window movement events? I don't want to enable override_redirect
, because I also need that my application be managed by the window manager.
Finally, after some research, it turns out that most Window Managers, at least those that do reparenting, stacking and/or compositing sends a ConfigureNotify
event to their clients with synthetic
bit flag sets to true (e.g. with MSB set on XCB's response_type
), whose x
and y
set to the client window's absolute position. Confirmed with Xfwm4, Openbox, metacity and KWin.