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_state_manager.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 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1844 } | 1844 } |
1845 } else { | 1845 } else { |
1846 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. | 1846 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. |
1847 // Some scenarios otherwise fail to validate minimized app/popup windows. | 1847 // Some scenarios otherwise fail to validate minimized app/popup windows. |
1848 ValidateRect(hwnd(), NULL); | 1848 ValidateRect(hwnd(), NULL); |
1849 } | 1849 } |
1850 #endif | 1850 #endif |
1851 } | 1851 } |
1852 | 1852 |
1853 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { | 1853 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { |
1854 base::SystemMonitor* monitor = base::SystemMonitor::Get(); | 1854 base::PowerStateManager* manager = base::PowerStateManager::Get(); |
vandebo (ex-Chrome)
2012/09/21 20:12:18
It's unclear exactly how we want to handle this pa
| |
1855 if (monitor) | 1855 if (monitor) { |
1856 monitor->ProcessWmPowerBroadcastMessage(power_event); | 1856 base::PowerStateManager::PowerEvent power_event; |
1857 switch (event_id) { | |
1858 case PBT_APMPOWERSTATUSCHANGE: // The power status changed. | |
1859 power_event = POWER_STATE_EVENT; | |
1860 break; | |
1861 case PBT_APMRESUMEAUTOMATIC: // Resume from suspend. | |
1862 //case PBT_APMRESUMESUSPEND: // User-initiated resume from suspend. | |
1863 // We don't notify for this latter event | |
1864 // because if it occurs it is always sent | |
1865 // as a second event after | |
1866 // PBT_APMRESUMEAUTOMATIC. | |
1867 power_event = RESUME_EVENT; | |
1868 break; | |
1869 case PBT_APMSUSPEND: // System has been suspended. | |
1870 power_event = SUSPEND_EVENT; | |
1871 break; | |
1872 default: | |
1873 return; | |
1874 | |
1875 // Other Power Events: | |
1876 // PBT_APMBATTERYLOW - removed in Vista. | |
1877 // PBT_APMOEMEVENT - removed in Vista. | |
1878 // PBT_APMQUERYSUSPEND - removed in Vista. | |
1879 // PBT_APMQUERYSUSPENDFAILED - removed in Vista. | |
1880 // PBT_APMRESUMECRITICAL - removed in Vista. | |
1881 // PBT_POWERSETTINGCHANGE - user changed the power settings. | |
1882 } | |
1883 manager->HandlePowerEvent(power_event); | |
1884 } | |
1857 SetMsgHandled(FALSE); | 1885 SetMsgHandled(FALSE); |
1858 return 0; | 1886 return 0; |
1859 } | 1887 } |
1860 | 1888 |
1861 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, | 1889 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, |
1862 WPARAM w_param, | 1890 WPARAM w_param, |
1863 LPARAM l_param) { | 1891 LPARAM l_param) { |
1864 SetMsgHandled(FALSE); | 1892 SetMsgHandled(FALSE); |
1865 return 0; | 1893 return 0; |
1866 } | 1894 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2091 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2119 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2092 } | 2120 } |
2093 if (window_pos->flags & SWP_SHOWWINDOW) | 2121 if (window_pos->flags & SWP_SHOWWINDOW) |
2094 delegate_->HandleVisibilityChanged(true); | 2122 delegate_->HandleVisibilityChanged(true); |
2095 else if (window_pos->flags & SWP_HIDEWINDOW) | 2123 else if (window_pos->flags & SWP_HIDEWINDOW) |
2096 delegate_->HandleVisibilityChanged(false); | 2124 delegate_->HandleVisibilityChanged(false); |
2097 SetMsgHandled(FALSE); | 2125 SetMsgHandled(FALSE); |
2098 } | 2126 } |
2099 | 2127 |
2100 } // namespace views | 2128 } // namespace views |
OLD | NEW |