mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
macOS native:
- removed `FlatNativeMacLibrary.getWindowPtr()` because it is too dangerous to use `windowPtr` (which is `NSWindow*`) in Java (using invalid window pointer would crash app) - made `getNSWindow()` 20x faster - catch exceptions in `getNSWindow()` - digitally signed dylibs
This commit is contained in:
@@ -23,6 +23,20 @@ import java.awt.Window;
|
||||
* <p>
|
||||
* <b>Note</b>: This is private API. Do not use!
|
||||
*
|
||||
* <h2>Methods that use windows as parameter</h2>
|
||||
*
|
||||
* For all methods that accept a {@link java.awt.Window} as parameter,
|
||||
* the underlying macOS window must be already created,
|
||||
* otherwise the method fails. You can use following to ensure this:
|
||||
* <pre>{@code
|
||||
* if( !window.isDisplayable() )
|
||||
* window.addNotify();
|
||||
* }</pre>
|
||||
* or invoke the method after packing the window. E.g.
|
||||
* <pre>{@code
|
||||
* window.pack();
|
||||
* }</pre>
|
||||
*
|
||||
* @author Karl Tauber
|
||||
* @since 3.3
|
||||
*/
|
||||
@@ -38,22 +52,5 @@ public class FlatNativeMacLibrary
|
||||
return FlatNativeLibrary.isLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the macOS window pointer (NSWindow) for the given Swing window.
|
||||
* <p>
|
||||
* Note that the underlying macOS window must be already created,
|
||||
* otherwise this method returns zero. Use following to ensure this:
|
||||
* <pre>{@code
|
||||
* if( !window.isDisplayable() )
|
||||
* window.addNotify();
|
||||
* }</pre>
|
||||
* or invoke this method after packing the window. E.g.
|
||||
* <pre>{@code
|
||||
* window.pack();
|
||||
* long windowPtr = getWindowPtr( window );
|
||||
* }</pre>
|
||||
*/
|
||||
public native static long getWindowPtr( Window window );
|
||||
|
||||
public native static void setWindowRoundedBorder( long windowPtr, float radius, float borderWidth, int borderColor );
|
||||
public native static boolean setWindowRoundedBorder( Window window, float radius, float borderWidth, int borderColor );
|
||||
}
|
||||
|
||||
@@ -324,13 +324,6 @@ public class FlatPopupFactory
|
||||
if( !popupWindow.isDisplayable() )
|
||||
popupWindow.addNotify();
|
||||
|
||||
// get native window handle/pointer
|
||||
long hwnd = SystemInfo.isWindows
|
||||
? FlatNativeWindowsLibrary.getHWND( popupWindow )
|
||||
: FlatNativeMacLibrary.getWindowPtr( popupWindow );
|
||||
if( hwnd == 0 )
|
||||
return;
|
||||
|
||||
int borderCornerRadius = getBorderCornerRadius( owner, contents );
|
||||
float borderWidth = getRoundedBorderWidth( owner, contents );
|
||||
|
||||
@@ -353,6 +346,9 @@ public class FlatPopupFactory
|
||||
}
|
||||
|
||||
if( SystemInfo.isWindows ) {
|
||||
// get native window handle
|
||||
long hwnd = FlatNativeWindowsLibrary.getHWND( popupWindow );
|
||||
|
||||
// set corner preference
|
||||
int cornerPreference = (borderCornerRadius <= 4)
|
||||
? FlatNativeWindowsLibrary.DWMWCP_ROUNDSMALL // 4px
|
||||
@@ -366,7 +362,7 @@ public class FlatPopupFactory
|
||||
borderWidth = 0;
|
||||
|
||||
// set corner radius, border width and color
|
||||
FlatNativeMacLibrary.setWindowRoundedBorder( hwnd, borderCornerRadius,
|
||||
FlatNativeMacLibrary.setWindowRoundedBorder( popupWindow, borderCornerRadius,
|
||||
borderWidth, (borderColor != null) ? borderColor.getRGB() : 0 );
|
||||
}
|
||||
}
|
||||
|
||||
BIN
flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/libflatlaf-macos-arm64.dylib
Normal file → Executable file
BIN
flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/libflatlaf-macos-arm64.dylib
Normal file → Executable file
Binary file not shown.
BIN
flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/libflatlaf-macos-x86_64.dylib
Normal file → Executable file
BIN
flatlaf-core/src/main/resources/com/formdev/flatlaf/natives/libflatlaf-macos-x86_64.dylib
Normal file → Executable file
Binary file not shown.
Reference in New Issue
Block a user