OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tabs/dock_info.h" | 5 #include "chrome/browser/ui/tabs/dock_info.h" |
6 | 6 |
7 #include "base/win/scoped_gdi_object.h" | 7 #include "base/win/scoped_gdi_object.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
11 #include "chrome/browser/ui/views/tabs/tab.h" | 11 #include "chrome/browser/ui/views/tabs/tab.h" |
| 12 #include "views/screen.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // BaseWindowFinder ----------------------------------------------------------- | 16 // BaseWindowFinder ----------------------------------------------------------- |
16 | 17 |
17 // Base class used to locate a window. This is intended to be used with the | 18 // Base class used to locate a window. This is intended to be used with the |
18 // various win32 functions that iterate over windows. | 19 // various win32 functions that iterate over windows. |
19 // | 20 // |
20 // A subclass need only override ShouldStopIterating to determine when | 21 // A subclass need only override ShouldStopIterating to determine when |
21 // iteration should stop. | 22 // iteration should stop. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return true; | 224 return true; |
224 } | 225 } |
225 return false; | 226 return false; |
226 } | 227 } |
227 | 228 |
228 private: | 229 private: |
229 DockToWindowFinder(const gfx::Point& screen_loc, | 230 DockToWindowFinder(const gfx::Point& screen_loc, |
230 const std::set<HWND>& ignore) | 231 const std::set<HWND>& ignore) |
231 : BaseWindowFinder(ignore), | 232 : BaseWindowFinder(ignore), |
232 screen_loc_(screen_loc) { | 233 screen_loc_(screen_loc) { |
233 HMONITOR monitor = MonitorFromPoint(screen_loc.ToPOINT(), | 234 gfx::Rect work_area = views::Screen::GetMonitorWorkAreaNearestPoint( |
234 MONITOR_DEFAULTTONULL); | 235 screen_loc); |
235 MONITORINFO monitor_info = {0}; | 236 if (!work_area.IsEmpty()) { |
236 monitor_info.cbSize = sizeof(MONITORINFO); | 237 result_.set_monitor_bounds(work_area); |
237 if (monitor && GetMonitorInfo(monitor, &monitor_info)) { | |
238 result_.set_monitor_bounds(gfx::Rect(monitor_info.rcWork)); | |
239 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, | 238 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, |
240 reinterpret_cast<LPARAM>(this)); | 239 reinterpret_cast<LPARAM>(this)); |
241 } | 240 } |
242 } | 241 } |
243 | 242 |
244 bool CheckPoint(HWND hwnd, int x, int y, DockInfo::Type type) { | 243 bool CheckPoint(HWND hwnd, int x, int y, DockInfo::Type type) { |
245 bool in_enable_area; | 244 bool in_enable_area; |
246 if (DockInfo::IsCloseToPoint(screen_loc_, x, y, &in_enable_area)) { | 245 if (DockInfo::IsCloseToPoint(screen_loc_, x, y, &in_enable_area)) { |
247 result_.set_in_enable_area(in_enable_area); | 246 result_.set_in_enable_area(in_enable_area); |
248 result_.set_window(hwnd); | 247 result_.set_window(hwnd); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 315 |
317 void DockInfo::SizeOtherWindowTo(const gfx::Rect& bounds) const { | 316 void DockInfo::SizeOtherWindowTo(const gfx::Rect& bounds) const { |
318 if (IsZoomed(window())) { | 317 if (IsZoomed(window())) { |
319 // We're docking relative to another window, we need to make sure the | 318 // We're docking relative to another window, we need to make sure the |
320 // window we're docking to isn't maximized. | 319 // window we're docking to isn't maximized. |
321 ShowWindow(window(), SW_RESTORE | SW_SHOWNA); | 320 ShowWindow(window(), SW_RESTORE | SW_SHOWNA); |
322 } | 321 } |
323 SetWindowPos(window(), HWND_TOP, bounds.x(), bounds.y(), bounds.width(), | 322 SetWindowPos(window(), HWND_TOP, bounds.x(), bounds.y(), bounds.width(), |
324 bounds.height(), SWP_NOACTIVATE | SWP_NOOWNERZORDER); | 323 bounds.height(), SWP_NOACTIVATE | SWP_NOOWNERZORDER); |
325 } | 324 } |
OLD | NEW |