Index: ui/views/win/hwnd_message_handler.cc |
=================================================================== |
--- ui/views/win/hwnd_message_handler.cc (revision 243629) |
+++ ui/views/win/hwnd_message_handler.cc (working copy) |
@@ -299,6 +299,24 @@ |
// 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)) { |
+ DCHECK(IsTopLevelWindow(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 |
@@ -1343,6 +1361,21 @@ |
delegate_->HandleCreate(); |
+#if defined(USE_AURA) |
sky
2014/01/10 16:43:21
Can this be moved to CalculateWindowStylesFromInit
ananta
2014/01/10 18:59:21
Done.
|
+ // 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 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 (IsTopLevelWindow(hwnd())) { |
+ long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
+ ::SetWindowLong(hwnd(), GWL_STYLE, |
+ current_style | WS_VSCROLL | WS_HSCROLL); |
+ } |
+#endif |
// TODO(beng): move more of NWW::OnCreate here. |
return 0; |
} |
@@ -2042,6 +2075,23 @@ |
// 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) |
+ // As documented in the HWNDMessageHandler::OnCreate function, we add the |
+ // WS_VSCROLL and WS_HSCROLL styles to the window to ensure that legacy track |
+ // pad/trackpoint drivers generate the WM_VSCROLL and WM_HSCROLL messages. |
+ // 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 |
sky
2014/01/10 16:43:21
Could we instead set the scrollbar sizes to 0?
ananta
2014/01/10 18:59:21
Tricky to do that. The non AURA code did this in t
|
+ // and readd them to the window style in a posted task which works. |
+ if (IsTopLevelWindow(hwnd())) { |
+ BOOL visible = ::IsWindowVisible(hwnd()); |
+ ShowScrollBar(hwnd(), SB_BOTH, FALSE); |
+ long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&AddScrollStylesToWindow, hwnd())); |
+#endif |
+ } |
} |
void HWNDMessageHandler::OnSysCommand(UINT notification_code, |
@@ -2255,6 +2305,15 @@ |
SetMsgHandled(FALSE); |
} |
+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; |
+} |
+ |
void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
for (size_t i = 0; i < touch_events.size() && ref; ++i) |