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 <tchar.h> | 10 #include <tchar.h> |
(...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 if (hittest != HTCLIENT) | 2176 if (hittest != HTCLIENT) |
2177 return 0; | 2177 return 0; |
2178 } | 2178 } |
2179 | 2179 |
2180 ScreenToClient(hwnd(), &point); | 2180 ScreenToClient(hwnd(), &point); |
2181 | 2181 |
2182 last_touch_message_time_ = ::GetMessageTime(); | 2182 last_touch_message_time_ = ::GetMessageTime(); |
2183 | 2183 |
2184 gfx::Point touch_point(point.x, point.y); | 2184 gfx::Point touch_point(point.x, point.y); |
2185 unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID); | 2185 unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID); |
2186 base::TimeDelta time_delta = event_time - base::TimeTicks(); | |
2187 | 2186 |
2188 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { | 2187 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { |
2189 touch_ids_.insert(input[i].dwID); | 2188 touch_ids_.insert(input[i].dwID); |
2190 GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id, | 2189 GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id, |
2191 event_time, time_delta, &touch_events); | 2190 event_time, &touch_events); |
2192 touch_down_contexts_++; | 2191 touch_down_contexts_++; |
2193 base::MessageLoop::current()->PostDelayedTask( | 2192 base::MessageLoop::current()->PostDelayedTask( |
2194 FROM_HERE, | 2193 FROM_HERE, |
2195 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, | 2194 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, |
2196 weak_factory_.GetWeakPtr()), | 2195 weak_factory_.GetWeakPtr()), |
2197 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); | 2196 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); |
2198 } else { | 2197 } else { |
2199 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { | 2198 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
2200 GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id, | 2199 GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id, |
2201 event_time, time_delta, &touch_events); | 2200 event_time, &touch_events); |
2202 } | 2201 } |
2203 | 2202 |
2204 if (input[i].dwFlags & TOUCHEVENTF_UP) { | 2203 if (input[i].dwFlags & TOUCHEVENTF_UP) { |
2205 touch_ids_.erase(input[i].dwID); | 2204 touch_ids_.erase(input[i].dwID); |
2206 GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id, | 2205 GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id, |
2207 event_time, time_delta, &touch_events); | 2206 event_time, &touch_events); |
2208 id_generator_.ReleaseNumber(input[i].dwID); | 2207 id_generator_.ReleaseNumber(input[i].dwID); |
2209 } | 2208 } |
2210 } | 2209 } |
2211 } | 2210 } |
2212 // Handle the touch events asynchronously. We need this because touch | 2211 // Handle the touch events asynchronously. We need this because touch |
2213 // events on windows don't fire if we enter a modal loop in the context of | 2212 // events on windows don't fire if we enter a modal loop in the context of |
2214 // a touch event. | 2213 // a touch event. |
2215 base::MessageLoop::current()->PostTask( | 2214 base::MessageLoop::current()->PostTask( |
2216 FROM_HERE, | 2215 FROM_HERE, |
2217 base::Bind(&HWNDMessageHandler::HandleTouchEvents, | 2216 base::Bind(&HWNDMessageHandler::HandleTouchEvents, |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2550 } | 2549 } |
2551 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2550 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
2552 // to notify our children too, since we can have MDI child windows who need to | 2551 // to notify our children too, since we can have MDI child windows who need to |
2553 // update their appearance. | 2552 // update their appearance. |
2554 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2553 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
2555 } | 2554 } |
2556 | 2555 |
2557 void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type, | 2556 void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type, |
2558 const gfx::Point& point, | 2557 const gfx::Point& point, |
2559 unsigned int id, | 2558 unsigned int id, |
2560 base::TimeTicks event_time, | 2559 base::TimeTicks time_stamp, |
2561 base::TimeDelta time_stamp, | |
2562 TouchEvents* touch_events) { | 2560 TouchEvents* touch_events) { |
2563 ui::TouchEvent event(event_type, point, id, time_stamp); | 2561 ui::TouchEvent event(event_type, point, id, time_stamp); |
2564 | 2562 |
2565 event.set_flags(ui::GetModifiersFromKeyState()); | 2563 event.set_flags(ui::GetModifiersFromKeyState()); |
2566 | 2564 |
2567 event.latency()->AddLatencyNumberWithTimestamp( | 2565 event.latency()->AddLatencyNumberWithTimestamp( |
2568 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 2566 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
2569 0, | 2567 0, |
2570 0, | 2568 0, |
2571 event_time, | 2569 time_stamp, |
2572 1); | 2570 1); |
2573 | 2571 |
2574 touch_events->push_back(event); | 2572 touch_events->push_back(event); |
2575 } | 2573 } |
2576 | 2574 |
2577 bool HWNDMessageHandler::HandleMouseInputForCaption(unsigned int message, | 2575 bool HWNDMessageHandler::HandleMouseInputForCaption(unsigned int message, |
2578 WPARAM w_param, | 2576 WPARAM w_param, |
2579 LPARAM l_param) { | 2577 LPARAM l_param) { |
2580 // If we are receive a WM_NCLBUTTONDOWN messsage for the caption, the | 2578 // If we are receive a WM_NCLBUTTONDOWN messsage for the caption, the |
2581 // following things happen. | 2579 // following things happen. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); | 2676 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); |
2679 ResetWindowRegion(false, true); | 2677 ResetWindowRegion(false, true); |
2680 } | 2678 } |
2681 | 2679 |
2682 if (direct_manipulation_helper_) | 2680 if (direct_manipulation_helper_) |
2683 direct_manipulation_helper_->SetBounds(bounds_in_pixels); | 2681 direct_manipulation_helper_->SetBounds(bounds_in_pixels); |
2684 } | 2682 } |
2685 | 2683 |
2686 | 2684 |
2687 } // namespace views | 2685 } // namespace views |
OLD | NEW |