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

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