Skip to content

Commit b549a10

Browse files
committed
8372756: Mouse additional buttons and horizontal scrolling are broken on XWayland GNOME >= 47 after JDK-8351907
Backport-of: db2cd1a
1 parent 9f0c5be commit b549a10

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@
142142
import sun.awt.X11GraphicsEnvironment;
143143
import sun.awt.XSettings;
144144
import sun.awt.datatransfer.DataTransferer;
145-
import sun.awt.screencast.ScreencastHelper;
146-
import sun.awt.screencast.XdgDesktopPortal;
147145
import sun.awt.util.PerformanceLogger;
148146
import sun.awt.util.ThreadGroupUtils;
149147
import sun.font.FontConfigManager;
@@ -1567,21 +1565,16 @@ public int getNumberOfButtons(){
15671565
awtLock();
15681566
try {
15691567
if (numberOfButtons == 0) {
1570-
if (XdgDesktopPortal.isRemoteDesktop()
1571-
&& ScreencastHelper.isAvailable()) {
1568+
numberOfButtons = getNumberOfButtonsImpl();
1569+
numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED) ? MAX_BUTTONS_SUPPORTED : numberOfButtons;
1570+
//4th and 5th buttons are for wheel and shouldn't be reported as buttons.
1571+
//If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
1572+
//If we have 3 physical buttons and a wheel, we report 3 buttons.
1573+
//If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
1574+
if (numberOfButtons >= 5) {
1575+
numberOfButtons -= 2;
1576+
} else if (numberOfButtons == 4 || numberOfButtons == 5) {
15721577
numberOfButtons = 3;
1573-
} else {
1574-
numberOfButtons = getNumberOfButtonsImpl();
1575-
numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED) ? MAX_BUTTONS_SUPPORTED : numberOfButtons;
1576-
//4th and 5th buttons are for wheel and shouldn't be reported as buttons.
1577-
//If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
1578-
//If we have 3 physical buttons and a wheel, we report 3 buttons.
1579-
//If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
1580-
if (numberOfButtons >= 5) {
1581-
numberOfButtons -= 2;
1582-
} else if (numberOfButtons == 4 || numberOfButtons == 5) {
1583-
numberOfButtons = 3;
1584-
}
15851578
}
15861579
}
15871580
//Assume don't have to re-query the number again and again.

0 commit comments

Comments
 (0)