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

Side by Side Diff: ui/views/win/hwnd_message_handler.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: 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 unified diff | Download patch
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <oleacc.h> 8 #include <oleacc.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 10
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (!(current_style & WS_POPUP)) { 365 if (!(current_style & WS_POPUP)) {
366 AddScrollStylesToWindow(hwnd()); 366 AddScrollStylesToWindow(hwnd());
367 needs_scroll_styles_ = true; 367 needs_scroll_styles_ = true;
368 } 368 }
369 } 369 }
370 #endif 370 #endif
371 371
372 prop_window_target_.reset(new ui::ViewProp(hwnd(), 372 prop_window_target_.reset(new ui::ViewProp(hwnd(),
373 ui::WindowEventTarget::kWin32InputEventTarget, 373 ui::WindowEventTarget::kWin32InputEventTarget,
374 static_cast<ui::WindowEventTarget*>(this))); 374 static_cast<ui::WindowEventTarget*>(this)));
375
376 // Direct Manipulation is enabled on Windows 10+. The CreateInstance function
377 // returns NULL if Direct Manipulation is not available.
378 direct_manipulation_helper_.reset(
379 gfx::win::DirectManipulationHelper::CreateInstance());
380 if (direct_manipulation_helper_)
381 direct_manipulation_helper_->Initialize(hwnd());
375 } 382 }
376 383
377 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { 384 void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) {
378 if (modal_type == ui::MODAL_TYPE_NONE) 385 if (modal_type == ui::MODAL_TYPE_NONE)
379 return; 386 return;
380 // We implement modality by crawling up the hierarchy of windows starting 387 // We implement modality by crawling up the hierarchy of windows starting
381 // at the owner, disabling all of them so that they don't receive input 388 // at the owner, disabling all of them so that they don't receive input
382 // messages. 389 // messages.
383 HWND start = ::GetWindow(hwnd(), GW_OWNER); 390 HWND start = ::GetWindow(hwnd(), GW_OWNER);
384 while (start) { 391 while (start) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 bounds_in_pixels.width(), bounds_in_pixels.height(), 513 bounds_in_pixels.width(), bounds_in_pixels.height(),
507 SWP_NOACTIVATE | SWP_NOZORDER); 514 SWP_NOACTIVATE | SWP_NOZORDER);
508 515
509 // If HWND size is not changed, we will not receive standard size change 516 // If HWND size is not changed, we will not receive standard size change
510 // notifications. If |force_size_changed| is |true|, we should pretend size is 517 // notifications. If |force_size_changed| is |true|, we should pretend size is
511 // changed. 518 // changed.
512 if (old_size == bounds_in_pixels.size() && force_size_changed) { 519 if (old_size == bounds_in_pixels.size() && force_size_changed) {
513 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); 520 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size());
514 ResetWindowRegion(false, true); 521 ResetWindowRegion(false, true);
515 } 522 }
523
524 if (direct_manipulation_helper_)
525 direct_manipulation_helper_->SetBounds(bounds_in_pixels);
516 } 526 }
517 527
518 void HWNDMessageHandler::SetSize(const gfx::Size& size) { 528 void HWNDMessageHandler::SetSize(const gfx::Size& size) {
519 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), 529 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(),
520 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 530 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
521 } 531 }
522 532
523 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { 533 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) {
524 HWND parent = GetParent(hwnd()); 534 HWND parent = GetParent(hwnd());
525 if (!IsWindow(hwnd())) 535 if (!IsWindow(hwnd()))
(...skipping 21 matching lines...) Expand all
547 557
548 void HWNDMessageHandler::Show() { 558 void HWNDMessageHandler::Show() {
549 if (IsWindow(hwnd())) { 559 if (IsWindow(hwnd())) {
550 if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) && 560 if (!(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_TRANSPARENT) &&
551 !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) { 561 !(GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE)) {
552 ShowWindowWithState(ui::SHOW_STATE_NORMAL); 562 ShowWindowWithState(ui::SHOW_STATE_NORMAL);
553 } else { 563 } else {
554 ShowWindowWithState(ui::SHOW_STATE_INACTIVE); 564 ShowWindowWithState(ui::SHOW_STATE_INACTIVE);
555 } 565 }
556 } 566 }
567 if (direct_manipulation_helper_)
568 direct_manipulation_helper_->Activate(hwnd());
557 } 569 }
558 570
559 void HWNDMessageHandler::ShowWindowWithState(ui::WindowShowState show_state) { 571 void HWNDMessageHandler::ShowWindowWithState(ui::WindowShowState show_state) {
560 TRACE_EVENT0("views", "HWNDMessageHandler::ShowWindowWithState"); 572 TRACE_EVENT0("views", "HWNDMessageHandler::ShowWindowWithState");
561 DWORD native_show_state; 573 DWORD native_show_state;
562 switch (show_state) { 574 switch (show_state) {
563 case ui::SHOW_STATE_INACTIVE: 575 case ui::SHOW_STATE_INACTIVE:
564 native_show_state = SW_SHOWNOACTIVATE; 576 native_show_state = SW_SHOWNOACTIVATE;
565 break; 577 break;
566 case ui::SHOW_STATE_MAXIMIZED: 578 case ui::SHOW_STATE_MAXIMIZED:
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 2676 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
2665 bool handled = delegate_->HandleMouseEvent(event); 2677 bool handled = delegate_->HandleMouseEvent(event);
2666 2678
2667 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. 2679 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
2668 tracked_objects::ScopedTracker tracking_profile8( 2680 tracked_objects::ScopedTracker tracking_profile8(
2669 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2681 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2670 "440919 HWNDMessageHandler::HandleMouseEventInternal8")); 2682 "440919 HWNDMessageHandler::HandleMouseEventInternal8"));
2671 2683
2672 if (!ref.get()) 2684 if (!ref.get())
2673 return 0; 2685 return 0;
2686
2687 if (direct_manipulation_helper_ &&
2688 (message == WM_MOUSEWHEEL || message == WM_MOUSEHWHEEL)) {
2689 direct_manipulation_helper_->HandleMouseWheel(hwnd(), message, w_param,
2690 l_param);
2691 }
2692
2674 if (!handled && message == WM_NCLBUTTONDOWN && w_param != HTSYSMENU && 2693 if (!handled && message == WM_NCLBUTTONDOWN && w_param != HTSYSMENU &&
2675 delegate_->IsUsingCustomFrame()) { 2694 delegate_->IsUsingCustomFrame()) {
2676 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. 2695 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed.
2677 tracked_objects::ScopedTracker tracking_profile9( 2696 tracked_objects::ScopedTracker tracking_profile9(
2678 FROM_HERE_WITH_EXPLICIT_FUNCTION( 2697 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2679 "440919 HWNDMessageHandler::HandleMouseEventInternal9")); 2698 "440919 HWNDMessageHandler::HandleMouseEventInternal9"));
2680 2699
2681 // TODO(msw): Eliminate undesired painting, or re-evaluate this workaround. 2700 // TODO(msw): Eliminate undesired painting, or re-evaluate this workaround.
2682 // DefWindowProc for WM_NCLBUTTONDOWN does weird non-client painting, so we 2701 // DefWindowProc for WM_NCLBUTTONDOWN does weird non-client painting, so we
2683 // need to call it inside a ScopedRedrawLock. This may cause other negative 2702 // need to call it inside a ScopedRedrawLock. This may cause other negative
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); 2759 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
2741 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); 2760 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
2742 } 2761 }
2743 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 2762 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
2744 // to notify our children too, since we can have MDI child windows who need to 2763 // to notify our children too, since we can have MDI child windows who need to
2745 // update their appearance. 2764 // update their appearance.
2746 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); 2765 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
2747 } 2766 }
2748 2767
2749 } // namespace views 2768 } // namespace views
OLDNEW
« no previous file with comments | « 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