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

Side by Side Diff: ui/gfx/win/direct_manipulation.cc

Issue 1283913002: Improve scroll performance on Windows 10 with high precision touchpads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't pass wheel messages to DirectManipulation from views if it is coming from the child 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/win/direct_manipulation.h"
6
7 #include "base/basictypes.h"
8 #include "base/win/windows_version.h"
9
10 namespace gfx {
11 namespace win {
12
13 // static
14 DirectManipulationHelper* DirectManipulationHelper::CreateInstance() {
15 if (base::win::GetVersion() >= base::win::VERSION_WIN10)
16 return new DirectManipulationHelper;
17 return NULL;
sky 2015/08/11 23:45:02 nullptr
ananta 2015/08/12 00:41:58 Not needed anymore with the function returning a s
18 }
19
20 void DirectManipulationHelper::Initialize(HWND window) {
21 DCHECK(::IsWindow(window));
22
23 // TODO(ananta)
24 // Remove the CHECK statements here and below and replace them with logs
25 // when this code stabilizes.
26 HRESULT hr = manager_.CreateInstance(CLSID_DirectManipulationManager,
27 nullptr, CLSCTX_INPROC_SERVER);
28 CHECK(SUCCEEDED(hr));
29
30 hr = compositor_.CreateInstance(CLSID_DCompManipulationCompositor,
31 nullptr, CLSCTX_INPROC_SERVER);
32 CHECK(SUCCEEDED(hr));
33
34 hr = manager_->GetUpdateManager(IID_PPV_ARGS(update_manager_.Receive()));
35 CHECK(SUCCEEDED(hr));
36
37 hr = compositor_->SetUpdateManager(update_manager_.get());
38 CHECK(SUCCEEDED(hr));
39
40 hr = frame_info_.QueryFrom(compositor_.get());
41 CHECK(SUCCEEDED(hr));
42
43 hr = manager_->CreateViewport(frame_info_.get(), window,
44 IID_PPV_ARGS(view_port_outer_.Receive()));
45 CHECK(SUCCEEDED(hr));
46
47 //
48 // Enable the desired configuration for each viewport.
49 //
50 DIRECTMANIPULATION_CONFIGURATION configuration =
51 DIRECTMANIPULATION_CONFIGURATION_INTERACTION
52 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_X
53 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_Y
54 | DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA
55 | DIRECTMANIPULATION_CONFIGURATION_RAILS_X
56 | DIRECTMANIPULATION_CONFIGURATION_RAILS_Y
57 | DIRECTMANIPULATION_CONFIGURATION_SCALING
58 | DIRECTMANIPULATION_CONFIGURATION_SCALING_INERTIA;
59
60 hr = view_port_outer_->ActivateConfiguration(configuration);
61 CHECK(SUCCEEDED(hr));
62 }
63
64 void DirectManipulationHelper::SetBounds(const gfx::Rect& bounds) {
65 base::win::ScopedComPtr<IDirectManipulationPrimaryContent>
66 primary_content_outer;
67 HRESULT hr = view_port_outer_->GetPrimaryContent(
68 IID_PPV_ARGS(primary_content_outer.Receive()));
69 CHECK(SUCCEEDED(hr));
70
71 base::win::ScopedComPtr<IDirectManipulationContent> content_outer;
72 hr = content_outer.QueryFrom(primary_content_outer.get());
73 CHECK(SUCCEEDED(hr));
74
75 RECT rect = bounds.ToRECT();
76
77 hr = view_port_outer_->SetViewportRect(&rect);
78 CHECK(SUCCEEDED(hr));
79
80 hr = content_outer->SetContentRect(&rect);
81 CHECK(SUCCEEDED(hr));
82 }
83
84 void DirectManipulationHelper::Activate(HWND window) {
85 DCHECK(::IsWindow(window));
86 HRESULT hr = manager_->Activate(window);
87 CHECK(SUCCEEDED(hr));
88 }
89
90 void DirectManipulationHelper:: HandleMouseWheel(HWND window, UINT message,
91 WPARAM w_param, LPARAM l_param) {
92 MSG msg = { window, message, w_param, l_param};
93
94 HRESULT hr = view_port_outer_->SetContact(DIRECTMANIPULATION_MOUSEFOCUS);
95 if (SUCCEEDED(hr)) {
96 BOOL handled = FALSE;
97 manager_->ProcessInput(&msg, &handled);
98 view_port_outer_->ReleaseContact(DIRECTMANIPULATION_MOUSEFOCUS);
99 }
100 }
101
102 } // namespace win.
103 } // namespace gfx.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698