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 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
10 #import "ui/gfx/mac/coordinate_conversion.h" | 10 #import "ui/gfx/mac/coordinate_conversion.h" |
11 | 11 |
12 gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint( | 12 gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint( |
13 const gfx::Point& screen_point, | 13 const gfx::Point& screen_point, |
14 const std::set<gfx::NativeWindow>& ignore) { | 14 const std::set<gfx::NativeWindow>& ignore) { |
| 15 return GetLocalProcessWindowAtPointImpl(screen_point, ignore); |
| 16 } |
| 17 |
| 18 gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPointImpl( |
| 19 const gfx::Point& screen_point, |
| 20 const std::set<gfx::NativeWindow>& ignore) { |
15 const NSPoint ns_point = gfx::ScreenPointToNSPoint(screen_point); | 21 const NSPoint ns_point = gfx::ScreenPointToNSPoint(screen_point); |
16 | 22 |
17 // Note: [NSApp orderedWindows] doesn't include NSPanels. | 23 // Note: [NSApp orderedWindows] doesn't include NSPanels. |
18 for (NSWindow* window : [NSApp orderedWindows]) { | 24 for (NSWindow* window : [NSApp orderedWindows]) { |
19 if (ignore.count(window)) | 25 if (ignore.count(window)) |
20 continue; | 26 continue; |
21 | 27 |
22 if (![window isOnActiveSpace]) | 28 if (![window isOnActiveSpace]) |
23 continue; | 29 continue; |
24 | 30 |
25 // NativeWidgetMac::Close() calls -orderOut: on NSWindows before actually | 31 // NativeWidgetMac::Close() calls -orderOut: on NSWindows before actually |
26 // closing them. | 32 // closing them. |
27 if (![window isVisible]) | 33 if (![window isVisible]) |
28 continue; | 34 continue; |
29 | 35 |
30 if (NSPointInRect(ns_point, [window frame])) | 36 if (NSPointInRect(ns_point, [window frame])) |
31 return window; | 37 return window; |
32 } | 38 } |
33 | 39 |
34 return nil; | 40 return nil; |
35 } | 41 } |
OLD | NEW |