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

Undecorated frame/dialog with default border (Windows 11 only) #978

Open
VISTALL opened this issue Mar 4, 2025 · 5 comments
Open

Undecorated frame/dialog with default border (Windows 11 only) #978

VISTALL opened this issue Mar 4, 2025 · 5 comments

Comments

@VISTALL
Copy link
Contributor

VISTALL commented Mar 4, 2025

Hello. IntelliJ IDEA use same hack as for default frame. Here example:

Image

Code from intellij

https://github.com/JetBrains/intellij-community/blob/master/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java#L253

@DevCharly
Copy link
Collaborator

Don't understand what you want 😕
Provide more details...

@VISTALL
Copy link
Contributor Author

VISTALL commented Mar 4, 2025

Sorry. For now - it's impossible to set native Windows 11 border to undecorated dialog/frame.

I thought - it's limitation of undecorated windows, but - looks like its not. IntelliJ IDEA set native Windows 11 border to undecorated frame (sample screenshot and code which is set to it).

I tested with current version of FlatLaf (and removed if-undecorated-return statement) - but native library return hwnd=0, for now I'm don't known why it return 0.

Will be nice to have option for setting native border to undecorated frames/dialogs at least at Windows 11 (its limitation of IDEA too)

Thanks

@DevCharly
Copy link
Collaborator

... but native library return hwnd=0, for now I'm don't known why it return 0.

Then the win32 window is not yet created.
You could try to invoke window.addNotify() before getting HWND.
Or better override addNotify() and do it there.
But I don't know whether it works to apply a rounded border to an undecorated frame.

You could also hide the min/max/close buttons and use full window content mode for a decorated frame.
See client properties (e.g. JRootPane.titleBarShowIconify, etc)
https://www.formdev.com/flatlaf/client-properties/#JRootPane

@VISTALL
Copy link
Contributor Author

VISTALL commented Mar 4, 2025

And, you are right. But my fast check show dialog without border anyway. But hwnd now is set.

(always forgetting native window flow)

I known about JRootPane.titleBarShowIconify but want adopt current code, just with calling set method.

IDEA & Consulo used undecorated windows for popups like this for all. Will be nice to save this setting.

I will test today maybe - how it works at macOS (about border shadow), as I known IDEA emulate shadow border at not windows 11

@VISTALL
Copy link
Contributor Author

VISTALL commented Mar 4, 2025

Test at mac. macOS always render shadow for undecorated frame, but without rounded borders.

Image

If I call method

FlatPopupFactory#setupRoundedBorder

we have perfect undecorated window at mac

Image

public class Main {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            FlatMacLightLaf.setup();

            JFrame frame =  new JFrame() {
                @Override
                public void addNotify() {
                    super.addNotify();

                    try {
                        Method method = FlatPopupFactory.class.getDeclaredMethod("setupRoundedBorder", Window.class, Component.class, Component.class);
                        method.setAccessible(true);

                        method.invoke(null, this, this, getRootPane());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            };
            frame.setLocationRelativeTo(null);
            frame.setSize(500, 500);
            frame.setUndecorated(true);
            frame.setLocation(300, 300);

            frame.setVisible(true);
        });
    }
}

Also calling this method at Windows make good border (but without shadow)

Image

Maybe introduce new parameter for undecorated window's which add default border - unify it between mac/windows. At linux maybe use default rectangle border with software shadow(like popups)

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

2 participants