Chromium Code Reviews| 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 <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <wtsapi32.h> | 10 #include <wtsapi32.h> |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 | 1015 |
| 1016 bool active = activation_state != WA_INACTIVE && !minimized; | 1016 bool active = activation_state != WA_INACTIVE && !minimized; |
| 1017 if (delegate_->CanActivate()) | 1017 if (delegate_->CanActivate()) |
| 1018 delegate_->HandleActivationChanged(active); | 1018 delegate_->HandleActivationChanged(active); |
| 1019 | 1019 |
| 1020 if (!active) { | 1020 if (!active) { |
| 1021 // We might get activated/inactivated without being enabled, so we need to | 1021 // We might get activated/inactivated without being enabled, so we need to |
| 1022 // clear restore_focus_when_enabled_. | 1022 // clear restore_focus_when_enabled_. |
| 1023 restore_focus_when_enabled_ = false; | 1023 restore_focus_when_enabled_ = false; |
| 1024 delegate_->SaveFocusOnDeactivate(); | 1024 delegate_->SaveFocusOnDeactivate(); |
| 1025 // When we lose activation send a dummy WM_MOUSELEAVE message. This is to | |
| 1026 // handle cases when we don't track certain WM_MOUSEMOVE messages like those | |
| 1027 // coming from a child. | |
| 1028 ::PostMessage(hwnd(), WM_MOUSELEAVE, 0, 0); | |
|
sky
2014/02/12 22:51:29
If the legacy hwnd starts tracking mouse events, i
ananta
2014/02/12 23:17:08
When it does. The TrackMouseEvent API succeeds on
| |
| 1025 } else { | 1029 } else { |
| 1026 // We must restore the focus after the message has been DefProc'ed as it | 1030 // We must restore the focus after the message has been DefProc'ed as it |
| 1027 // does set the focus to the last focused HWND. | 1031 // does set the focus to the last focused HWND. |
| 1028 // Note that if the window is not enabled, we cannot restore the focus as | 1032 // Note that if the window is not enabled, we cannot restore the focus as |
| 1029 // calling ::SetFocus on a child of the non-enabled top-window would fail. | 1033 // calling ::SetFocus on a child of the non-enabled top-window would fail. |
| 1030 // This is the case when showing a modal dialog (such as 'open file', | 1034 // This is the case when showing a modal dialog (such as 'open file', |
| 1031 // 'print'...) from a different thread. | 1035 // 'print'...) from a different thread. |
| 1032 // In that case we delay the focus restoration to when the window is enabled | 1036 // In that case we delay the focus restoration to when the window is enabled |
| 1033 // again. | 1037 // again. |
| 1034 if (!IsWindowEnabled(hwnd())) { | 1038 if (!IsWindowEnabled(hwnd())) { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1621 } | 1625 } |
| 1622 } | 1626 } |
| 1623 } else if (message == WM_NCRBUTTONDOWN && | 1627 } else if (message == WM_NCRBUTTONDOWN && |
| 1624 (w_param == HTCAPTION || w_param == HTSYSMENU)) { | 1628 (w_param == HTCAPTION || w_param == HTSYSMENU)) { |
| 1625 is_right_mouse_pressed_on_caption_ = true; | 1629 is_right_mouse_pressed_on_caption_ = true; |
| 1626 // We SetCapture() to ensure we only show the menu when the button | 1630 // We SetCapture() to ensure we only show the menu when the button |
| 1627 // down and up are both on the caption. Note: this causes the button up to | 1631 // down and up are both on the caption. Note: this causes the button up to |
| 1628 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. | 1632 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. |
| 1629 SetCapture(); | 1633 SetCapture(); |
| 1630 } | 1634 } |
| 1631 | |
| 1632 MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime(), | 1635 MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime(), |
| 1633 { CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } }; | 1636 { CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } }; |
| 1634 ui::MouseEvent event(msg); | 1637 ui::MouseEvent event(msg); |
| 1635 if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message)) | 1638 if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message)) |
| 1636 event.set_flags(event.flags() | ui::EF_FROM_TOUCH); | 1639 event.set_flags(event.flags() | ui::EF_FROM_TOUCH); |
| 1637 | 1640 |
| 1638 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) | 1641 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) |
| 1639 delegate_->HandleTooltipMouseMove(message, w_param, l_param); | 1642 delegate_->HandleTooltipMouseMove(message, w_param, l_param); |
| 1640 | 1643 |
| 1641 if (event.type() == ui::ET_MOUSE_MOVED && !HasCapture()) { | 1644 if (event.type() == ui::ET_MOUSE_MOVED && !HasCapture() && |
| 1645 HIWORD(w_param) != SPECIAL_MOUSEMOVE_NOT_TO_BE_TRACKED) { | |
|
sky
2014/02/12 22:51:29
Does this imply we need to track mouse mouse event
ananta
2014/02/12 23:17:08
When the mouse leaves the bounds of the child we w
| |
| 1642 // Windows only fires WM_MOUSELEAVE events if the application begins | 1646 // Windows only fires WM_MOUSELEAVE events if the application begins |
| 1643 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. | 1647 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. |
| 1644 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. | 1648 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. |
| 1645 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? | 1649 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? |
| 1646 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); | 1650 TME_NONCLIENT | TME_LEAVE : TME_LEAVE); |
| 1647 } else if (event.type() == ui::ET_MOUSE_EXITED) { | 1651 } else if (event.type() == ui::ET_MOUSE_EXITED) { |
| 1648 // Reset our tracking flags so future mouse movement over this | 1652 // Reset our tracking flags so future mouse movement over this |
| 1649 // NativeWidgetWin results in a new tracking session. Fall through for | 1653 // NativeWidgetWin results in a new tracking session. Fall through for |
| 1650 // OnMouseEvent. | 1654 // OnMouseEvent. |
| 1651 active_mouse_tracking_flags_ = 0; | 1655 active_mouse_tracking_flags_ = 0; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2389 SetMsgHandled(FALSE); | 2393 SetMsgHandled(FALSE); |
| 2390 } | 2394 } |
| 2391 | 2395 |
| 2392 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2396 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
| 2393 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2397 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
| 2394 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2398 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
| 2395 delegate_->HandleTouchEvent(touch_events[i]); | 2399 delegate_->HandleTouchEvent(touch_events[i]); |
| 2396 } | 2400 } |
| 2397 | 2401 |
| 2398 } // namespace views | 2402 } // namespace views |
| OLD | NEW |