MCPcopy Create free account
hub / github.com/ckaiser/Lightscreen / findRealWindow

Method findRealWindow

tools/os.cpp:318–359  ·  view source on GitHub ↗

Taken from KSnapshot. Oh KDE, what would I do without you :D

Source from the content-addressed store, hash-verified

316#ifdef Q_OS_LINUX
317// Taken from KSnapshot. Oh KDE, what would I do without you :D
318Window os::findRealWindow(Window w, int depth)
319{
320 if (depth > 5) {
321 return None;
322 }
323
324 static Atom wm_state = XInternAtom(QX11Info::display(), "WM_STATE", False);
325 Atom type;
326 int format;
327 unsigned long nitems, after;
328 unsigned char *prop;
329
330 if (XGetWindowProperty(QX11Info::display(), w, wm_state, 0, 0, False, AnyPropertyType,
331 &type, &format, &nitems, &after, &prop) == Success) {
332 if (prop != NULL) {
333 XFree(prop);
334 }
335
336 if (type != None) {
337 return w;
338 }
339 }
340
341 Window root, parent;
342 Window *children;
343 unsigned int nchildren;
344 Window ret = None;
345
346 if (XQueryTree(QX11Info::display(), w, &root, &parent, &children, &nchildren) != 0) {
347 for (unsigned int i = 0;
348 i < nchildren && ret == None;
349 ++i) {
350 ret = os::findRealWindow(children[ i ], depth + 1);
351 }
352
353 if (children != NULL) {
354 XFree(children);
355 }
356 }
357
358 return ret;
359}
360
361Window os::windowUnderCursor(bool includeDecorations)
362{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected