Index: ui/views/widget/desktop_aura/x11_topmost_window_finder.cc |
diff --git a/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc b/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc |
index eb0d1bdcba917bb24b5067b87f1dcc5a9bd7de45..75e76f235e05ae65172978b3e902cf1e96774f4a 100644 |
--- a/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc |
+++ b/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc |
@@ -19,16 +19,23 @@ aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( |
const gfx::Point& screen_loc, |
const std::set<aura::Window*>& ignore) { |
screen_loc_ = screen_loc; |
- ignore_ = ignore; |
+ for (std::set<aura::Window*>::const_iterator it = ignore.begin(); |
+ it != ignore.end(); ++it) { |
+ XID xid = (*it)->GetHost()->GetAcceleratedWidget(); |
+ cache_.insert(std::make_pair(xid, false)); |
+ } |
std::vector<aura::Window*> local_process_windows = |
DesktopWindowTreeHostX11::GetAllOpenWindows(); |
bool found_local_process_window = false; |
for (size_t i = 0; i < local_process_windows.size(); ++i) { |
- if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) { |
+ XID xid = local_process_windows[i]->GetHost()->GetAcceleratedWidget(); |
+ if (ShouldStopIterating(xid)) { |
+ cache_[xid] = true; |
found_local_process_window = true; |
break; |
} |
+ cache_[xid] = false; |
} |
if (!found_local_process_window) |
return NULL; |
@@ -44,35 +51,15 @@ XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) { |
} |
bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) { |
- if (!ui::IsWindowVisible(xid)) |
- return false; |
- |
- aura::Window* window = |
- views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); |
- if (window) { |
- if (ShouldStopIteratingAtLocalProcessWindow(window)) { |
- toplevel_ = xid; |
- return true; |
- } |
- return false; |
- } |
+ std::map<XID, bool>::const_iterator it = cache_.find(xid); |
+ if (it != cache_.end()) |
+ return it->second; |
- if (ui::WindowContainsPoint(xid, screen_loc_)) { |
+ if (ui::IsWindowVisible(xid) && ui::WindowContainsPoint(xid, screen_loc_)) { |
toplevel_ = xid; |
return true; |
} |
return false; |
} |
-bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow( |
- aura::Window* window) { |
- if (ignore_.find(window) != ignore_.end()) |
- return false; |
- |
- // Currently |window|->IsVisible() always returns true. |
- // TODO(pkotwicz): Fix this. crbug.com/353038 |
- return window->IsVisible() && |
- window->GetBoundsInScreen().Contains(screen_loc_); |
-} |
- |
} // namespace views |