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

Several problems with the GUI-behaviour on a two-screen setup #166

Closed
erl987 opened this issue Sep 2, 2020 · 6 comments
Closed

Several problems with the GUI-behaviour on a two-screen setup #166

erl987 opened this issue Sep 2, 2020 · 6 comments
Labels
custom window decorations Related to using FlatLaf custom window decorations JDK bug there is something wrong in the JDK multi-screen Related to using multiple screens
Milestone

Comments

@erl987
Copy link

erl987 commented Sep 2, 2020

I have a primary 4k-screen on a laptop and a separate secondary Full-HD screen on Windows 10. The software is using Java OpenJDK 14.0.2. If using the FlatLaf L&F but not with Metal for example, I get some weird issues:

  1. When I start our application on the primary screen and try to move it to the secondary (located to the right), the application partly moves over to the secondary screen but then suddenly jumps out of the screens to the left. Afterward, it is hard to bring it back to visibility, this works only via the keyboard.

  2. When I finally have the application on the secondary screen, the File Open dialog is opening part of its components (the file-dropdown) on the primary screen.

These issues appear to be related to the FlatLaf layout, but also to the screen setup. Others don't have this problem with the same code.

Do you have any suggestions on how to fix this? Is this a known issue? If necessary, I can try to create a small program that reproduces hopefully this issue at least on my computer.

Best regards,
Ralf

@DevCharly
Copy link
Collaborator

Thx for reporting.

I can reproduce your 2nd problem. I have to open-and-close the "Save in" combobox 3 times until the popup list is at the correct location... strange...

Regarding 1st problem:
Can not yet reproduce it.
Could you please run FlatScreenInfo.java on your computer, with the same Java version, and post the output here?
This program outputs information about the connected screens.
With this information I can configure the same setup an try to reproduce the issue.
All you need to run the program is FlatScreenInfo.java because it does not have any dependencies.

BTW are you using FlatLaf custom window decorations?
Enabled with JFrame.setDefaultLookAndFeelDecorated( true );?

If yes, does the 1st problem also occur if you disable FlatLaf custom window decorations?

DevCharly added a commit that referenced this issue Sep 3, 2020
…o another screen with different scaling factor (issue #166)
@DevCharly
Copy link
Collaborator

@erl987 Found a problem when moving a window to another screen that uses different scale factor. Then the window did not stay at the mouse position. In my case it was placed about 500px below the mouse position, but still partly on second screen. Maybe this is the same problem as yours.

Fixed in commit 0247308.

Please try it and let me know whether 1st problem is gone.
If you don't want build FlatLaf yourself, use the latest 0.42-SNAPSHOT
(see https://github.com/JFormDesigner/FlatLaf#snapshots)

@DevCharly DevCharly added this to the 0.42 milestone Sep 3, 2020
DevCharly added a commit that referenced this issue Sep 4, 2020
… another screen with different scaling factor (issue #166)
@erl987
Copy link
Author

erl987 commented Sep 4, 2020

Thanks for the fast and helpful responses!

The layout is like this:

Scale factors: 250% / 125%
Java version: 14.0.2

ID: \Display0 (main)
Size: 3840 x 2160 / 32 Bit / 60 Hz
Bounds: 1536 x 864 / x 0 / y 0 (scale -2.5)
Insets: left 0 / right 0 / top 0 / bottom 100
Scale: 2.5

ID: \Display1
Size: 1920 x 1080 / 32 Bit / 59 Hz
Bounds: 1536 x 864 / x 3072 / y 0 (scale -1.25)
Insets: left 0 / right 0 / top 0 / bottom 50
Scale: 1.25

Actually yes, the problem only occurs if JFrame.setDefaultLookAndFeelDecorated( true ); is set.

I need to check your recent fixes later today.

@erl987
Copy link
Author

erl987 commented Sep 4, 2020

The latest snapshot version of FlatLaf is indeed fixing issue no. 1, thank you very much!

The problem with the open file dialog is still present though, please note that in our case it is actually only the opening dialog that makes problems and not the saving dialog. That is at least what I observe.

DevCharly added a commit that referenced this issue Sep 17, 2020
@DevCharly
Copy link
Collaborator

DevCharly commented Sep 17, 2020

Turns out that 2nd issue is a bug in Java: https://bugs.openjdk.java.net/browse/JDK-8224608

It also occurs in other LaFs (Windows, Nimbus, Metal, etc) every time a heavy weight popup is used, which is the case when the popup does not fit into the window. E.g. large menus or comboboxes at the bottom of a window.

You can try it with the FlatLaf 0.42 Demo (use Java 9 or later):

  1. use the combobox in the left-bottom edge to switch to Metal LaF.
  2. press Ctrl+N or use "File > New" to open the "New" dialog.
  3. click on a combobox arrow to show popup list
  4. move the "New" dialog to the other screen (that uses different scaling factor)
  5. click on a combobox arrow to show popup list

Now the popup is probably shown at wrong location. This usually happens only the first time after moving the dialog to another screen. So try moving dialog back to other screen and click combobox button...

The reason that it occured in FlatLaf file chooser in you app is that comboboxes in FlatLaf show by default 15 lines, but in other LaFs only 8 lines. So other LaFs use a light weight popup because it fits into the dialog, but FlatLaf file chooser uses a heavy weight popup, which causes the issues.

Anyway, after trying various workarounds and doing a lot of testing, I was finally able to fix it in commit ef4c467 😄

Fixed in FlatLaf 0.42

@erl987
Copy link
Author

erl987 commented Sep 18, 2020

Yes, the file dialog is working well now for me! So all issues reported here are fixed. Thank you!

/Ralf

@DevCharly DevCharly added custom window decorations Related to using FlatLaf custom window decorations JDK bug there is something wrong in the JDK multi-screen Related to using multiple screens labels Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom window decorations Related to using FlatLaf custom window decorations JDK bug there is something wrong in the JDK multi-screen Related to using multiple screens
Projects
None yet
Development

No branches or pull requests

2 participants