--- old/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2015-04-24 17:32:10.559361300 +0400 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2015-04-24 17:32:09.791317400 +0400 @@ -1198,6 +1198,7 @@ WIN_MSG(WM_XBUTTONDBLCLK) WIN_MSG(WM_XBUTTONDOWN) WIN_MSG(WM_XBUTTONUP) + WIN_MSG(WM_MOUSEHWHEEL) WIN_MSG(WM_MOUSEWHEEL) WIN_MSG(WM_PARENTNOTIFY) WIN_MSG(WM_ENTERMENULOOP) @@ -1629,6 +1630,7 @@ case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_MOUSEMOVE: + case WM_MOUSEHWHEEL: case WM_MOUSEWHEEL: case WM_AWT_MOUSEENTER: case WM_AWT_MOUSEEXIT: @@ -1637,6 +1639,8 @@ myPos.x = GET_X_LPARAM(curPos); myPos.y = GET_Y_LPARAM(curPos); ::ScreenToClient(GetHWnd(), &myPos); + BOOL hMouseWheel; + hMouseWheel = FALSE; switch(switchMessage) { case WM_AWT_MOUSEENTER: mr = WmMouseEnter(static_cast(wParam), myPos.x, myPos.y); @@ -1699,10 +1703,12 @@ case WM_AWT_MOUSEEXIT: mr = WmMouseExit(static_cast(wParam), myPos.x, myPos.y); break; + case WM_MOUSEHWHEEL: + hMouseWheel = TRUE; case WM_MOUSEWHEEL: mr = WmMouseWheel(GET_KEYSTATE_WPARAM(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), - GET_WHEEL_DELTA_WPARAM(wParam)); + GET_WHEEL_DELTA_WPARAM(wParam), hMouseWheel); break; } break; @@ -2449,7 +2455,7 @@ } MsgRouting AwtComponent::WmMouseWheel(UINT flags, int x, int y, - int wheelRotation) + int wheelRotation, BOOL hMouseWheel) { // convert coordinates to be Component-relative, not screen relative // for wheeling when outside the window, this works similar to @@ -2494,8 +2500,12 @@ DTRACE_PRINTLN("calling SendMouseWheelEvent"); + jint modifiers = GetJavaModifiers(); + if (hMouseWheel) { + modifiers |= java_awt_event_InputEvent_SHIFT_DOWN_MASK; + } SendMouseWheelEvent(java_awt_event_MouseEvent_MOUSE_WHEEL, ::JVM_CurrentTimeMillis(NULL, 0), - eventPt.x, eventPt.y, GetJavaModifiers(), 0, 0, scrollType, + eventPt.x, eventPt.y, modifiers, 0, 0, scrollType, scrollLines, roundedWheelRotation, preciseWheelRotation, &msg); m_wheelRotationAmount %= WHEEL_DELTA; --- old/src/java.desktop/windows/native/libawt/windows/awt_Component.h 2015-04-24 17:32:15.411638800 +0400 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Component.h 2015-04-24 17:32:14.464584700 +0400 @@ -521,7 +521,7 @@ virtual MsgRouting WmMouseMove(UINT flags, int x, int y); virtual MsgRouting WmMouseExit(UINT flags, int x, int y); virtual MsgRouting WmMouseWheel(UINT flags, int x, int y, - int wheelRotation); + int wheelRotation, BOOL hMouseWheel); virtual MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button); virtual MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button); virtual MsgRouting WmWindowPosChanging(LPARAM windowPos); --- old/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2015-04-24 17:32:20.612936300 +0400 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp 2015-04-24 17:32:19.534874700 +0400 @@ -1510,7 +1510,7 @@ * the mouse, not the Component with the input focus. */ - if (msg.message == WM_MOUSEWHEEL) { + if (msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL) { //i.e. mouse is over client area for this window DWORD hWndForWheelProcess; DWORD hWndForWheelThread = ::GetWindowThreadProcessId(hWndForWheel, &hWndForWheelProcess); --- old/src/java.desktop/windows/native/libawt/windows/awtmsg.h 2015-04-24 17:32:25.499215800 +0400 +++ new/src/java.desktop/windows/native/libawt/windows/awtmsg.h 2015-04-24 17:32:24.574162900 +0400 @@ -45,6 +45,10 @@ #define WM_MOUSEWHEEL 0x020A #endif //WM_MOUSEWHEEL +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif //WM_MOUSEHWHEEL + #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 #endif //WHEEL_DELTA --- /dev/null 2015-04-24 17:32:31.000000000 +0400 +++ new/test/java/awt/Mouse/MouseHorizontalWheel/MouseHorizontalWheelTest.html 2015-04-24 17:32:30.024474600 +0400 @@ -0,0 +1,38 @@ + + + + + +Verify that horizontal scrolling in a JScrollPane works with a touchpad. + +If the system does not support touchpad press PASS. + +1. Move the mouse cursor to the text area +2. Make a horizontal scroll gesture on the touchpad +3. Check that the text area is scrolled horizontally + + + + + --- /dev/null 2015-04-24 17:32:35.000000000 +0400 +++ new/test/java/awt/Mouse/MouseHorizontalWheel/MouseHorizontalWheelTest.java 2015-04-24 17:32:34.128709400 +0400 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JApplet; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +/* @test + * @bug 8052123 + * @summary Horizontal scrolling not possible with touchpad with Metal and + * Nimbus L&F + * @author Alexander Scherbatiy + * @run applet/manual=yesno MouseHorizontalWheelTest.html + */ +public class MouseHorizontalWheelTest extends JApplet { + + @Override + public void init() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + JTextArea textArea = new JTextArea(30, 50); + textArea.setText("Hello World!"); + + JScrollPane scrollPane = new JScrollPane(textArea); + add(scrollPane); + } + }); + } +}