Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 22865036: Add support for reposting the ET_GESTURE_TAP_DOWN gesture event to the RootWindow and in the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 } 2034 }
2035 } 2035 }
2036 2036
2037 void HWNDMessageHandler::OnThemeChanged() { 2037 void HWNDMessageHandler::OnThemeChanged() {
2038 ui::NativeThemeWin::instance()->CloseHandles(); 2038 ui::NativeThemeWin::instance()->CloseHandles();
2039 } 2039 }
2040 2040
2041 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, 2041 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
2042 WPARAM w_param, 2042 WPARAM w_param,
2043 LPARAM l_param) { 2043 LPARAM l_param) {
2044 // Handle touch events only on Aura for now.
sky 2013/08/22 22:07:16 How does this effect non-aura?
ananta 2013/08/22 22:48:15 In non AURA the RenderWidgetHostViewWin class hand
2045 #if !defined(USE_AURA)
2046 SetMsgHandled(FALSE);
2047 return 0;
2048 #endif
2044 int num_points = LOWORD(w_param); 2049 int num_points = LOWORD(w_param);
2045 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); 2050 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]);
2046 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), 2051 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param),
2047 num_points, input.get(), 2052 num_points, input.get(),
2048 sizeof(TOUCHINPUT))) { 2053 sizeof(TOUCHINPUT))) {
2054 TouchEvents touch_events;
2049 for (int i = 0; i < num_points; ++i) { 2055 for (int i = 0; i < num_points; ++i) {
2050 ui::EventType touch_event_type = ui::ET_UNKNOWN; 2056 ui::EventType touch_event_type = ui::ET_UNKNOWN;
2051 2057
2052 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { 2058 if (input[i].dwFlags & TOUCHEVENTF_DOWN) {
2053 touch_ids_.insert(input[i].dwID); 2059 touch_ids_.insert(input[i].dwID);
2054 touch_event_type = ui::ET_TOUCH_PRESSED; 2060 touch_event_type = ui::ET_TOUCH_PRESSED;
2055 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { 2061 } else if (input[i].dwFlags & TOUCHEVENTF_UP) {
2056 touch_ids_.erase(input[i].dwID); 2062 touch_ids_.erase(input[i].dwID);
2057 touch_event_type = ui::ET_TOUCH_RELEASED; 2063 touch_event_type = ui::ET_TOUCH_RELEASED;
2058 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { 2064 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) {
2059 touch_event_type = ui::ET_TOUCH_MOVED; 2065 touch_event_type = ui::ET_TOUCH_MOVED;
2060 } 2066 }
2061 // Handle touch events only on Aura for now.
2062 #if defined(USE_AURA)
2063 if (touch_event_type != ui::ET_UNKNOWN) { 2067 if (touch_event_type != ui::ET_UNKNOWN) {
2064 POINT point; 2068 POINT point;
2065 point.x = TOUCH_COORD_TO_PIXEL(input[i].x) / 2069 point.x = TOUCH_COORD_TO_PIXEL(input[i].x) /
2066 ui::win::GetUndocumentedDPIScale(); 2070 ui::win::GetUndocumentedDPIScale();
2067 point.y = TOUCH_COORD_TO_PIXEL(input[i].y) / 2071 point.y = TOUCH_COORD_TO_PIXEL(input[i].y) /
2068 ui::win::GetUndocumentedDPIScale(); 2072 ui::win::GetUndocumentedDPIScale();
2069 2073
2070 ScreenToClient(hwnd(), &point); 2074 ScreenToClient(hwnd(), &point);
2071 2075
2072 ui::TouchEvent event( 2076 ui::TouchEvent event(
2073 touch_event_type, 2077 touch_event_type,
2074 gfx::Point(point.x, point.y), 2078 gfx::Point(point.x, point.y),
2075 input[i].dwID % ui::GestureSequence::kMaxGesturePoints, 2079 input[i].dwID % ui::GestureSequence::kMaxGesturePoints,
2076 base::TimeDelta::FromMilliseconds(input[i].dwTime)); 2080 base::TimeDelta::FromMilliseconds(input[i].dwTime));
2077 delegate_->HandleTouchEvent(event); 2081 touch_events.push_back(event);
2078 } 2082 }
2079 #endif
2080 } 2083 }
2084 // Handle the touch events asynchronously. We need this because touch
2085 // events on windows don't fire if we enter a modal loop in the context of
2086 // a touch event.
2087 base::MessageLoop::current()->PostTask(
2088 FROM_HERE,
2089 base::Bind(&HWNDMessageHandler::HandleTouchEvents,
2090 base::Unretained(this), touch_events));
sky 2013/08/22 22:07:16 Don't use Unretained here. There is no guarantee t
ananta 2013/08/22 22:48:15 Done.
2081 } 2091 }
2082 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); 2092 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param));
2083 SetMsgHandled(FALSE); 2093 SetMsgHandled(FALSE);
2084 return 0; 2094 return 0;
2085 } 2095 }
2086 2096
2087 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { 2097 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) {
2088 if (ignore_window_pos_changes_) { 2098 if (ignore_window_pos_changes_) {
2089 // If somebody's trying to toggle our visibility, change the nonclient area, 2099 // If somebody's trying to toggle our visibility, change the nonclient area,
2090 // change our Z-order, or activate us, we should probably let it go through. 2100 // change our Z-order, or activate us, we should probably let it go through.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 MARGINS m = {10, 10, 10, 10}; 2184 MARGINS m = {10, 10, 10, 10};
2175 DwmExtendFrameIntoClientArea(hwnd(), &m); 2185 DwmExtendFrameIntoClientArea(hwnd(), &m);
2176 } 2186 }
2177 if (window_pos->flags & SWP_SHOWWINDOW) 2187 if (window_pos->flags & SWP_SHOWWINDOW)
2178 delegate_->HandleVisibilityChanged(true); 2188 delegate_->HandleVisibilityChanged(true);
2179 else if (window_pos->flags & SWP_HIDEWINDOW) 2189 else if (window_pos->flags & SWP_HIDEWINDOW)
2180 delegate_->HandleVisibilityChanged(false); 2190 delegate_->HandleVisibilityChanged(false);
2181 SetMsgHandled(FALSE); 2191 SetMsgHandled(FALSE);
2182 } 2192 }
2183 2193
2194 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) {
2195 if (!delegate_)
2196 return;
2197 for (size_t i = 0; i < touch_events.size(); ++i) {
sky 2013/08/22 22:07:16 nit: no {}
ananta 2013/08/22 22:48:15 Done.
2198 delegate_->HandleTouchEvent(touch_events[i]);
2199 }
2200 }
2201
2184 } // namespace views 2202 } // namespace views
OLDNEW
« ui/views/controls/menu/menu_controller.cc ('K') | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698