-
Notifications
You must be signed in to change notification settings - Fork 40
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
Custom title bar on macOS #32
Comments
Yes this keeps the window buttons and title text. |
https://bugs.openjdk.java.net/browse/JDK-8212549 which indeed works in Java 13. JFrame frame = new JFrame();
final JRootPane rootPane = frame.getRootPane();
rootPane.putClientProperty("apple.awt.fullWindowContent", true);
rootPane.putClientProperty("apple.awt.transparentTitleBar", true); |
Great. At least for java version >= 12 this is a solution. Does moving the window work? For java version below 12 there should still be a possibility to achieve this. Gladly because the jdk implementation also just sets those corresponding properties on the NSWindow the swing code can be reused and just the method of setting the window property still needs to be implemented natively. Based on the jdk implementation it could look like this #include "package_path_class.h"
#import <Cocoa/Cocoa.h>
#define OBJC(jl) ((id)jlong_to_ptr(jl))
#define FULL_WINDOW_CONTENT 1 << 14
#define TRANSPARENT_TITLE_BAR 1 << 18
JNIEXPORT void JNICALL
package_path_class_installDecorations(JNIEnv *env, jclass obj, jlong windowPtr)
{
NSWindow *nsWindow = OBJC(windowPtr);
window.styleMask |= FULL_WINDOW_CONTENT | TRANSPARENT_TITLE_BAR;
} To get hold of the window pointer |
What do you think of |
Theoretically a good approach. The instance of the underlying WindowPeer peer = (WindowPeer)window.getPeer();
CPlatformWindow platformWindow = (CPlatformWindow)((LWWindowPeer)peer).getPlatformWindow(); Neither |
This relates to #2 .
Provide a custom title bar on macOS. After doing some research, this could be done by setting
the properties
fullsizecontentview
and]titlebarappearstransparent
of the underlying NSWindow. (see https://stackoverflow.com/questions/54353576/colorizing-the-titlebar-in-macos-with-multiple-colors).Communication with java would happen as in the windows version through JNI passing the request to a C++ function which in turn calls the objective-c code, that is able to set those properties.
If working the LaF should add a custom title bar (without window buttons, as those should still be present).
As I don't have access to macOS platform I can't do this myself, so help would be highly appreciated.
The text was updated successfully, but these errors were encountered: