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 "views/widget/monitor_win.h" | 5 #include "views/widget/monitor_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <shellapi.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
11 | 11 |
12 namespace views { | 12 namespace views { |
13 | 13 |
14 gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect) { | 14 gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect) { |
15 RECT p_rect = rect.ToRECT(); | 15 RECT p_rect = rect.ToRECT(); |
16 HMONITOR monitor = MonitorFromRect(&p_rect, MONITOR_DEFAULTTONEAREST); | 16 HMONITOR monitor = MonitorFromRect(&p_rect, MONITOR_DEFAULTTONEAREST); |
17 if (monitor) { | 17 if (monitor) { |
18 MONITORINFO mi = {0}; | 18 MONITORINFO mi = {0}; |
19 mi.cbSize = sizeof(mi); | 19 mi.cbSize = sizeof(mi); |
20 GetMonitorInfo(monitor, &mi); | 20 GetMonitorInfo(monitor, &mi); |
21 return gfx::Rect(mi.rcWork); | 21 return gfx::Rect(mi.rcWork); |
22 } | 22 } |
23 NOTREACHED(); | 23 NOTREACHED(); |
24 return gfx::Rect(); | 24 return gfx::Rect(); |
25 } | 25 } |
26 | 26 |
27 HWND GetTopmostAutoHideTaskbarForEdge(UINT edge, HMONITOR monitor) { | |
28 if (monitor == NULL) | |
Peter Kasting
2011/08/30 18:31:32
Nit: I'd roll this into the conditional below like
jianli
2011/08/30 18:38:55
Done.
| |
29 return NULL; | |
30 APPBARDATA taskbar_data = { 0 }; | |
Peter Kasting
2011/08/30 18:31:32
Nit: Shorter:
APPBARDATA taskbar_data = { sizeof
jianli
2011/08/30 18:38:55
Done.
| |
31 taskbar_data.cbSize = sizeof APPBARDATA; | |
32 taskbar_data.uEdge = edge; | |
33 HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR, | |
34 &taskbar_data)); | |
35 if (::IsWindow(taskbar) && | |
Peter Kasting
2011/08/30 18:31:32
Nit: Shorter:
return (...) ?
taskbar : NULL;
jianli
2011/08/30 18:38:55
Done.
| |
36 (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) && | |
37 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST)) | |
38 return taskbar; | |
39 return NULL; | |
40 } | |
41 | |
27 } // namespace views | 42 } // namespace views |
OLD | NEW |