[macOS 26] Add layer-based border rendering for Text and Combo widgets#3302
[macOS 26] Add layer-based border rendering for Text and Combo widgets#3302tobiasmelcher wants to merge 3 commits into
Conversation
The macOS runtime can report incorrect OS versions (10.16 instead of actual version) when the executable's linked SDK is too old. Add OS.getMachOSDKVersion() to extract the SDK version from the LC_BUILD_VERSION load command in the main executable's Mach-O header. This allows SWT to detect the SDK version the running JVM was built against, enabling proper diagnostics for version reporting issues.
Test Results (macos) 56 files - 2 56 suites - 2 3s ⏱️ - 7m 37s Results for commit 520d7f3. ± Comparison against base commit f33b79e. This pull request removes 4545 tests.♻️ This comment has been updated with latest results. |
|
I think I went into the wrong direction. I got following explanation from Gemini. I will try the Description This change is part of Apple's move toward layer-backed controls and the "Liquid Glass" design language, where traditional CPU-based drawing of bezels is being phased out in favor of GPU-accelerated layer properties. Changes Enables Layer-Backing: Sets wantsLayer = true for the control. Manual Border Definition: Uses CALayer properties to define a border that mimics the native appearance. System Color Integration: Uses NSColor.separatorColor to ensure the border automatically adapts to Light Mode, Dark Mode, and high-contrast accessibility settings. Refined Geometry: Applies a slight cornerRadius to align with modern macOS UI standards. Technical Snippet (Implementation Logic) Swift Forward Compatibility: Moves away from deprecated drawing behaviors toward the recommended AppKit/Core Animation architecture. No Regression: On older macOS versions, this approach remains functionally identical and provides a cleaner, modern aesthetic. |
|
Thank you for taking so much time to investigate this, @tobias-melcher. It's great to see the continuously increasing understanding of what changed/happens. Looking forward to hopefully seeing a solution that keeps SWT adopt the latest macOS look & feel. The screenshots already look very promising. |
On macOS 26 (Tahoe) Liquid Glass, all text fields and combo boxes require a visible border regardless of SWT.BORDER style. This adds the necessary Cocoa bindings (NSView.setWantsLayer, CALayer.setBorderColor/ setBorderWidth/setCornerRadius, NSColor.separatorColor/CGColor) and draws borders via the layer pipeline. The shared logic is extracted into Control.configureLayerBorder() and the SDK version is cached in OS.MACH_O_SDK_VERSION.
5cd8838 to
1e4df2d
Compare
|
Pull request 1e4df2d no longer uses any hack or workaround from my point of view. Following screenshots are made with -Dorg.eclipse.swt.internal.carbon.smallFonts
What do you think? Is it an improvement compared to the current state? Does it make sense to merge these changes? |
I don't think it's a good idea to merge any of these macOS changes so late in 4.40. If there is more time for targeting a later release it allows (at least me) more time to test on macOS 15, 26 and on various combinations. It would be a shame to find serious regressions in 4.40. |
No worries, I don't want to break any release. It is fine for me. Just wanted to know if the change goes into the right direction. |
Thanks. I want to spend some focussed time testing this and the other changes to Mac for macOS 26 support and also test for possible regressions on earlier macOS versions (I have various Mac setups including Intel). It would be helpful if the changes which are proposed could have longer testing period into 4.41. Thanks for your work on this! |
|
Sorry for the delay @HeikoKlare . I now started again to look into this topic. I introduced the LiquidGlassStrategy enum in [520d7f3] to be able to compare the two rendering approaches side-by-side:
You are right: the LAYER_BORDER approach does not look great. The padding is off, the background color differs, and the result feels customized rather than native. The SKIP_DISPLAY_OVERRIDES approach clearly produces a more native look (see screenshots below). My hesitation with SKIP_DISPLAY_OVERRIDES is that I cannot fully assess the side effects of no longer overriding those native display methods. addEventMethods(...) has been the established mechanism across all NSView-based widgets for many years, and skipping the display-invalidation overrides specifically for NSTextField / NSComboBox could surface subtle regressions in redraw / partial invalidation / region handling scenarios that may only become visible later. That uncertainty was the original motivation for trying the layer-based approach. Comparison screenshots (all made with the homebrew jvm built with MacOS SDK 26). Please only compare the text field and the combo box which are modified. What do you think? |


















On macOS 26 (Tahoe) Liquid Glass, all text fields and combo boxes
require a visible border regardless of SWT.BORDER style. This adds
the necessary Cocoa bindings (NSView.setWantsLayer,
CALayer.setBorderColor/
setBorderWidth/setCornerRadius, NSColor.separatorColor/CGColor) and
draws borders via the layer pipeline. The shared logic is extracted
into Control.configureLayerBorder() and the SDK version is cached in
OS.MACH_O_SDK_VERSION.