| 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_skia_paint.h" | 20 #include "ui/gfx/canvas_skia_paint.h" |
| 21 #include "ui/gfx/icon_util.h" | 21 #include "ui/gfx/icon_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 #include "ui/views/win/scoped_fullscreen_visibility.h" | 32 #include "ui/views/win/scoped_fullscreen_visibility.h" |
| 33 | 33 |
| 34 #if !defined(USE_AURA) | 34 #if !defined(USE_AURA) |
| 35 #include "ui/views/accessibility/native_view_accessibility_win.h" | 35 #include "ui/views/accessibility/native_view_accessibility_win.h" |
| 36 #include "ui/views/widget/child_window_message_processor.h" | 36 #include "ui/views/widget/child_window_message_processor.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace views { | 39 namespace views { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 // Used to signal the power event when receiving Windows power broadcast |
| 43 // message. |
| 44 base::PowerMonitor::Signaler* g_power_signaler = NULL; |
| 45 |
| 42 // 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 |
| 43 // 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, |
| 44 // 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 |
| 45 // completed. | 49 // completed. |
| 46 class MoveLoopMouseWatcher { | 50 class MoveLoopMouseWatcher { |
| 47 public: | 51 public: |
| 48 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); | 52 explicit MoveLoopMouseWatcher(HWNDMessageHandler* host); |
| 49 ~MoveLoopMouseWatcher(); | 53 ~MoveLoopMouseWatcher(); |
| 50 | 54 |
| 51 // 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 is_right_mouse_pressed_on_caption_(false), | 381 is_right_mouse_pressed_on_caption_(false), |
| 378 lock_updates_count_(0), | 382 lock_updates_count_(0), |
| 379 destroyed_(NULL), | 383 destroyed_(NULL), |
| 380 ignore_window_pos_changes_(false), | 384 ignore_window_pos_changes_(false), |
| 381 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), | 385 ALLOW_THIS_IN_INITIALIZER_LIST(ignore_pos_changes_factory_(this)), |
| 382 last_monitor_(NULL), | 386 last_monitor_(NULL), |
| 383 use_layered_buffer_(false), | 387 use_layered_buffer_(false), |
| 384 layered_alpha_(255), | 388 layered_alpha_(255), |
| 385 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), | 389 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), |
| 386 can_update_layered_window_(true) { | 390 can_update_layered_window_(true) { |
| 391 if (g_power_signaler == NULL && base::PowerMonitor::Get()) |
| 392 g_power_signaler = base::PowerMonitor::Get()->GetSignalerOnce(); |
| 387 } | 393 } |
| 388 | 394 |
| 389 HWNDMessageHandler::~HWNDMessageHandler() { | 395 HWNDMessageHandler::~HWNDMessageHandler() { |
| 390 delegate_ = NULL; | 396 delegate_ = NULL; |
| 391 if (destroyed_ != NULL) | 397 if (destroyed_ != NULL) |
| 392 *destroyed_ = true; | 398 *destroyed_ = true; |
| 393 // Prevent calls back into this class via WNDPROC now that we've been | 399 // Prevent calls back into this class via WNDPROC now that we've been |
| 394 // destroyed. | 400 // destroyed. |
| 395 ClearUserData(); | 401 ClearUserData(); |
| 402 delete g_power_signaler; |
| 403 g_power_signaler = NULL; |
| 396 } | 404 } |
| 397 | 405 |
| 398 void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) { | 406 void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) { |
| 399 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, | 407 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, |
| 400 &last_work_area_); | 408 &last_work_area_); |
| 401 | 409 |
| 402 // Create the window. | 410 // Create the window. |
| 403 WindowImpl::Init(parent, bounds); | 411 WindowImpl::Init(parent, bounds); |
| 404 } | 412 } |
| 405 | 413 |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 #endif | 1847 #endif |
| 1840 } | 1848 } |
| 1841 } else { | 1849 } else { |
| 1842 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. | 1850 // TODO(msw): Find a better solution for this crbug.com/93530 workaround. |
| 1843 // Some scenarios otherwise fail to validate minimized app/popup windows. | 1851 // Some scenarios otherwise fail to validate minimized app/popup windows. |
| 1844 ValidateRect(hwnd(), NULL); | 1852 ValidateRect(hwnd(), NULL); |
| 1845 } | 1853 } |
| 1846 } | 1854 } |
| 1847 | 1855 |
| 1848 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { | 1856 LRESULT HWNDMessageHandler::OnPowerBroadcast(DWORD power_event, DWORD data) { |
| 1849 base::SystemMonitor* monitor = base::SystemMonitor::Get(); | 1857 if (base::PowerMonitor::Get()) { |
| 1850 if (monitor) | 1858 CHECK(g_power_signaler); |
| 1851 monitor->ProcessWmPowerBroadcastMessage(power_event); | 1859 g_power_signaler->ProcessWmPowerBroadcastMessage(power_event); |
| 1860 } |
| 1861 |
| 1852 SetMsgHandled(FALSE); | 1862 SetMsgHandled(FALSE); |
| 1853 return 0; | 1863 return 0; |
| 1854 } | 1864 } |
| 1855 | 1865 |
| 1856 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, | 1866 LRESULT HWNDMessageHandler::OnReflectedMessage(UINT message, |
| 1857 WPARAM w_param, | 1867 WPARAM w_param, |
| 1858 LPARAM l_param) { | 1868 LPARAM l_param) { |
| 1859 SetMsgHandled(FALSE); | 1869 SetMsgHandled(FALSE); |
| 1860 return 0; | 1870 return 0; |
| 1861 } | 1871 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2084 DwmExtendFrameIntoClientArea(hwnd(), &m); |
| 2075 } | 2085 } |
| 2076 if (window_pos->flags & SWP_SHOWWINDOW) | 2086 if (window_pos->flags & SWP_SHOWWINDOW) |
| 2077 delegate_->HandleVisibilityChanged(true); | 2087 delegate_->HandleVisibilityChanged(true); |
| 2078 else if (window_pos->flags & SWP_HIDEWINDOW) | 2088 else if (window_pos->flags & SWP_HIDEWINDOW) |
| 2079 delegate_->HandleVisibilityChanged(false); | 2089 delegate_->HandleVisibilityChanged(false); |
| 2080 SetMsgHandled(FALSE); | 2090 SetMsgHandled(FALSE); |
| 2081 } | 2091 } |
| 2082 | 2092 |
| 2083 } // namespace views | 2093 } // namespace views |
| OLD | NEW |