Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" | |
| 6 | |
| 7 #include "ui/aura/window.h" | |
| 8 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | |
| 9 | |
| 10 namespace views { | |
| 11 | |
| 12 X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(None) { | |
| 13 } | |
| 14 | |
| 15 X11TopmostWindowFinder::~X11TopmostWindowFinder() { | |
| 16 } | |
| 17 | |
| 18 aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt( | |
| 19 const gfx::Point& screen_loc, | |
| 20 const std::set<aura::Window*>& ignore) { | |
| 21 screen_loc_ = screen_loc; | |
| 22 ignore_ = ignore; | |
| 23 | |
| 24 std::vector<aura::Window*> local_process_windows = | |
| 25 DesktopWindowTreeHostX11::GetAllOpenWindows(); | |
| 26 bool found_local_process_window = false; | |
| 27 for (size_t i = 0; i < local_process_windows.size(); ++i) { | |
| 28 if (ShouldStopIteratingAtLocalProcessWindow(local_process_windows[i])) { | |
| 29 found_local_process_window = true; | |
| 30 break; | |
| 31 } | |
| 32 } | |
| 33 if (!found_local_process_window) | |
| 34 return NULL; | |
| 35 | |
| 36 ui::EnumerateTopLevelWindows(this); | |
| 37 return views::DesktopWindowTreeHostX11::GetContentWindowForXID(toplevel_); | |
| 38 } | |
| 39 | |
| 40 XID X11TopmostWindowFinder::FindWindowAt(const gfx::Point& screen_loc) { | |
| 41 screen_loc_ = screen_loc; | |
| 42 ui::EnumerateTopLevelWindows(this); | |
| 43 return toplevel_; | |
| 44 } | |
| 45 | |
| 46 bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) { | |
| 47 if (!ui::IsWindowVisible(xid)) | |
| 48 return false; | |
| 49 | |
| 50 aura::Window* window = | |
| 51 views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); | |
| 52 if (window) { | |
| 53 if (ShouldStopIteratingAtLocalProcessWindow(window)) { | |
| 54 toplevel_ = xid; | |
| 55 return true; | |
| 56 } | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 if (ui::WindowContainsPoint(xid, screen_loc_)) { | |
| 61 toplevel_ = xid; | |
| 62 return true; | |
| 63 } | |
| 64 return false; | |
| 65 } | |
| 66 | |
| 67 bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow( | |
| 68 aura::Window* window) { | |
| 69 if (ignore_.find(window) != ignore_.end()) | |
| 70 return false; | |
| 71 | |
| 72 // Currently |window|->IsVisible() always returns true. | |
| 73 // TODO(pkotwicz): Fix this. crbug.com/353038 | |
| 74 return window->IsVisible() && | |
| 75 window->GetBoundsInScreen().Contains(screen_loc_); | |
|
pkotwicz
2014/04/29 02:27:46
For an upcoming CL:
Checking the bounds is wrong.
| |
| 76 } | |
| 77 | |
| 78 } // namespace views | |
| OLD | NEW |