| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/dock_info.h" | 5 #include "chrome/browser/dock_info.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return finder.is_top_most_; | 152 return finder.is_top_most_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual bool ShouldStopIterating(HWND hwnd) { | 155 virtual bool ShouldStopIterating(HWND hwnd) { |
| 156 if (hwnd == target_) { | 156 if (hwnd == target_) { |
| 157 // Window is topmost, stop iterating. | 157 // Window is topmost, stop iterating. |
| 158 is_top_most_ = true; | 158 is_top_most_ = true; |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (::IsWindowVisible(hwnd)) { | 162 if (!::IsWindowVisible(hwnd)) { |
| 163 CRect r; | 163 // The window isn't visible, keep iterating. |
| 164 if (::GetWindowRect(hwnd, &r) && r.PtInRect(screen_loc_.ToPOINT())) { | 164 return false; |
| 165 // Not the topmost, stop iterating. | |
| 166 return true; | |
| 167 } | |
| 168 } | 165 } |
| 169 return false; | 166 |
| 167 CRect r; |
| 168 if (!::GetWindowRect(hwnd, &r) || !r.PtInRect(screen_loc_.ToPOINT())) { |
| 169 // The window doesn't contain the point, keep iterating. |
| 170 return false; |
| 171 } |
| 172 |
| 173 // hwnd is at the point. Make sure the point is within the windows region. |
| 174 if (GetWindowRgn(hwnd, tmp_region_.Get()) == ERROR) { |
| 175 // There's no region on the window and the window contains the point. Stop |
| 176 // iterating. |
| 177 return true; |
| 178 } |
| 179 |
| 180 // The region is relative to the window's rect. |
| 181 BOOL is_point_in_region = PtInRegion(tmp_region_.Get(), |
| 182 screen_loc_.x() - r.left, screen_loc_.y() - r.top); |
| 183 tmp_region_ = CreateRectRgn(0, 0, 0, 0); |
| 184 // Stop iterating if the region contains the point. |
| 185 return !!is_point_in_region; |
| 170 } | 186 } |
| 171 | 187 |
| 172 private: | 188 private: |
| 173 TopMostFinder(HWND window, | 189 TopMostFinder(HWND window, |
| 174 const gfx::Point& screen_loc, | 190 const gfx::Point& screen_loc, |
| 175 const std::set<HWND>& ignore) | 191 const std::set<HWND>& ignore) |
| 176 : BaseWindowFinder(ignore), | 192 : BaseWindowFinder(ignore), |
| 177 target_(window), | 193 target_(window), |
| 178 screen_loc_(screen_loc), | 194 screen_loc_(screen_loc), |
| 179 is_top_most_(false) { | 195 is_top_most_(false), |
| 196 tmp_region_(CreateRectRgn(0, 0, 0, 0)) { |
| 180 EnumWindows(WindowCallbackProc, reinterpret_cast<LPARAM>(this)); | 197 EnumWindows(WindowCallbackProc, reinterpret_cast<LPARAM>(this)); |
| 181 } | 198 } |
| 182 | 199 |
| 183 // The window we're looking for. | 200 // The window we're looking for. |
| 184 HWND target_; | 201 HWND target_; |
| 185 | 202 |
| 186 // Location of window to find. | 203 // Location of window to find. |
| 187 gfx::Point screen_loc_; | 204 gfx::Point screen_loc_; |
| 188 | 205 |
| 189 // Is target_ the top most window? This is initially false but set to true | 206 // Is target_ the top most window? This is initially false but set to true |
| 190 // in ShouldStopIterating if target_ is passed in. | 207 // in ShouldStopIterating if target_ is passed in. |
| 191 bool is_top_most_; | 208 bool is_top_most_; |
| 192 | 209 |
| 210 ScopedHRGN tmp_region_; |
| 211 |
| 193 DISALLOW_COPY_AND_ASSIGN(TopMostFinder); | 212 DISALLOW_COPY_AND_ASSIGN(TopMostFinder); |
| 194 }; | 213 }; |
| 195 | 214 |
| 196 // WindowFinder --------------------------------------------------------------- | 215 // WindowFinder --------------------------------------------------------------- |
| 197 | 216 |
| 198 // Helper class to determine if a particular point contains a window from our | 217 // Helper class to determine if a particular point contains a window from our |
| 199 // process. | 218 // process. |
| 200 class LocalProcessWindowFinder : public BaseWindowFinder { | 219 class LocalProcessWindowFinder : public BaseWindowFinder { |
| 201 public: | 220 public: |
| 202 // Returns the hwnd from our process at screen_loc that is not obscured by | 221 // Returns the hwnd from our process at screen_loc that is not obscured by |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 Type type) { | 516 Type type) { |
| 498 if (IsCloseToMonitorPoint(screen_loc, x, y, type, &in_enable_area_) && | 517 if (IsCloseToMonitorPoint(screen_loc, x, y, type, &in_enable_area_) && |
| 499 (type != MAXIMIZE || | 518 (type != MAXIMIZE || |
| 500 !IsMaximizedTabbedBrowserOnMonitor(monitor))) { | 519 !IsMaximizedTabbedBrowserOnMonitor(monitor))) { |
| 501 hot_spot_.SetPoint(x, y); | 520 hot_spot_.SetPoint(x, y); |
| 502 type_ = type; | 521 type_ = type; |
| 503 return true; | 522 return true; |
| 504 } | 523 } |
| 505 return false; | 524 return false; |
| 506 } | 525 } |
| OLD | NEW |