| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 last_monitor_(NULL), | 350 last_monitor_(NULL), |
| 351 use_layered_buffer_(false), | 351 use_layered_buffer_(false), |
| 352 layered_alpha_(255), | 352 layered_alpha_(255), |
| 353 waiting_for_redraw_layered_window_contents_(false), | 353 waiting_for_redraw_layered_window_contents_(false), |
| 354 is_first_nccalc_(true), | 354 is_first_nccalc_(true), |
| 355 menu_depth_(0), | 355 menu_depth_(0), |
| 356 autohide_factory_(this), | 356 autohide_factory_(this), |
| 357 id_generator_(0), | 357 id_generator_(0), |
| 358 needs_scroll_styles_(false), | 358 needs_scroll_styles_(false), |
| 359 in_size_loop_(false), | 359 in_size_loop_(false), |
| 360 touch_down_context_(false), | 360 touch_down_contexts_(0), |
| 361 last_mouse_hwheel_time_(0), | 361 last_mouse_hwheel_time_(0), |
| 362 msg_handled_(FALSE) { | 362 msg_handled_(FALSE) { |
| 363 } | 363 } |
| 364 | 364 |
| 365 HWNDMessageHandler::~HWNDMessageHandler() { | 365 HWNDMessageHandler::~HWNDMessageHandler() { |
| 366 delegate_ = NULL; | 366 delegate_ = NULL; |
| 367 // Prevent calls back into this class via WNDPROC now that we've been | 367 // Prevent calls back into this class via WNDPROC now that we've been |
| 368 // destroyed. | 368 // destroyed. |
| 369 ClearUserData(); | 369 ClearUserData(); |
| 370 } | 370 } |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 } | 1470 } |
| 1471 | 1471 |
| 1472 void HWNDMessageHandler::OnKillFocus(HWND focused_window) { | 1472 void HWNDMessageHandler::OnKillFocus(HWND focused_window) { |
| 1473 delegate_->HandleNativeBlur(focused_window); | 1473 delegate_->HandleNativeBlur(focused_window); |
| 1474 SetMsgHandled(FALSE); | 1474 SetMsgHandled(FALSE); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, | 1477 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, |
| 1478 WPARAM w_param, | 1478 WPARAM w_param, |
| 1479 LPARAM l_param) { | 1479 LPARAM l_param) { |
| 1480 // Please refer to the comments in the header for the touch_down_context_ | 1480 // Please refer to the comments in the header for the touch_down_contexts_ |
| 1481 // member for the if statement below. | 1481 // member for the if statement below. |
| 1482 if (touch_down_context_) | 1482 if (touch_down_contexts_) |
| 1483 return MA_NOACTIVATE; | 1483 return MA_NOACTIVATE; |
| 1484 | 1484 |
| 1485 // On Windows, if we select the menu item by touch and if the window at the | 1485 // On Windows, if we select the menu item by touch and if the window at the |
| 1486 // location is another window on the same thread, that window gets a | 1486 // location is another window on the same thread, that window gets a |
| 1487 // WM_MOUSEACTIVATE message and ends up activating itself, which is not | 1487 // WM_MOUSEACTIVATE message and ends up activating itself, which is not |
| 1488 // correct. We workaround this by setting a property on the window at the | 1488 // correct. We workaround this by setting a property on the window at the |
| 1489 // current cursor location. We check for this property in our | 1489 // current cursor location. We check for this property in our |
| 1490 // WM_MOUSEACTIVATE handler and don't activate the window if the property is | 1490 // WM_MOUSEACTIVATE handler and don't activate the window if the property is |
| 1491 // set. | 1491 // set. |
| 1492 if (::GetProp(hwnd(), ui::kIgnoreTouchMouseActivateForWindow)) { | 1492 if (::GetProp(hwnd(), ui::kIgnoreTouchMouseActivateForWindow)) { |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2098 |
| 2099 ScreenToClient(hwnd(), &point); | 2099 ScreenToClient(hwnd(), &point); |
| 2100 | 2100 |
| 2101 last_touch_message_time_ = ::GetMessageTime(); | 2101 last_touch_message_time_ = ::GetMessageTime(); |
| 2102 | 2102 |
| 2103 ui::EventType touch_event_type = ui::ET_UNKNOWN; | 2103 ui::EventType touch_event_type = ui::ET_UNKNOWN; |
| 2104 | 2104 |
| 2105 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { | 2105 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { |
| 2106 touch_ids_.insert(input[i].dwID); | 2106 touch_ids_.insert(input[i].dwID); |
| 2107 touch_event_type = ui::ET_TOUCH_PRESSED; | 2107 touch_event_type = ui::ET_TOUCH_PRESSED; |
| 2108 touch_down_context_ = true; | 2108 touch_down_contexts_++; |
| 2109 base::MessageLoop::current()->PostDelayedTask( | 2109 base::MessageLoop::current()->PostDelayedTask( |
| 2110 FROM_HERE, | 2110 FROM_HERE, |
| 2111 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, | 2111 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, |
| 2112 weak_factory_.GetWeakPtr()), | 2112 weak_factory_.GetWeakPtr()), |
| 2113 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); | 2113 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); |
| 2114 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { | 2114 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { |
| 2115 touch_ids_.erase(input[i].dwID); | 2115 touch_ids_.erase(input[i].dwID); |
| 2116 touch_event_type = ui::ET_TOUCH_RELEASED; | 2116 touch_event_type = ui::ET_TOUCH_RELEASED; |
| 2117 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { | 2117 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
| 2118 touch_event_type = ui::ET_TOUCH_MOVED; | 2118 touch_event_type = ui::ET_TOUCH_MOVED; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 SetMsgHandled(FALSE); | 2254 SetMsgHandled(FALSE); |
| 2255 } | 2255 } |
| 2256 | 2256 |
| 2257 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2257 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
| 2258 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2258 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
| 2259 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2259 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
| 2260 delegate_->HandleTouchEvent(touch_events[i]); | 2260 delegate_->HandleTouchEvent(touch_events[i]); |
| 2261 } | 2261 } |
| 2262 | 2262 |
| 2263 void HWNDMessageHandler::ResetTouchDownContext() { | 2263 void HWNDMessageHandler::ResetTouchDownContext() { |
| 2264 touch_down_context_ = false; | 2264 touch_down_contexts_--; |
| 2265 } | 2265 } |
| 2266 | 2266 |
| 2267 LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, | 2267 LRESULT HWNDMessageHandler::HandleMouseEventInternal(UINT message, |
| 2268 WPARAM w_param, | 2268 WPARAM w_param, |
| 2269 LPARAM l_param, | 2269 LPARAM l_param, |
| 2270 bool track_mouse) { | 2270 bool track_mouse) { |
| 2271 if (!touch_ids_.empty()) | 2271 if (!touch_ids_.empty()) |
| 2272 return 0; | 2272 return 0; |
| 2273 // We handle touch events on Windows Aura. Windows generates synthesized | 2273 // We handle touch events on Windows Aura. Windows generates synthesized |
| 2274 // mouse messages in response to touch which we should ignore. However touch | 2274 // mouse messages in response to touch which we should ignore. However touch |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 POINT cursor_pos = {0}; | 2408 POINT cursor_pos = {0}; |
| 2409 ::GetCursorPos(&cursor_pos); | 2409 ::GetCursorPos(&cursor_pos); |
| 2410 if (memcmp(&cursor_pos, &mouse_location, sizeof(POINT))) | 2410 if (memcmp(&cursor_pos, &mouse_location, sizeof(POINT))) |
| 2411 return false; | 2411 return false; |
| 2412 return true; | 2412 return true; |
| 2413 } | 2413 } |
| 2414 return false; | 2414 return false; |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 } // namespace views | 2417 } // namespace views |
| OLD | NEW |