Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when rght-click the tray icon #211

Open
Zmax0 opened this issue Apr 23, 2024 · 0 comments
Open

NullPointerException when rght-click the tray icon #211

Zmax0 opened this issue Apr 23, 2024 · 0 comments

Comments

@Zmax0
Copy link

Zmax0 commented Apr 23, 2024

Hello,

resolution is 2880x1800 with 200% scaling

DEBUG [main] d.s.SystemTray - Version 4.4
DEBUG [main] d.s.SystemTray - OS: Windows 11
DEBUG [main] d.s.SystemTray - Arch: amd64
DEBUG [main] d.s.SystemTray - Oracle Corporation OpenJDK 64-Bit Server VM 21.0.2
DEBUG [main] d.s.SystemTray - JPMS enabled: true
DEBUG [main] d.s.SystemTray - Is Auto sizing tray/menu? true
DEBUG [main] d.s.SystemTray - Is JavaFX detected? false
DEBUG [main] d.s.SystemTray - Is SWT detected? false
DEBUG [main] d.s.SystemTray - Java Swing L&F: Metal
DEBUG [main] d.s.SystemTray - Auto-detecting tray type
DEBUG [main] d.s.SystemTray - Tray indicator image size: 24
DEBUG [main] d.s.SystemTray - Tray menu image size: 22
INFO [main] d.s.SystemTray - Successfully loaded type: _WindowsNativeTray
DEBUG [main] d.s.SystemTray - Resizing image-stream to 24
ERROR [WindowsEventDispatch_0] d.j.w.WindowsEventDispatch - Error during listener execution.
java.lang.NullPointerException: Cannot read field "y" because "bounds" is null
	at dorkbox.systemtray/dorkbox.systemTray.ui.swing.TrayPopup.doShow(TrayPopup.java:126)
	at dorkbox.systemtray/dorkbox.systemTray.ui.swing._WindowsNativeTray$4.run(_WindowsNativeTray.java:211)
	at dorkbox.jna/dorkbox.jna.windows.WindowsEventDispatch$1.callback(WindowsEventDispatch.java:166)
	at dorkbox.jna/dorkbox.jna.windows.User32_64.GetMessage(Native Method)
	at dorkbox.jna/dorkbox.jna.windows.WindowsEventDispatch.run(WindowsEventDispatch.java:190)
	at java.base/java.lang.Thread.run(Thread.java:1583)

mousePositionX = 2336; mousePositionY = 1754
xScalePtr.getValue() = 0, so result is infinity

    public static
    double dorkbox.systemTray.util.SizeAndScalingWindows#getDpiScaleForMouseClick(int mousePositionX, int mousePositionY) {
        WinDef.POINT.ByValue pointValue = new WinDef.POINT.ByValue(mousePositionX, mousePositionY);
        WinUser.HMONITOR monitorFromPoint = User32.User32.MonitorFromPoint(pointValue, WinUser.MONITOR_DEFAULTTONEAREST);

        // I don't know why this has 2 options, but the scale is always the same in both directions...
        IntByReference xScalePtr = new IntByReference();
        IntByReference yScalePtr = new IntByReference();
        ShCore.GetDpiForMonitor(monitorFromPoint, 0, xScalePtr, yScalePtr);

        // 96 is the default scale on windows
        return 96.0D / xScalePtr.getValue();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant