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

Native window decorations for Windows 10 (using JNI) #267

Merged
merged 16 commits into from Mar 12, 2021

Conversation

DevCharly
Copy link
Collaborator

@DevCharly DevCharly commented Mar 10, 2021

This PR is the successor of PR #262 and implements native window decorations for Windows 10 using JNI. This avoids the 3MB dependency on JNA. Also flatlaf-native-jna-1.1-SNAPSHOT.jar is no longer needed. A small 9kB DLL is now contained in flatlaf.jar. This DLL is extracted at startup to folder $TEMP/flatlaf.temp. Since it is not possible to delete it when the application exits (because Windows has locked it), unused temporary DLL is deleted on next startup.

This PR enables dark frame/dialog title bar and embedded menu bar with all JREs while still having:

  • native Window 10 border drop shadows
  • native Window 10 resize functionality
  • Windows 10 snapping functionality
  • native Windows 10 system window menu when right-clicking on title bar or left-clicking on application icon

image

image

Try it

To try it out, either build from source or download the build artifacts ZIP from GitHub Actions
(at the bottom of that page):
https://github.com/JFormDesigner/FlatLaf/actions/runs/642361750

The ZIP contains the demo flatlaf-demo-1.1-SNAPSHOT.jar (contains all dependencies).

To test in own applications, add flatlaf-1.1-SNAPSHOT.jar to the classpath.

Enable/disable

This feature is enabled by default on Windows 10.

If you don't like/want it, you can disable it with:

UIManager.put( "TitlePane.useWindowDecorations", false );

It is also possible to disable only the embedded menu bar (and keep the dark title pane) with:

UIManager.put( "TitlePane.menuBarEmbedded", false );

It is also possible to disable this on command line with following VM options:

-Dflatlaf.useWindowDecorations=false
-Dflatlaf.menuBarEmbedded=false

If you have following code in your app, you can remove it (no longer necessary):

// enable window decorations
JFrame.setDefaultLookAndFeelDecorated( true );
JDialog.setDefaultLookAndFeelDecorated( true );

JetBrains Runtime (JRE)

If you're using JetBrains Runtime 11 to run your app, this feature is not used.
Instead the native window decorations feature provided by the JetBrains Runtime is used (as in FlatLaf 1.0).

fixes issue #170

… on application icon, close window on left-double-click on app icon
…latlaf-natives/flatlaf-natives-jna`

removed module-info.java because this JAR is not released/published
@DevCharly DevCharly added the custom window decorations Related to using FlatLaf custom window decorations label Mar 10, 2021
@DevCharly DevCharly added this to the 1.1 milestone Mar 10, 2021
- enabled by default (via UI property `TitlePane.useWindowDecorations`)
- dropped system property `flatlaf.useNativeWindowDecorations` and replaced with `flatlaf.useWindowDecorations`
- old functionality of system property `flatlaf.useWindowDecorations` removed
@DevCharly
Copy link
Collaborator Author

This feature is now enabled by default (see updated main post)

@DevCharly DevCharly merged commit 39d56f2 into main Mar 12, 2021
@DevCharly DevCharly deleted the native-window-decorations branch March 12, 2021 22:38
@basix86
Copy link
Contributor

basix86 commented Mar 23, 2021

Very nice and complex job.
Congratulations!

@DevCharly DevCharly mentioned this pull request Apr 17, 2021
kingthorin added a commit to kingthorin/zaproxy that referenced this pull request Apr 29, 2021
Native Decorations were causing various issues for me:
- ZAP wouldn't start maximized.
- Split pane dividers would drift noticeably between starts of ZAP.
- The close button would sometimes be inaccessible.

See: JFormDesigner/FlatLaf#267 for further
details.


Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
kosap pushed a commit to kosap/zaproxy that referenced this pull request Jun 3, 2021
Native Decorations were causing various issues for me:
- ZAP wouldn't start maximized.
- Split pane dividers would drift noticeably between starts of ZAP.
- The close button would sometimes be inaccessible.

See: JFormDesigner/FlatLaf#267 for further
details.


Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
preetkaran20 pushed a commit to preetkaran20/zaproxy that referenced this pull request Jul 19, 2021
Native Decorations were causing various issues for me:
- ZAP wouldn't start maximized.
- Split pane dividers would drift noticeably between starts of ZAP.
- The close button would sometimes be inaccessible.

See: JFormDesigner/FlatLaf#267 for further
details.


Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants