Chromium Code Reviews| 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) { |
|
sky
2014/01/10 19:18:42
Is this still needed? Can't you key off the styles
ananta
2014/01/10 20:05:36
Removed. Added a member flag
|
| + 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 |
| @@ -1965,6 +1983,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 +2069,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) |
| + // 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 (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, |