| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/tabs/window_finder.h" | 5 #include "chrome/browser/ui/views/tabs/window_finder.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "chrome/browser/ui/host_desktop.h" | 8 #include "chrome/browser/ui/host_desktop.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_tree_host.h" |
| 11 #include "ui/base/x/x11_util.h" | 11 #include "ui/base/x/x11_util.h" |
| 12 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 12 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 13 | 13 |
| 14 #if defined(USE_ASH) | 14 #if defined(USE_ASH) |
| 15 aura::Window* GetLocalProcessWindowAtPointAsh( | 15 aura::Window* GetLocalProcessWindowAtPointAsh( |
| 16 const gfx::Point& screen_point, | 16 const gfx::Point& screen_point, |
| 17 const std::set<aura::Window*>& ignore); | 17 const std::set<aura::Window*>& ignore); |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 23 // BaseWindowFinder | 23 // BaseWindowFinder |
| 24 // | 24 // |
| 25 // Base class used to locate a window. A subclass need only override | 25 // Base class used to locate a window. A subclass need only override |
| 26 // ShouldStopIterating to determine when iteration should stop. | 26 // ShouldStopIterating to determine when iteration should stop. |
| 27 class BaseWindowFinder : public ui::EnumerateWindowsDelegate { | 27 class BaseWindowFinder : public ui::EnumerateWindowsDelegate { |
| 28 public: | 28 public: |
| 29 explicit BaseWindowFinder(const std::set<aura::Window*>& ignore) { | 29 explicit BaseWindowFinder(const std::set<aura::Window*>& ignore) { |
| 30 std::set<aura::Window*>::iterator iter; | 30 std::set<aura::Window*>::iterator iter; |
| 31 for (iter = ignore.begin(); iter != ignore.end(); iter++) { | 31 for (iter = ignore.begin(); iter != ignore.end(); iter++) { |
| 32 XID xid = (*iter)->GetDispatcher()->host()->GetAcceleratedWidget(); | 32 XID xid = (*iter)->GetHost()->GetAcceleratedWidget(); |
| 33 ignore_.insert(xid); | 33 ignore_.insert(xid); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual ~BaseWindowFinder() {} | 37 virtual ~BaseWindowFinder() {} |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 // Returns true if |window| is in the ignore list. | 40 // Returns true if |window| is in the ignore list. |
| 41 bool ShouldIgnoreWindow(XID window) { | 41 bool ShouldIgnoreWindow(XID window) { |
| 42 return (ignore_.find(window) != ignore_.end()); | 42 return (ignore_.find(window) != ignore_.end()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 return 0; | 136 return 0; |
| 137 } | 137 } |
| 138 | 138 |
| 139 protected: | 139 protected: |
| 140 virtual bool ShouldStopIterating(XID window) OVERRIDE { | 140 virtual bool ShouldStopIterating(XID window) OVERRIDE { |
| 141 if (BaseWindowFinder::ShouldIgnoreWindow(window)) | 141 if (BaseWindowFinder::ShouldIgnoreWindow(window)) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 // Check if this window is in our process. | 144 // Check if this window is in our process. |
| 145 if (!aura::WindowEventDispatcher::GetForAcceleratedWidget(window)) | 145 if (!aura::WindowTreeHost::GetForAcceleratedWidget(window)) |
| 146 return false; | 146 return false; |
| 147 | 147 |
| 148 if (!ui::IsWindowVisible(window)) | 148 if (!ui::IsWindowVisible(window)) |
| 149 return false; | 149 return false; |
| 150 | 150 |
| 151 if (ui::WindowContainsPoint(window, screen_loc_)) { | 151 if (ui::WindowContainsPoint(window, screen_loc_)) { |
| 152 result_ = window; | 152 result_ = window; |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 184 #if defined(USE_ASH) | 184 #if defined(USE_ASH) |
| 185 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) | 185 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) |
| 186 return GetLocalProcessWindowAtPointAsh(screen_point, ignore); | 186 return GetLocalProcessWindowAtPointAsh(screen_point, ignore); |
| 187 #endif | 187 #endif |
| 188 // The X11 server is the canonical state of what the window stacking order | 188 // The X11 server is the canonical state of what the window stacking order |
| 189 // is. | 189 // is. |
| 190 XID xid = | 190 XID xid = |
| 191 LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore); | 191 LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore); |
| 192 return views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); | 192 return views::DesktopWindowTreeHostX11::GetContentWindowForXID(xid); |
| 193 } | 193 } |
| OLD | NEW |