How to get top-level window position relative to root window (i.e. whole screen) using plain ol' xlib (or brand new XCB)?
相关问题
- X11 forwarding affects Java Swing GUI dropdowns -
- X11 non-clipped child windows
- Using Python GTK GUI front end with C++ backend
- Saving xlib XImage to PNG
- R script using X11 window only opens for a second
相关文章
- Tracking XWindow Protocol
- How do I map an X11 keysym to a Unicode character?
- Sending Keystrokes to a X Window
- XLib Window Name Problems
- Desktop integrated application (desktop widget lik
- With X11, how can I get the user's time “away
- Programmatically launching standalone Adobe flashp
- Embedding QWidget into X11 Window
Use XTranslateCoordinates (or xcb equivalent) to translate 0,0 on the window to root window coordinates.
Using Xlib:
There are also lots of other informations that come with
XWindowAttributes
. See here.This is what you would do with XCB:
The x,y components of the structure returned by XGetWindowAttributes are relative to the origin of the window's parent. That's not the same as relative to the top left of the screen.
Calling XTranslateCoordinates passing the root window and 0,0 gives coordinates of the window relative to the screen.
I found that if I write:
The values displayed by the printf are those which, if passed to XMoveWindow, keep the window at its current position. Thus those coordinates are reasonably considered to be the position of the window.