From 9d34cdbfa9a4e026cca504c7aec728ddfc86cbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Wed, 29 Jun 2016 23:42:15 +0200 Subject: avoid calling into XLib Testing one bug, the function seems usually be called with the root window as parameter, so we can save a pointless lookup for the root of the root by testing against window before testing against window_root. Elegantly, this will "fix" the bug where XGetGeometry of the second heads root will either report the first heads root or some junk (xephyr case?) BUG: 1128 --- src/fluxbox.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 7b73360..492b64d 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -981,14 +981,22 @@ void Fluxbox::attachSignals(WinClient &winclient) { BScreen *Fluxbox::searchScreen(Window window) { + ScreenList::iterator it = m_screens.begin(); + ScreenList::iterator it_end = m_screens.end(); + + // let's first assume window is a root window + for (; it != it_end; ++it) { + if (*it && (*it)->rootWindow() == window) + return *it; + } + + // no? query the root for window and try with that Window window_root = FbTk::FbWindow::rootWindow(display(), window); - if (window_root == None) { + if (window_root == None || window_root == window) { return 0; } - ScreenList::iterator it = m_screens.begin(); - ScreenList::iterator it_end = m_screens.end(); - for (; it != it_end; ++it) { + for (it = m_screens.begin(); it != it_end; ++it) { if (*it && (*it)->rootWindow() == window_root) return *it; } -- cgit v0.11.2