diff --git a/source/Platform/Unix/Xlib.cpp b/source/Platform/Unix/Xlib.cpp index 32e36fb..bde34f8 100644 --- a/source/Platform/Unix/Xlib.cpp +++ b/source/Platform/Unix/Xlib.cpp @@ -26,6 +26,22 @@ void shutdown() return _priv::display; } +// Implementation borrowed from SFML :) +::Window getParentWindow(::Window win) +{ + ::Window root, parent; + ::Window* children = nullptr; + unsigned int numChildren; + + ::XQueryTree(getDisplay(), win, &root, &parent, &children, &numChildren); + + // Children information is not used, so must be freed. + if (children != nullptr) + XFree(children); + + return parent; +} + ::Atom getAtom(const std::string& name, bool onlyIfExists) { return XInternAtom(getDisplay(), name.c_str(), onlyIfExists); diff --git a/source/Platform/Unix/Xlib.h b/source/Platform/Unix/Xlib.h index cc5cb2d..53a9d7e 100644 --- a/source/Platform/Unix/Xlib.h +++ b/source/Platform/Unix/Xlib.h @@ -15,6 +15,8 @@ void shutdown(); ::Display* getDisplay(); +::Window getParentWindow(::Window win); + ::Atom getAtom(const std::string& name, bool onlyIfExists = false); } } // namespace sp::xlib