1
votes

Currently I develop a JavaFX application for the Raspberry Pi 3. For development on my PC I use Ubuntu 16.04.1, OpenJDK 1.8.0_111 and OpenJFX 8.0.60. For operation on the Raspberri Pi I use Raspbian Jessie with PIXEL (boot in console mode), OpenJDK 1.8.0_40 and OpenJFX 8.0.60.

A graphical mouse cursor is unnecessary, because the user should only interact with the application using a touch screen. Furthermore the mouse cursor is annoying, because it slightly covers the content of the screen. In addition it irritates the user by changing its position whenever the screen is touched. Therefore I want to hide the mouse cursor on the screen.

On my PC I am able to hide the mouse cursor using the following code:

scene.setCursor(Cursor.NONE);

I start the application on the Raspberry Pi from bash shell using

java -jar MyApp.jar

After doing so the setCurser property works initially. But after touching the screen or moving the mouse the default mouse cursor appears on the screen. This seems to be an unresolved problem: Post on raspberrypi.org forum

The OpenJFX Wiki says:

Note that the default configuration of JavaFX on the Raspberry Pi does not use X11. Instead JavaFX works directly with the display framebuffer and input devices. So you should not have the X11 desktop running when starting JavaFX.

As a workaround, how can I hide the graphical mouse cursor in the framebuffer on Raspbian Jessie?

2

2 Answers

1
votes

I've found workaround for this bug. Though it creates some flickering at the start of my application it is acceptable in my case. (Also you could try to turn backlight off during program start ) Here is the magic code(the cure effect was discovered accidentally working with several full screen windows)

private void fixMouse(Stage primaryStage)
    {
        Platform.runLater(()->{
            //Show mouse cursor
            Robot robot = com.sun.glass.ui.Application.GetApplication().createRobot();

            robot.mouseMove(790,470);
            robot.destroy();

            //Show fullscreen dialog
            final Stage dialog = new Stage();
            dialog.initModality(Modality.APPLICATION_MODAL);
            dialog.initOwner(primaryStage);

            StackPane dialogLayout = new StackPane();
            dialog.setFullScreen(true);
            dialog.setResizable(false);
            dialog.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

            Scene dialogScene = new Scene(dialogLayout, 0, 0);
            dialogScene.setCursor(Cursor.NONE);
            dialogScene.setFill(Color.BLACK);
            dialogLayout.setBackground(Background.EMPTY);

            dialog.setScene(dialogScene);
            dialog.show();

            // Auto close the dialog
            Platform.runLater(()->{
                        dialog.close();
                        primaryStage.setFullScreen(true);
                    });
            });
    }
0
votes

For anyone who stumbled upon this question while searching:

I was able to fix the problem by decompiling jfxrt.jar and changing one line in the class com.sun.glass.ui.monocle.DispmanCursor. I decompiled it with BytecodeViewer, changed the setVisibility method to always set false value and saved as jar. (Yes, the more proper way would be to build openjfx from source, but it's way faster this way for such a small change) If anyone knows a way to get an instance of DispmanCursor from code to use the method (although it's package local, so I doubt there's a way) -- let me know. decompiled DispmanCursor The other fix I added was changing com.sun.glass.ui.monocle.AcceleratedScreen -- it has hardcoded library names that have been changed since then: libGLESv2.so and libEGL.so are now called libbrcmGLESv2.so and libbrcmEGL.so respectively (see this thread for more information).

Here's the final fixed jfxrt.jar.