JetBrains Runtime Issue with Touch Events on Windows
Dear JetBrains Team,
I develop the open-source mind map editor Freeplane. Recently, I embedded JetBrains Java Runtime into the Windows version due to its better emoji font support. However, during preview testing, a user reported losing touch functionality with their Surface Pro 7, affecting both pen and finger inputs.
To investigate, I wrote a minimal Java app to log mouse events. Testing revealed the following:
- Using Azul Zulu Java Runtime v21.0.5, touch inputs were correctly mapped to mouse events.
- With JetBrains Runtime 21.0.5b509.30 and 21.0.5b631.16, only pure mouse events were logged; no touch events were detected.
The app requires the following Java option:
--add-exports java.desktop/sun.awt=ALL-UNNAMED
This is necessary to access the internal sun.awt APIs, specifically for detecting whether a MouseEvent was caused by a touch event.
Code:
package com.example;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.logging.Logger;
import sun.awt.AWTAccessor;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TouchMouseEventExample {
private static final Logger logger = Logger.getLogger(TouchMouseEventExample.class.getName());
public static void main(String[] args) {
logger.info("Java Version: " + System.getProperty("java.version"));
logger.info("Java Vendor: " + System.getProperty("java.vendor"));
JFrame frame = new JFrame("Touch Event Simulation");
JPanel panel = new JPanel();
panel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
printEvent(e);
}
@Override
public void mouseReleased(MouseEvent e) {
printEvent(e);
}
@Override
public void mouseClicked(MouseEvent e) {
printEvent(e);
}
});
panel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
printEvent(e);
}
});
frame.add(panel);
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
private static void printEvent(MouseEvent e) {
boolean isCausedByTouchEvent = AWTAccessor.getMouseEventAccessor().isCausedByTouchEvent(e);
logger.info(e.toString() + "\n"
+ "Modifiers: " + e.getModifiersEx() + (isCausedByTouchEvent ? "caused by Touch Event" : ""));
}
}
System Details:
- OS: Windows 11 Home, Version 10.0.26100, Italian localization
- Device: Microsoft Surface Pro 7
- CPU: Intel Core i5-1035G4, 4 cores, 8 logical processors
Relationship to Existing Issues:
This issue seems related to the previously reported https://github.com/JetBrains/JetBrainsRuntime/issues/467. It demonstrates that the problem is broader and not tied to a specific library. The findings can extend and complement the existing YouTrack issue JBR-7716, created by @vprovodin, to address issue #467.
I kindly request that this issue be given higher priority due to its significant impact on Java applications running on devices with touch input.
Best regards, Dimitry Polivaev
I can confirm a similar issue with JBR 21.0.6 x64 on Windows 11 and Ubuntu 22.04.
Single touch events are reported as mouse events. But touch & drag is not reported at all.
In comparison, Oracle JDK 1.8, and Amazon Coretto 1.8 do what I expect. Dragging on the touch screen was reported as mousePressed(), mouseDragged() and mouseReleased().
any help is appreciated, -- Peter
just did some more experimenting: the bug affects all versions of JBR 21, from b346 to b872
it does not affect Oracle JDK 21, 23, Azul Zulu 21.