OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "ui/views/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/system_monitor/system_monitor.h" | 11 #include "base/power_monitor/power_monitor.h" |
12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
14 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 14 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
15 #include "ui/base/native_theme/native_theme_win.h" | 15 #include "ui/base/native_theme/native_theme_win.h" |
16 #include "ui/base/win/hwnd_util.h" | 16 #include "ui/base/win/hwnd_util.h" |
17 #include "ui/base/win/mouse_wheel_util.h" | 17 #include "ui/base/win/mouse_wheel_util.h" |
18 #include "ui/base/win/shell.h" | 18 #include "ui/base/win/shell.h" |
19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/canvas_paint.h" | 20 #include "ui/gfx/canvas_paint.h" |
21 #include "ui/gfx/canvas_skia_paint.h" | 21 #include "ui/gfx/canvas_skia_paint.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
33 #include "ui/views/win/scoped_fullscreen_visibility.h" | 33 #include "ui/views/win/scoped_fullscreen_visibility.h" |
34 | 34 |
35 #if !defined(USE_AURA) | 35 #if !defined(USE_AURA) |
36 #include "ui/views/accessibility/native_view_accessibility_win.h" | 36 #include "ui/views/accessibility/native_view_accessibility_win.h" |
37 #include "ui/views/widget/child_window_message_processor.h" | 37 #include "ui/views/widget/child_window_message_processor.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace views { | 40 namespace views { |
41 namespace { | 41 namespace { |
42 | 42 |
43 // Reference the Notifier defined in the global PowerMonitor instance. | |
44 base::PowerMonitor::Notifier* g_power_notifier = NULL; | |
vandebo (ex-Chrome)
2012/10/23 01:27:57
Set this in the constructor and assert that we get
| |
45 | |
43 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a | 46 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a |
44 // move. win32 doesn't appear to offer a way to determine the result of a move, | 47 // move. win32 doesn't appear to offer a way to determine the result of a move, |
45 // so we install hooks to determine if we got a mouse up and assume the move | 48 // so we install hooks to determine if we got a mouse up and assume the move |
46 // completed. | 49 // completed. |
47 class MoveLoopMouseWatcher { | 50 class MoveLoopMouseWatcher { |
48 public: | 51 public: |
49 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); | 52 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); |
50 ~MoveLoopMouseWatcher(); | 53 ~MoveLoopMouseWatcher(); |
51 | 54 |
52 // Returns true if the mouse is up, or if we couldn't install the hook. | 55 // Returns true if the mouse is up, or if we couldn't install the hook. |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 #endif | 1848 #endif |
1846 } | 1849 } |
1847 } else { | 1850 } else { |
1848 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. | 1851 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. |
1849 // Some scenarios otherwise fail to validate minimized app/popup windows. | 1852 // Some scenarios otherwise fail to validate minimized app/popup windows. |
1850 ValidateRect(hwnd(), NULL); | 1853 ValidateRect(hwnd(), NULL); |
1851 } | 1854 } |
1852 } | 1855 } |
1853 | 1856 |
1854 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { | 1857 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { |
1855 base::SystemMonitor* monitor = base::SystemMonitor::Get(); | 1858 if (g_power_notifier == NULL) |
1856 if (monitor) | 1859 g_power_notifier = base::PowerMonitor::GetInstance()->GetNotifierOnce(); |
1857 monitor->ProcessWmPowerBroadcastMessage(power_event); | 1860 if (g_power_notifier) |
1861 g_power_notifier->ProcessWmPowerBroadcastMessage(power_event); | |
1862 | |
1858 SetMsgHandled(FALSE); | 1863 SetMsgHandled(FALSE); |
1859 return 0; | 1864 return 0; |
1860 } | 1865 } |
1861 | 1866 |
1862 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, | 1867 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, |
1863 WPARAM w_param, | 1868 WPARAM w_param, |
1864 LPARAM l_param) { | 1869 LPARAM l_param) { |
1865 SetMsgHandled(FALSE); | 1870 SetMsgHandled(FALSE); |
1866 return 0; | 1871 return 0; |
1867 } | 1872 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2079 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2084 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2080 } | 2085 } |
2081 if (window_pos->flags & SWP_SHOWWINDOW) | 2086 if (window_pos->flags & SWP_SHOWWINDOW) |
2082 delegate_->HandleVisibilityChanged(true); | 2087 delegate_->HandleVisibilityChanged(true); |
2083 else if (window_pos->flags & SWP_HIDEWINDOW) | 2088 else if (window_pos->flags & SWP_HIDEWINDOW) |
2084 delegate_->HandleVisibilityChanged(false); | 2089 delegate_->HandleVisibilityChanged(false); |
2085 SetMsgHandled(FALSE); | 2090 SetMsgHandled(FALSE); |
2086 } | 2091 } |
2087 | 2092 |
2088 } // namespace views | 2093 } // namespace views |
OLD | NEW |