Chromium Code Reviews| Index: ui/views/win/hwnd_message_handler.cc |
| =================================================================== |
| --- ui/views/win/hwnd_message_handler.cc (revision 244605) |
| +++ ui/views/win/hwnd_message_handler.cc (working copy) |
| @@ -315,6 +315,13 @@ |
| } |
| } |
| +void HideWindowsScrollBar(HWND window) { |
| + ShowScrollBar(window, SB_BOTH, FALSE); |
| + base::MessageLoop::current()->PostTask( |
|
sky
2014/01/15 15:41:32
Document why the post task.
ananta
2014/01/15 16:54:58
Done.
|
| + FROM_HERE, |
| + base::Bind(&AddScrollStylesToWindow, window)); |
| +} |
| + |
| } // namespace |
| // A scoping class that prevents a window from being able to redraw in response |
| @@ -407,7 +414,8 @@ |
| menu_depth_(0), |
| autohide_factory_(this), |
| id_generator_(0), |
| - scroll_styles_set_(false) { |
| + scroll_styles_set_(false), |
| + size_move_loop_(false) { |
| } |
| HWNDMessageHandler::~HWNDMessageHandler() { |
| @@ -424,6 +432,28 @@ |
| // Create the window. |
| WindowImpl::Init(parent, bounds); |
| + |
| +#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); |
| + if (!(current_style & WS_POPUP)) { |
| + ::SetWindowLong(hwnd(), GWL_STYLE, |
|
sky
2014/01/15 15:41:32
Can you use AddScrollStylesToWindow?
ananta
2014/01/15 16:54:58
Done.
|
| + current_style | WS_VSCROLL | WS_HSCROLL); |
| + scroll_styles_set_ = true; |
|
sky
2014/01/15 15:41:32
How about naming this needs_scroll_styles_?
ananta
2014/01/15 16:54:58
Done.
|
| + } |
| + } |
| +#endif |
| } |
| void HWNDMessageHandler::InitModalType(ui::ModalType modal_type) { |
| @@ -1366,25 +1396,6 @@ |
| 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; |
| } |
| @@ -1416,6 +1427,7 @@ |
| } |
| void HWNDMessageHandler::OnEnterSizeMove() { |
| + size_move_loop_ = true; |
| delegate_->HandleBeginWMSizeMove(); |
| SetMsgHandled(FALSE); |
| } |
| @@ -1434,6 +1446,11 @@ |
| void HWNDMessageHandler::OnExitSizeMove() { |
| delegate_->HandleEndWMSizeMove(); |
| SetMsgHandled(FALSE); |
| + size_move_loop_ = false; |
| + // Please refer to the notes in the OnSize function for information about |
| + // the scrolling hack. |
| + if (scroll_styles_set_) |
| + HideWindowsScrollBar(hwnd()); |
| } |
| void HWNDMessageHandler::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { |
| @@ -2101,13 +2118,11 @@ |
| // 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())); |
| + // If we are in the context of a size loop operation, we do this when the |
| + // sizing operation completes. |
| + if (scroll_styles_set_ && !size_move_loop_) |
| + HideWindowsScrollBar(hwnd()); |
| #endif |
| - } |
| } |
| void HWNDMessageHandler::OnSysCommand(UINT notification_code, |