GithubHelp home page GithubHelp logo

Custom title bar on macOS about darklaf HOT 7 CLOSED

weisj avatar weisj commented on July 20, 2024
Custom title bar on macOS

from darklaf.

Comments (7)

vlsi avatar vlsi commented on July 20, 2024

Is it different from Frame#setUndecorated(true) ?

Снимок экрана 2020-02-20 в 1 00 30

from darklaf.

weisJ avatar weisJ commented on July 20, 2024

Yes this keeps the window buttons and title text.

from darklaf.

vlsi avatar vlsi commented on July 20, 2024

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);

Снимок экрана 2020-02-20 в 2 00 59

from darklaf.

weisJ avatar weisJ commented on July 20, 2024

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 JNIDecorations.m:

#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 Pointer.nativeValue(Native.getComponentPointer(component)) should still work on macOS.

from darklaf.

vlsi avatar vlsi commented on July 20, 2024

What do you think of setAccessible(true)-driven sun.lwawt.macosx.CPlatformWindow#setStyleBits(int mask, boolean value) for pre Java 12?

from darklaf.

weisJ avatar weisJ commented on July 20, 2024

Theoretically a good approach. The instance of the underlying CPlatformWindow can be optained as follows:

WindowPeer peer = (WindowPeer)window.getPeer();
CPlatformWindow platformWindow = (CPlatformWindow)((LWWindowPeer)peer).getPlatformWindow();

Neither CPlatformWindw nor LWWindowPeer are visible (or included) in non macOS jdk version.
All of this would need to happen through reflection or otherwise this can't be build.

from darklaf.

weisJ avatar weisJ commented on July 20, 2024

@vlsi could you tell me if #54 works for your? At least for the part of actually calling setStyleBits on CPlatformWindow.

from darklaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.