Correct blacklist entry message
[chromium-blink-merge.git] / ui / views / widget / monitor_win.cc
blob1292692d9f35d8c68184b5d0d4e978f51b0c6ee8
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/widget/monitor_win.h"
7 #include <shellapi.h>
9 #include "base/logging.h"
10 #include "base/win/win_util.h"
11 #include "ui/gfx/rect.h"
13 namespace views {
15 gfx::Rect GetMonitorBoundsForRect(const gfx::Rect& rect) {
16 RECT p_rect = rect.ToRECT();
17 HMONITOR monitor = MonitorFromRect(&p_rect, MONITOR_DEFAULTTONEAREST);
18 if (monitor) {
19 MONITORINFO mi = {0};
20 mi.cbSize = sizeof(mi);
21 base::win::GetMonitorInfoWrapper(monitor, &mi);
22 return gfx::Rect(mi.rcWork);
24 NOTREACHED();
25 return gfx::Rect();
28 HWND GetTopmostAutoHideTaskbarForEdge(UINT edge, HMONITOR monitor) {
29 // NOTE: this may be invoked on a background thread.
30 APPBARDATA taskbar_data = { sizeof(APPBARDATA), NULL, 0, edge };
31 HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR,
32 &taskbar_data));
33 return (::IsWindow(taskbar) && (monitor != NULL) &&
34 (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) &&
35 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST)) ?
36 taskbar : NULL;
39 } // namespace views