touch: Cleanup touch-event mode switching on windows.
On windows, chrome used to switch between raw-touch and gesture modes depending on whether the touch-start event was processed by the renderer or not. But now, the switch happens iff touch-events is enabled (using command-line flag) on appropriate version of windows. So cleanup the relevant code. BUG=138153 TBR=avi@chromium.org (content/port/) Review URL: https://codereview.chromium.org/11028144 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161458 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
content
browser
renderer_host
render_widget_host_impl.ccrender_widget_host_impl.hrender_widget_host_view_android.ccrender_widget_host_view_android.hrender_widget_host_view_aura.ccrender_widget_host_view_aura.hrender_widget_host_view_gtk.ccrender_widget_host_view_gtk.hrender_widget_host_view_mac.hrender_widget_host_view_mac.mmrender_widget_host_view_win.ccrender_widget_host_view_win.htest_render_view_host.h
port
@ -1590,7 +1590,7 @@ void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type,
|
||||
} else if (type == WebInputEvent::MouseWheel) {
|
||||
ProcessWheelAck(processed);
|
||||
} else if (WebInputEvent::isTouchEventType(type)) {
|
||||
ProcessTouchAck(event_type, processed);
|
||||
ProcessTouchAck(processed);
|
||||
} else if (WebInputEvent::isGestureEventType(type)) {
|
||||
ProcessGestureAck(processed, type);
|
||||
}
|
||||
@ -1728,10 +1728,9 @@ void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) {
|
||||
gesture_event_filter_->ProcessGestureAck(processed, type);
|
||||
}
|
||||
|
||||
void RenderWidgetHostImpl::ProcessTouchAck(
|
||||
WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostImpl::ProcessTouchAck(bool processed) {
|
||||
if (view_)
|
||||
view_->ProcessTouchAck(type, processed);
|
||||
view_->ProcessTouchAck(processed);
|
||||
}
|
||||
|
||||
void RenderWidgetHostImpl::OnMsgFocus() {
|
||||
|
@ -638,7 +638,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost,
|
||||
// Called on OnMsgInputEventAck() to process a touch event ack message.
|
||||
// This can result in a gesture event being generated and sent back to the
|
||||
// renderer.
|
||||
void ProcessTouchAck(WebKit::WebInputEvent::Type type, bool processed);
|
||||
void ProcessTouchAck(bool processed);
|
||||
|
||||
// Called when there is a new auto resize (using a post to avoid a stack
|
||||
// which may get in recursive loops).
|
||||
|
@ -374,8 +374,7 @@ void RenderWidgetHostViewAndroid::UnhandledWheelEvent(
|
||||
// intentionally empty, like RenderWidgetHostViewViews
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewAndroid::ProcessTouchAck(
|
||||
WebKit::WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostViewAndroid::ProcessTouchAck(bool processed) {
|
||||
// intentionally empty, like RenderWidgetHostViewViews
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,7 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
|
||||
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
|
||||
virtual void UnhandledWheelEvent(
|
||||
const WebKit::WebMouseWheelEvent& event) OVERRIDE;
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE;
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
|
@ -1005,8 +1005,7 @@ gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
|
||||
return window_->GetToplevelWindow()->GetBoundsInRootWindow();
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewAura::ProcessTouchAck(
|
||||
WebKit::WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostViewAura::ProcessTouchAck(bool processed) {
|
||||
// The ACKs for the touch-events arrive in the same sequence as they were
|
||||
// dispatched.
|
||||
aura::RootWindow* root_window = window_->GetRootWindow();
|
||||
|
@ -127,8 +127,7 @@ class RenderWidgetHostViewAura
|
||||
virtual void AcceleratedSurfaceRelease(uint64 surface_id) OVERRIDE;
|
||||
virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE;
|
||||
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE;
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
|
@ -1241,8 +1241,7 @@ void RenderWidgetHostViewGtk::DestroyPluginContainer(
|
||||
plugin_container_manager_.DestroyPluginContainer(id);
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewGtk::ProcessTouchAck(
|
||||
WebKit::WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostViewGtk::ProcessTouchAck(bool processed) {
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewGtk::SetHasHorizontalScrollbar(
|
||||
|
@ -116,8 +116,7 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk
|
||||
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
|
||||
virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
|
||||
virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE;
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
|
@ -319,8 +319,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostViewBase {
|
||||
// to be reloaded.
|
||||
void ForceTextureReload();
|
||||
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE;
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
|
@ -1318,8 +1318,7 @@ void RenderWidgetHostViewMac::ForceTextureReload() {
|
||||
plugin_container_manager_.ForceTextureReload();
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewMac::ProcessTouchAck(
|
||||
WebKit::WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostViewMac::ProcessTouchAck(bool processed) {
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewMac::SetHasHorizontalScrollbar(
|
||||
|
@ -951,8 +951,7 @@ void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) {
|
||||
render_widget_host_->SetBackground(background);
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewWin::ProcessTouchAck(
|
||||
WebKit::WebInputEvent::Type type, bool processed) {
|
||||
void RenderWidgetHostViewWin::ProcessTouchAck(bool processed) {
|
||||
|
||||
DCHECK(render_widget_host_->has_touch_handler() &&
|
||||
touch_events_enabled_);
|
||||
@ -963,59 +962,35 @@ void RenderWidgetHostViewWin::ProcessTouchAck(
|
||||
gestures.reset(gesture_recognizer_->AdvanceTouchQueue(this, processed));
|
||||
ProcessGestures(gestures.get());
|
||||
}
|
||||
|
||||
if (type == WebKit::WebInputEvent::TouchStart)
|
||||
UpdateDesiredTouchMode(processed);
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewWin::SetToGestureMode() {
|
||||
if (base::win::GetVersion() < base::win::VERSION_WIN7)
|
||||
return;
|
||||
UnregisterTouchWindow(m_hWnd);
|
||||
// Single finger panning is consistent with other windows applications.
|
||||
const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY |
|
||||
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
|
||||
const DWORD gesture_block = GC_PAN_WITH_GUTTER;
|
||||
GESTURECONFIG gc[] = {
|
||||
{ GID_ZOOM, GC_ZOOM, 0 },
|
||||
{ GID_PAN, gesture_allow , gesture_block},
|
||||
{ GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0},
|
||||
{ GID_PRESSANDTAP, GC_PRESSANDTAP , 0}
|
||||
};
|
||||
if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc,
|
||||
sizeof(GESTURECONFIG))) {
|
||||
NOTREACHED();
|
||||
}
|
||||
touch_events_enabled_ = false;
|
||||
}
|
||||
|
||||
bool RenderWidgetHostViewWin::SetToTouchMode() {
|
||||
if (base::win::GetVersion() < base::win::VERSION_WIN7)
|
||||
return false;
|
||||
bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
|
||||
touch_events_enabled_ = touch_mode;
|
||||
return touch_mode;
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewWin::UpdateDesiredTouchMode(bool touch_mode) {
|
||||
void RenderWidgetHostViewWin::UpdateDesiredTouchMode() {
|
||||
// Make sure that touch events even make sense.
|
||||
bool touch_mode_valid = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
|
||||
static bool touch_mode = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
|
||||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
|
||||
touch_mode = touch_mode_valid;
|
||||
|
||||
// Already in correct mode, nothing to do.
|
||||
if ((touch_mode && touch_events_enabled_) ||
|
||||
(!touch_mode && !touch_events_enabled_))
|
||||
if (!touch_mode)
|
||||
return;
|
||||
|
||||
// Now we know that the window's current state doesn't match the desired
|
||||
// state. If we want touch mode, then we attempt to register for touch
|
||||
// events, and otherwise to unregister.
|
||||
if (touch_mode) {
|
||||
touch_mode = SetToTouchMode();
|
||||
}
|
||||
if (!touch_mode) {
|
||||
SetToGestureMode();
|
||||
touch_events_enabled_ = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
|
||||
|
||||
if (!touch_events_enabled_) {
|
||||
UnregisterTouchWindow(m_hWnd);
|
||||
// Single finger panning is consistent with other windows applications.
|
||||
const DWORD gesture_allow = GC_PAN_WITH_SINGLE_FINGER_VERTICALLY |
|
||||
GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
|
||||
const DWORD gesture_block = GC_PAN_WITH_GUTTER;
|
||||
GESTURECONFIG gc[] = {
|
||||
{ GID_ZOOM, GC_ZOOM, 0 },
|
||||
{ GID_PAN, gesture_allow , gesture_block},
|
||||
{ GID_TWOFINGERTAP, GC_TWOFINGERTAP , 0},
|
||||
{ GID_PRESSANDTAP, GC_PRESSANDTAP , 0}
|
||||
};
|
||||
if (!SetGestureConfig(m_hWnd, 0, arraysize(gc), gc, sizeof(GESTURECONFIG)))
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1270,13 +1245,7 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) {
|
||||
// scrolled when under the mouse pointer even if inactive.
|
||||
props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd));
|
||||
|
||||
bool touch_enabled = base::win::GetVersion() >= base::win::VERSION_WIN7 &&
|
||||
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTouchEvents);
|
||||
if (touch_enabled)
|
||||
SetToTouchMode();
|
||||
else
|
||||
SetToGestureMode();
|
||||
|
||||
UpdateDesiredTouchMode();
|
||||
UpdateIMEState();
|
||||
|
||||
return 0;
|
||||
|
@ -201,8 +201,7 @@ class RenderWidgetHostViewWin
|
||||
const base::Callback<void(bool)>& callback,
|
||||
skia::PlatformBitmap* output) OVERRIDE;
|
||||
virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE;
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
@ -407,15 +406,9 @@ class RenderWidgetHostViewWin
|
||||
// a WM_POINTERDOWN message.
|
||||
void ResetPointerDownContext();
|
||||
|
||||
// Switches between raw-touches mode and gesture mode. Currently touch mode
|
||||
// will only take effect when kEnableTouchEvents is in effect.
|
||||
void UpdateDesiredTouchMode(bool touch);
|
||||
|
||||
// Set window to receive gestures.
|
||||
void SetToGestureMode();
|
||||
|
||||
// Set window to raw touch events. Returns whether registering was successful.
|
||||
bool SetToTouchMode();
|
||||
// Sets the appropriate mode for raw-touches or gestures. Currently touch mode
|
||||
// will only take effect when kEnableTouchEvents is in effect (on Win7+).
|
||||
void UpdateDesiredTouchMode();
|
||||
|
||||
// Configures the enable/disable state of |ime_input_| to match with the
|
||||
// current |text_input_type_|.
|
||||
|
@ -156,8 +156,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase {
|
||||
virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE {}
|
||||
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
|
||||
#endif
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) OVERRIDE { }
|
||||
virtual void ProcessTouchAck(bool processed) OVERRIDE { }
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE { }
|
||||
virtual void SetScrollOffsetPinning(
|
||||
|
@ -263,8 +263,7 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView {
|
||||
// prevent-default on a dispatched touch event, the touch events are queued in
|
||||
// the GestureRecognizer until invocation of ProcessTouchAck releases it to be
|
||||
// processed (when |processed| is false) or ignored (when |processed| is true)
|
||||
virtual void ProcessTouchAck(WebKit::WebInputEvent::Type type,
|
||||
bool processed) = 0;
|
||||
virtual void ProcessTouchAck(bool processed) = 0;
|
||||
|
||||
// Asks the view to create a smooth scroll gesture that will be used to
|
||||
// simulate a user-initiated scroll.
|
||||
|
Reference in New Issue
Block a user