Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: ui/views/widget/desktop_aura/x11_topmost_window_finder.cc

Issue 264713007: Add unittests for X11TopmostWindowFinder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698