| Index: ui/views/win/hwnd_message_handler.cc
|
| ===================================================================
|
| --- ui/views/win/hwnd_message_handler.cc (revision 244297)
|
| +++ 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
|
| @@ -389,7 +405,8 @@
|
| can_update_layered_window_(true),
|
| is_first_nccalc_(true),
|
| autohide_factory_(this),
|
| - id_generator_(0) {
|
| + id_generator_(0),
|
| + scroll_styles_set_(false) {
|
| }
|
|
|
| HWNDMessageHandler::~HWNDMessageHandler() {
|
| @@ -1324,6 +1341,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;
|
| }
|
| @@ -1925,6 +1961,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) {
|
| @@ -2002,6 +2047,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,
|
|
|