Skip to content

Instantly share code, notes, and snippets.

@jarrettchisholm
Last active December 11, 2015 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarrettchisholm/4666488 to your computer and use it in GitHub Desktop.
Save jarrettchisholm/4666488 to your computer and use it in GitHub Desktop.
x11 window position patch for SFML 2.0
284,286c284,304
< XWindowAttributes attributes;
< XGetWindowAttributes(m_display, m_window, &attributes);
< return Vector2i(attributes.x, attributes.y);
---
> ::Window activeWin, root;
> int xCoordinate, yCoordinate;
> uint width, height, border_width, depth;
> ::Window *children;
> uint childcount;
>
> int x = 0;
> int y = 0;
>
> activeWin = m_window;
>
> while (activeWin != root) {
> if(XGetGeometry(m_display, activeWin, &root, &xCoordinate, &yCoordinate, &width, &height, &border_width, &depth)) {
> x += xCoordinate;
> y += yCoordinate;
> }
>
> XQueryTree(m_display, activeWin, &root, &activeWin, &children, &childcount);
> }
>
> return Vector2i(x, y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment