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

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 133053004: Ensure that trackpad and trackpoint scrolling works on Windows desktop Aura with legacy trackpad dr… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 11 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/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
===================================================================
--- ui/views/win/hwnd_message_handler.cc (revision 244237)
+++ ui/views/win/hwnd_message_handler.cc (working copy)
@@ -299,6 +299,22 @@
// The thickness of an auto-hide taskbar in pixels.
const int kAutoHideTaskbarThicknessPx = 2;
+bool IsTopLevelWindow(HWND window) {
+ long style = ::GetWindowLong(window, GWL_STYLE);
+ if (!(style & WS_CHILD))
+ return true;
+ HWND parent = ::GetParent(window);
+ return !parent || (parent == ::GetDesktopWindow());
+}
+
+void AddScrollStylesToWindow(HWND window) {
+ if (::IsWindow(window)) {
+ long current_style = ::GetWindowLong(window, GWL_STYLE);
+ ::SetWindowLong(window, GWL_STYLE,
+ current_style | WS_VSCROLL | WS_HSCROLL);
+ }
+}
+
} // namespace
// A scoping class that prevents a window from being able to redraw in response
@@ -390,7 +406,8 @@
is_first_nccalc_(true),
menu_depth_(0),
autohide_factory_(this),
- id_generator_(0) {
+ id_generator_(0),
+ scroll_styles_set_(false) {
}
HWNDMessageHandler::~HWNDMessageHandler() {
@@ -1343,6 +1360,25 @@
delegate_->HandleCreate();
+#if defined(USE_AURA)
+ // Certain trackpad drivers on Windows have bugs where in they don't generate
+ // WM_MOUSEWHEEL messages for the trackpoint and trackpad scrolling gestures
+ // unless there is an entry for Chrome with the class name of the Window.
+ // These drivers check if the window under the trackpoint has the WS_VSCROLL/
+ // WS_HSCROLL style and if yes they generate the legacy WM_VSCROLL/WM_HSCROLL
+ // messages. We add these styles to ensure that trackpad/trackpoint scrolling
+ // work.
+ // TODO(ananta)
+ // Look into moving the WS_VSCROLL and WS_HSCROLL style setting logic to the
+ // CalculateWindowStylesFromInitParams function. Doing it there seems to
+ // cause some interactive tests to fail. Investigation needed.
+ if (IsTopLevelWindow(hwnd())) {
+ long current_style = ::GetWindowLong(hwnd(), GWL_STYLE);
+ ::SetWindowLong(hwnd(), GWL_STYLE,
+ current_style | WS_VSCROLL | WS_HSCROLL);
+ scroll_styles_set_ = true;
+ }
+#endif
// TODO(beng): move more of NWW::OnCreate here.
return 0;
}
@@ -1965,6 +2001,15 @@
return 0;
}
+LRESULT HWNDMessageHandler::OnScrollMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
+ MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime() };
+ ui::ScrollEvent event(msg);
+ delegate_->HandleScrollEvent(event);
+ return 0;
+}
+
LRESULT HWNDMessageHandler::OnSetCursor(UINT message,
WPARAM w_param,
LPARAM l_param) {
@@ -2042,6 +2087,21 @@
// ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
// invoked OnSize we ensure the RootView has been laid out.
ResetWindowRegion(false, true);
+
+#if defined(USE_AURA)
+ // We add the WS_VSCROLL and WS_HSCROLL styles to top level windows to ensure
+ // that legacy trackpad/trackpoint drivers generate the WM_VSCROLL and
+ // WM_HSCROLL messages and scrolling works.
+ // We want the style to be present on the window. However we don't want
+ // Windows to draw the scrollbars. To achieve this we hide the scroll bars
+ // and readd them to the window style in a posted task which works.
+ if (scroll_styles_set_) {
+ ShowScrollBar(hwnd(), SB_BOTH, FALSE);
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&AddScrollStylesToWindow, hwnd()));
+#endif
+ }
}
void HWNDMessageHandler::OnSysCommand(UINT notification_code,
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698