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 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 if (hittest != HTCLIENT) | 2214 if (hittest != HTCLIENT) |
2215 return 0; | 2215 return 0; |
2216 } | 2216 } |
2217 | 2217 |
2218 ScreenToClient(hwnd(), &point); | 2218 ScreenToClient(hwnd(), &point); |
2219 | 2219 |
2220 last_touch_message_time_ = ::GetMessageTime(); | 2220 last_touch_message_time_ = ::GetMessageTime(); |
2221 | 2221 |
2222 gfx::Point touch_point(point.x, point.y); | 2222 gfx::Point touch_point(point.x, point.y); |
2223 unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID); | 2223 unsigned int touch_id = id_generator_.GetGeneratedID(input[i].dwID); |
2224 base::TimeDelta time_delta = event_time - base::TimeTicks(); | |
2225 | 2224 |
2226 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { | 2225 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { |
2227 touch_ids_.insert(input[i].dwID); | 2226 touch_ids_.insert(input[i].dwID); |
2228 GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id, | 2227 GenerateTouchEvent(ui::ET_TOUCH_PRESSED, touch_point, touch_id, |
2229 event_time, time_delta, &touch_events); | 2228 event_time, &touch_events); |
2230 touch_down_contexts_++; | 2229 touch_down_contexts_++; |
2231 base::MessageLoop::current()->PostDelayedTask( | 2230 base::MessageLoop::current()->PostDelayedTask( |
2232 FROM_HERE, | 2231 FROM_HERE, |
2233 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, | 2232 base::Bind(&HWNDMessageHandler::ResetTouchDownContext, |
2234 weak_factory_.GetWeakPtr()), | 2233 weak_factory_.GetWeakPtr()), |
2235 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); | 2234 base::TimeDelta::FromMilliseconds(kTouchDownContextResetTimeout)); |
2236 } else { | 2235 } else { |
2237 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { | 2236 if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
2238 GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id, | 2237 GenerateTouchEvent(ui::ET_TOUCH_MOVED, touch_point, touch_id, |
2239 event_time, time_delta, &touch_events); | 2238 event_time, &touch_events); |
2240 } | 2239 } |
2241 | 2240 |
2242 if (input[i].dwFlags & TOUCHEVENTF_UP) { | 2241 if (input[i].dwFlags & TOUCHEVENTF_UP) { |
2243 touch_ids_.erase(input[i].dwID); | 2242 touch_ids_.erase(input[i].dwID); |
2244 GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id, | 2243 GenerateTouchEvent(ui::ET_TOUCH_RELEASED, touch_point, touch_id, |
2245 event_time, time_delta, &touch_events); | 2244 event_time, &touch_events); |
2246 id_generator_.ReleaseNumber(input[i].dwID); | 2245 id_generator_.ReleaseNumber(input[i].dwID); |
2247 } | 2246 } |
2248 } | 2247 } |
2249 } | 2248 } |
2250 // Handle the touch events asynchronously. We need this because touch | 2249 // Handle the touch events asynchronously. We need this because touch |
2251 // events on windows don't fire if we enter a modal loop in the context of | 2250 // events on windows don't fire if we enter a modal loop in the context of |
2252 // a touch event. | 2251 // a touch event. |
2253 base::MessageLoop::current()->PostTask( | 2252 base::MessageLoop::current()->PostTask( |
2254 FROM_HERE, | 2253 FROM_HERE, |
2255 base::Bind(&HWNDMessageHandler::HandleTouchEvents, | 2254 base::Bind(&HWNDMessageHandler::HandleTouchEvents, |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 } | 2587 } |
2589 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2588 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
2590 // to notify our children too, since we can have MDI child windows who need to | 2589 // to notify our children too, since we can have MDI child windows who need to |
2591 // update their appearance. | 2590 // update their appearance. |
2592 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2591 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
2593 } | 2592 } |
2594 | 2593 |
2595 void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type, | 2594 void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type, |
2596 const gfx::Point& point, | 2595 const gfx::Point& point, |
2597 unsigned int id, | 2596 unsigned int id, |
2598 base::TimeTicks event_time, | 2597 base::TimeTicks time_stamp, |
2599 base::TimeDelta time_stamp, | |
2600 TouchEvents* touch_events) { | 2598 TouchEvents* touch_events) { |
2601 ui::TouchEvent event(event_type, point, id, time_stamp); | 2599 ui::TouchEvent event(event_type, point, id, time_stamp); |
2602 | 2600 |
2603 event.set_flags(ui::GetModifiersFromKeyState()); | 2601 event.set_flags(ui::GetModifiersFromKeyState()); |
2604 | 2602 |
2605 event.latency()->AddLatencyNumberWithTimestamp( | 2603 event.latency()->AddLatencyNumberWithTimestamp( |
2606 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 2604 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
2607 0, | 2605 0, |
2608 0, | 2606 0, |
2609 event_time, | 2607 time_stamp, |
2610 1); | 2608 1); |
2611 | 2609 |
2612 touch_events->push_back(event); | 2610 touch_events->push_back(event); |
2613 } | 2611 } |
2614 | 2612 |
2615 bool HWNDMessageHandler::HandleMouseInputForCaption(unsigned int message, | 2613 bool HWNDMessageHandler::HandleMouseInputForCaption(unsigned int message, |
2616 WPARAM w_param, | 2614 WPARAM w_param, |
2617 LPARAM l_param) { | 2615 LPARAM l_param) { |
2618 // If we are receive a WM_NCLBUTTONDOWN messsage for the caption, the | 2616 // If we are receive a WM_NCLBUTTONDOWN messsage for the caption, the |
2619 // following things happen. | 2617 // following things happen. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2740 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 2738 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
2741 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), | 2739 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), |
2742 &monitor_info); | 2740 &monitor_info); |
2743 gfx::Rect shrunk_rect(monitor_info.rcMonitor); | 2741 gfx::Rect shrunk_rect(monitor_info.rcMonitor); |
2744 shrunk_rect.set_height(shrunk_rect.height() - 1); | 2742 shrunk_rect.set_height(shrunk_rect.height() - 1); |
2745 background_fullscreen_hack_ = true; | 2743 background_fullscreen_hack_ = true; |
2746 SetBoundsInternal(shrunk_rect, false); | 2744 SetBoundsInternal(shrunk_rect, false); |
2747 } | 2745 } |
2748 | 2746 |
2749 } // namespace views | 2747 } // namespace views |
OLD | NEW |