Chromium Code Reviews (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out

Unified Diff: ui/gfx/win/direct_manipulation.h

Issue 1283913002: Improve scroll performance on Windows 10 with high precision touchpads. (Closed) Base URL:
Patch Set: Address review comments Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/win/ » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/win/direct_manipulation.h
diff --git a/ui/gfx/win/direct_manipulation.h b/ui/gfx/win/direct_manipulation.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6053b1baaee165ea321422ef04f47b4a999dee4
--- /dev/null
+++ b/ui/gfx/win/direct_manipulation.h
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#include <directmanipulation.h>
+#include "base/win/scoped_comptr.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/gfx_export.h"
+namespace gfx {
+namespace win {
+// Windows 10 provides a new API called Direct Manipulation which generates
+// smooth scroll events via WM_MOUSEWHEEL messages with predictable deltas
+// on high precision touch pads. This basically requires the application window
+// to register as a Direct Manipulation consumer. The way mouse wheel messages
+// are dispatched is
+// 1. The foreground window is checked to see if it is a Direct Manipulation
+// consumer.
+// 2. If it is then Direct Manipulation takes over and sends the following
+// 3. It then posts WM_MOUSEWHEEL messages with precision deltas which vary
+// based on the amount of the scroll.
+// 4. If the foreground window is not a Direct Manipulation consumer, it
+// then takes a fallback route where it posts WM_MOUSEWHEEL messages
+// with precision but varying deltas to the window. There is a also
+// a slight delay in receiving the first set of mouse wheel messages.
+// This causes scrolling to appear janky and jumpy.
+// Our approach for addressing this is to do the absolute minimum to
+// register our window as a Direct Manipulation consumer. This class
+// provides the necessary functionality to register the passed in HWND as a
+// Direct Manipulation consumer. We don't rely on Direct manipulation
+// to do the smooth scrolling in the background thread as documented on
+// msdn.
+class GFX_EXPORT DirectManipulationHelper {
+ public:
+ // Creates an instance of this class if Direct Manipulation is enabled on
+ // the platform. If not returns NULL.
+ static DirectManipulationHelper* CreateInstance();
+ // This function instantiates Direct Manipulation and creates a viewport for
+ // the passed in |window|.
+ // consumer. Most of the code is boiler plate and is based on the sample.
+ void Initialize(HWND window);
+ // Sets the bounds of the fake Direct manipulation viewport to match those
+ // of the legacy window.
+ void SetBounds(const gfx::Rect& bounds);
+ // Registers the passed in |window| as a Direct Manipulation consumer.
+ void Activate(HWND window);
+ // Passes the WM_MOUSEWHEEL messages to Direct Manipulation. This is for
+ // logistics purposes.
+ void HandleMouseWheel(HWND window, UINT message, WPARAM w_param,
+ LPARAM l_param);
+ private:
+ DirectManipulationHelper() {}
+ base::win::ScopedComPtr<IDirectManipulationManager2> manager_;
+ base::win::ScopedComPtr<IDirectManipulationCompositor> compositor_;
+ base::win::ScopedComPtr<IDirectManipulationUpdateManager> update_manager_;
+ base::win::ScopedComPtr<IDirectManipulationFrameInfoProvider> frame_info_;
+ base::win::ScopedComPtr<IDirectManipulationViewport2> view_port_outer_;
+ DISALLOW_COPY_AND_ASSIGN(DirectManipulationHelper);
+} // namespace win
+} // namespace gfx
« no previous file with comments | « ui/gfx/gfx.gyp ('k') | ui/gfx/win/ » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698