JetBrains / JetBrainsRuntime

Runtime environment based on OpenJDK for running IntelliJ Platform-based products on Windows, macOS, and Linux
GNU General Public License v2.0
1.36k stars 199 forks source link

JBR-7586 Fix closing menus in a custom title bar #454

Closed stachenov closed 2 months ago

stachenov commented 2 months ago

The problem: we add a menu bar to a custom title bar, the user clicks a menu, it expands, then the user clicks again, the menu stays open.

The cause: the click causes the window to be ungrabbed, because it's a click on the frame decorations. Ungrabbing the frame causes the menu to close, just like if the user clicked on an empty area. Then the click reaches the menu and it reopens.

The fix: just don't ungrab if the native actions are disabled. Let the components to handle clicks normally, as if they're located in the client area.

NikitkoCent commented 2 months ago

@YaaZ, could you also review this as the developer of the custom title bars?

YaaZ commented 2 months ago

Looks good, that's how I would fix it too. However, this is a very fragile matter, hope this doesn't break something else...

YaaZ commented 2 months ago

@stachenov could you rebase your branch over fresh main, please?

stachenov commented 2 months ago

Ugh. OK, I guess I'll just change it to skip the test if the custom title bar isn't supported. I think that's better than to hardcode the OS.

stachenov commented 2 months ago

Added a check to skip the test if custom window decorations aren't supported.

YaaZ commented 2 months ago

@stachenov there is a merge conflict with main

stachenov commented 2 months ago

Yes, I haven't figured that this was already merged. Fixed.

NikitkoCent commented 2 months ago

Pushed the new commit to main and squashed it with the initial one. So, another round of CI testing...

NikitkoCent commented 2 months ago

Everything went well, so the patch merged into main, jbr21, jbr17 branches. Thanks for your effort!.