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

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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 lock_updates_count_(0), 386 lock_updates_count_(0),
387 destroyed_(NULL), 387 destroyed_(NULL),
388 ignore_window_pos_changes_(false), 388 ignore_window_pos_changes_(false),
389 ignore_pos_changes_factory_(this), 389 ignore_pos_changes_factory_(this),
390 last_monitor_(NULL), 390 last_monitor_(NULL),
391 use_layered_buffer_(false), 391 use_layered_buffer_(false),
392 layered_alpha_(255), 392 layered_alpha_(255),
393 paint_layered_window_factory_(this), 393 paint_layered_window_factory_(this),
394 can_update_layered_window_(true), 394 can_update_layered_window_(true),
395 is_first_nccalc_(true), 395 is_first_nccalc_(true),
396 autohide_factory_(this) { 396 autohide_factory_(this),
397 touch_event_factory_(this) {
397 } 398 }
398 399
399 HWNDMessageHandler::~HWNDMessageHandler() { 400 HWNDMessageHandler::~HWNDMessageHandler() {
400 delegate_ = NULL; 401 delegate_ = NULL;
401 if (destroyed_ != NULL) 402 if (destroyed_ != NULL)
402 *destroyed_ = true; 403 *destroyed_ = true;
403 // Prevent calls back into this class via WNDPROC now that we've been 404 // Prevent calls back into this class via WNDPROC now that we've been
404 // destroyed. 405 // destroyed.
405 ClearUserData(); 406 ClearUserData();
406 } 407 }
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 } 2035 }
2035 } 2036 }
2036 2037
2037 void HWNDMessageHandler::OnThemeChanged() { 2038 void HWNDMessageHandler::OnThemeChanged() {
2038 ui::NativeThemeWin::instance()->CloseHandles(); 2039 ui::NativeThemeWin::instance()->CloseHandles();
2039 } 2040 }
2040 2041
2041 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, 2042 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message,
2042 WPARAM w_param, 2043 WPARAM w_param,
2043 LPARAM l_param) { 2044 LPARAM l_param) {
2045 // Handle touch events only on Aura for now.
2046 #if !defined(USE_AURA)
2047 SetMsgHandled(FALSE);
2048 return 0;
2049 #endif
2044 int num_points = LOWORD(w_param); 2050 int num_points = LOWORD(w_param);
2045 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]); 2051 scoped_ptr<TOUCHINPUT[]> input(new TOUCHINPUT[num_points]);
2046 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), 2052 if (ui::GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param),
2047 num_points, input.get(), 2053 num_points, input.get(),
2048 sizeof(TOUCHINPUT))) { 2054 sizeof(TOUCHINPUT))) {
2055 TouchEvents touch_events;
2049 for (int i = 0; i < num_points; ++i) { 2056 for (int i = 0; i < num_points; ++i) {
2050 ui::EventType touch_event_type = ui::ET_UNKNOWN; 2057 ui::EventType touch_event_type = ui::ET_UNKNOWN;
2051 2058
2052 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { 2059 if (input[i].dwFlags & TOUCHEVENTF_DOWN) {
2053 touch_ids_.insert(input[i].dwID); 2060 touch_ids_.insert(input[i].dwID);
2054 touch_event_type = ui::ET_TOUCH_PRESSED; 2061 touch_event_type = ui::ET_TOUCH_PRESSED;
2055 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { 2062 } else if (input[i].dwFlags & TOUCHEVENTF_UP) {
2056 touch_ids_.erase(input[i].dwID); 2063 touch_ids_.erase(input[i].dwID);
2057 touch_event_type = ui::ET_TOUCH_RELEASED; 2064 touch_event_type = ui::ET_TOUCH_RELEASED;
2058 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { 2065 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) {
2059 touch_event_type = ui::ET_TOUCH_MOVED; 2066 touch_event_type = ui::ET_TOUCH_MOVED;
2060 } 2067 }
2061 // Handle touch events only on Aura for now.
2062 #if defined(USE_AURA)
2063 if (touch_event_type != ui::ET_UNKNOWN) { 2068 if (touch_event_type != ui::ET_UNKNOWN) {
2064 POINT point; 2069 POINT point;
2065 point.x = TOUCH_COORD_TO_PIXEL(input[i].x) / 2070 point.x = TOUCH_COORD_TO_PIXEL(input[i].x) /
2066 ui::win::GetUndocumentedDPIScale(); 2071 ui::win::GetUndocumentedDPIScale();
2067 point.y = TOUCH_COORD_TO_PIXEL(input[i].y) / 2072 point.y = TOUCH_COORD_TO_PIXEL(input[i].y) /
2068 ui::win::GetUndocumentedDPIScale(); 2073 ui::win::GetUndocumentedDPIScale();
2069 2074
2070 ScreenToClient(hwnd(), &point); 2075 ScreenToClient(hwnd(), &point);
2071 2076
2072 ui::TouchEvent event( 2077 ui::TouchEvent event(
2073 touch_event_type, 2078 touch_event_type,
2074 gfx::Point(point.x, point.y), 2079 gfx::Point(point.x, point.y),
2075 input[i].dwID % ui::GestureSequence::kMaxGesturePoints, 2080 input[i].dwID % ui::GestureSequence::kMaxGesturePoints,
2076 base::TimeDelta::FromMilliseconds(input[i].dwTime)); 2081 base::TimeDelta::FromMilliseconds(input[i].dwTime));
2077 delegate_->HandleTouchEvent(event); 2082 touch_events.push_back(event);
2078 } 2083 }
2079 #endif
2080 } 2084 }
2085 // Handle the touch events asynchronously. We need this because touch
2086 // events on windows don't fire if we enter a modal loop in the context of
2087 // a touch event.
2088 base::MessageLoop::current()->PostTask(
2089 FROM_HERE,
2090 base::Bind(&HWNDMessageHandler::HandleTouchEvents,
2091 touch_event_factory_.GetWeakPtr(), touch_events));
2081 } 2092 }
2082 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); 2093 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param));
2083 SetMsgHandled(FALSE); 2094 SetMsgHandled(FALSE);
2084 return 0; 2095 return 0;
2085 } 2096 }
2086 2097
2087 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { 2098 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) {
2088 if (ignore_window_pos_changes_) { 2099 if (ignore_window_pos_changes_) {
2089 // If somebody's trying to toggle our visibility, change the nonclient area, 2100 // 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. 2101 // 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}; 2185 MARGINS m = {10, 10, 10, 10};
2175 DwmExtendFrameIntoClientArea(hwnd(), &m); 2186 DwmExtendFrameIntoClientArea(hwnd(), &m);
2176 } 2187 }
2177 if (window_pos->flags & SWP_SHOWWINDOW) 2188 if (window_pos->flags & SWP_SHOWWINDOW)
2178 delegate_->HandleVisibilityChanged(true); 2189 delegate_->HandleVisibilityChanged(true);
2179 else if (window_pos->flags & SWP_HIDEWINDOW) 2190 else if (window_pos->flags & SWP_HIDEWINDOW)
2180 delegate_->HandleVisibilityChanged(false); 2191 delegate_->HandleVisibilityChanged(false);
2181 SetMsgHandled(FALSE); 2192 SetMsgHandled(FALSE);
2182 } 2193 }
2183 2194
2195 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) {
2196 if (!delegate_)
2197 return;
2198 for (size_t i = 0; i < touch_events.size(); ++i)
2199 delegate_->HandleTouchEvent(touch_events[i]);
2200 }
2201
2184 } // namespace views 2202 } // namespace views
OLDNEW
« ui/aura/root_window_unittest.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