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/native_widget_win.h" | 5 #include "views/widget/native_widget_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "views/accessibility/native_view_accessibility_win.h" | 32 #include "views/accessibility/native_view_accessibility_win.h" |
33 #include "views/controls/native_control_win.h" | 33 #include "views/controls/native_control_win.h" |
34 #include "views/controls/textfield/native_textfield_views.h" | 34 #include "views/controls/textfield/native_textfield_views.h" |
35 #include "views/focus/accelerator_handler.h" | 35 #include "views/focus/accelerator_handler.h" |
36 #include "views/focus/view_storage.h" | 36 #include "views/focus/view_storage.h" |
37 #include "views/ime/input_method_win.h" | 37 #include "views/ime/input_method_win.h" |
38 #include "views/views_delegate.h" | 38 #include "views/views_delegate.h" |
39 #include "views/widget/aero_tooltip_manager.h" | 39 #include "views/widget/aero_tooltip_manager.h" |
40 #include "views/widget/child_window_message_processor.h" | 40 #include "views/widget/child_window_message_processor.h" |
41 #include "views/widget/drop_target_win.h" | 41 #include "views/widget/drop_target_win.h" |
| 42 #include "views/widget/monitor_win.h" |
42 #include "views/widget/native_widget_delegate.h" | 43 #include "views/widget/native_widget_delegate.h" |
43 #include "views/widget/native_widget_views.h" | 44 #include "views/widget/native_widget_views.h" |
44 #include "views/widget/root_view.h" | 45 #include "views/widget/root_view.h" |
45 #include "views/widget/widget_delegate.h" | 46 #include "views/widget/widget_delegate.h" |
46 #include "views/window/native_frame_view.h" | 47 #include "views/window/native_frame_view.h" |
47 | 48 |
48 #pragma comment(lib, "dwmapi.lib") | 49 #pragma comment(lib, "dwmapi.lib") |
49 | 50 |
50 using ui::ViewProp; | 51 using ui::ViewProp; |
51 | 52 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if (!*monitor) | 279 if (!*monitor) |
279 return false; | 280 return false; |
280 MONITORINFO monitor_info = { 0 }; | 281 MONITORINFO monitor_info = { 0 }; |
281 monitor_info.cbSize = sizeof(monitor_info); | 282 monitor_info.cbSize = sizeof(monitor_info); |
282 GetMonitorInfo(*monitor, &monitor_info); | 283 GetMonitorInfo(*monitor, &monitor_info); |
283 *monitor_rect = monitor_info.rcMonitor; | 284 *monitor_rect = monitor_info.rcMonitor; |
284 *work_area = monitor_info.rcWork; | 285 *work_area = monitor_info.rcWork; |
285 return true; | 286 return true; |
286 } | 287 } |
287 | 288 |
288 // Returns true if edge |edge| (one of ABE_LEFT, TOP, RIGHT, or BOTTOM) of | |
289 // monitor |monitor| has an auto-hiding taskbar that's always-on-top. | |
290 bool EdgeHasTopmostAutoHideTaskbar(UINT edge, HMONITOR monitor) { | |
291 APPBARDATA taskbar_data = { 0 }; | |
292 taskbar_data.cbSize = sizeof APPBARDATA; | |
293 taskbar_data.uEdge = edge; | |
294 HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR, | |
295 &taskbar_data)); | |
296 return ::IsWindow(taskbar) && (monitor != NULL) && | |
297 (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONULL) == monitor) && | |
298 (GetWindowLong(taskbar, GWL_EXSTYLE) & WS_EX_TOPMOST); | |
299 } | |
300 | |
301 // Links the HWND to its NativeWidget. | 289 // Links the HWND to its NativeWidget. |
302 const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__"; | 290 const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__"; |
303 | 291 |
304 // A custom MSAA object id used to determine if a screen reader is actively | 292 // A custom MSAA object id used to determine if a screen reader is actively |
305 // listening for MSAA events. | 293 // listening for MSAA events. |
306 const int kCustomObjectID = 1; | 294 const int kCustomObjectID = 1; |
307 | 295 |
308 // If the hung renderer warning doesn't fit on screen, the amount of padding to | 296 // If the hung renderer warning doesn't fit on screen, the amount of padding to |
309 // be left between the edge of the window and the edge of the nearest monitor, | 297 // be left between the edge of the window and the edge of the nearest monitor, |
310 // after the window is nudged back on screen. Pixels. | 298 // after the window is nudged back on screen. Pixels. |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 // the window rect given with WM_NCCALCSIZE (which is our previous | 1620 // the window rect given with WM_NCCALCSIZE (which is our previous |
1633 // restored window position) we will get the correct monitor handle. | 1621 // restored window position) we will get the correct monitor handle. |
1634 monitor = MonitorFromRect(client_rect, MONITOR_DEFAULTTONULL); | 1622 monitor = MonitorFromRect(client_rect, MONITOR_DEFAULTTONULL); |
1635 if (!monitor) { | 1623 if (!monitor) { |
1636 // This is probably an extreme case that we won't hit, but if we don't | 1624 // This is probably an extreme case that we won't hit, but if we don't |
1637 // intersect any monitor, let us not adjust the client rect since our | 1625 // intersect any monitor, let us not adjust the client rect since our |
1638 // window will not be visible anyway. | 1626 // window will not be visible anyway. |
1639 return 0; | 1627 return 0; |
1640 } | 1628 } |
1641 } | 1629 } |
1642 if (EdgeHasTopmostAutoHideTaskbar(ABE_LEFT, monitor)) | 1630 if (GetTopmostAutoHideTaskbarForEdge(ABE_LEFT, monitor)) |
1643 client_rect->left += kAutoHideTaskbarThicknessPx; | 1631 client_rect->left += kAutoHideTaskbarThicknessPx; |
1644 if (EdgeHasTopmostAutoHideTaskbar(ABE_TOP, monitor)) { | 1632 if (GetTopmostAutoHideTaskbarForEdge(ABE_TOP, monitor)) { |
1645 if (GetWidget()->ShouldUseNativeFrame()) { | 1633 if (GetWidget()->ShouldUseNativeFrame()) { |
1646 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of | 1634 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of |
1647 // WM_NCHITTEST, having any nonclient area atop the window causes the | 1635 // WM_NCHITTEST, having any nonclient area atop the window causes the |
1648 // caption buttons to draw onscreen but not respond to mouse | 1636 // caption buttons to draw onscreen but not respond to mouse |
1649 // hover/clicks. | 1637 // hover/clicks. |
1650 // So for a taskbar at the screen top, we can't push the | 1638 // So for a taskbar at the screen top, we can't push the |
1651 // client_rect->top down; instead, we move the bottom up by one pixel, | 1639 // client_rect->top down; instead, we move the bottom up by one pixel, |
1652 // which is the smallest change we can make and still get a client area | 1640 // which is the smallest change we can make and still get a client area |
1653 // less than the screen size. This is visibly ugly, but there seems to | 1641 // less than the screen size. This is visibly ugly, but there seems to |
1654 // be no better solution. | 1642 // be no better solution. |
1655 --client_rect->bottom; | 1643 --client_rect->bottom; |
1656 } else { | 1644 } else { |
1657 client_rect->top += kAutoHideTaskbarThicknessPx; | 1645 client_rect->top += kAutoHideTaskbarThicknessPx; |
1658 } | 1646 } |
1659 } | 1647 } |
1660 if (EdgeHasTopmostAutoHideTaskbar(ABE_RIGHT, monitor)) | 1648 if (GetTopmostAutoHideTaskbarForEdge(ABE_RIGHT, monitor)) |
1661 client_rect->right -= kAutoHideTaskbarThicknessPx; | 1649 client_rect->right -= kAutoHideTaskbarThicknessPx; |
1662 if (EdgeHasTopmostAutoHideTaskbar(ABE_BOTTOM, monitor)) | 1650 if (GetTopmostAutoHideTaskbarForEdge(ABE_BOTTOM, monitor)) |
1663 client_rect->bottom -= kAutoHideTaskbarThicknessPx; | 1651 client_rect->bottom -= kAutoHideTaskbarThicknessPx; |
1664 | 1652 |
1665 // We cannot return WVR_REDRAW when there is nonclient area, or Windows | 1653 // We cannot return WVR_REDRAW when there is nonclient area, or Windows |
1666 // exhibits bugs where client pixels and child HWNDs are mispositioned by | 1654 // exhibits bugs where client pixels and child HWNDs are mispositioned by |
1667 // the width/height of the upper-left nonclient area. | 1655 // the width/height of the upper-left nonclient area. |
1668 return 0; | 1656 return 0; |
1669 } | 1657 } |
1670 | 1658 |
1671 // If the window bounds change, we're going to relayout and repaint anyway. | 1659 // If the window bounds change, we're going to relayout and repaint anyway. |
1672 // Returning WVR_REDRAW avoids an extra paint before that of the old client | 1660 // Returning WVR_REDRAW avoids an extra paint before that of the old client |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 return (GetKeyState(VK_LBUTTON) & 0x80) || | 2521 return (GetKeyState(VK_LBUTTON) & 0x80) || |
2534 (GetKeyState(VK_RBUTTON) & 0x80) || | 2522 (GetKeyState(VK_RBUTTON) & 0x80) || |
2535 (GetKeyState(VK_MBUTTON) & 0x80) || | 2523 (GetKeyState(VK_MBUTTON) & 0x80) || |
2536 (GetKeyState(VK_XBUTTON1) & 0x80) || | 2524 (GetKeyState(VK_XBUTTON1) & 0x80) || |
2537 (GetKeyState(VK_XBUTTON2) & 0x80); | 2525 (GetKeyState(VK_XBUTTON2) & 0x80); |
2538 } | 2526 } |
2539 | 2527 |
2540 } // namespace internal | 2528 } // namespace internal |
2541 | 2529 |
2542 } // namespace views | 2530 } // namespace views |
OLD | NEW |