Skip to content

macOS: Adding support for RTL Custom TitleBar#586

Open
kdroidFilter wants to merge 1 commit intoJetBrains:jbr25from
kdroidFilter:macos-rtl-custom-titlebar-jbr25
Open

macOS: Adding support for RTL Custom TitleBar#586
kdroidFilter wants to merge 1 commit intoJetBrains:jbr25from
kdroidFilter:macos-rtl-custom-titlebar-jbr25

Conversation

@kdroidFilter
Copy link
Copy Markdown

@kdroidFilter kdroidFilter commented Feb 7, 2026

This PR adds macOS support for the controls.rtl property on the Custom TitleBar, aligning the macOS behavior with the Windows implementation introduced in #540.

On Windows, PR #540 reads the controls.rtl property and mirrors the native window control buttons to the right side. On macOS, the same property existed on the Java side but was never read — the traffic light buttons (close, miniaturize, zoom) were always anchored to the left via Auto Layout constraints. This PR fixes that.

Solution

Following the same approach as #540 (adding an RTL flag as a titlebar property), this implementation:

  • Reads the controls.rtl property via a new JNI accessor (internalCustomTitleBarControlsRtl)
  • Anchors buttons to rightAnchor with negative offsets when RTL is enabled (instead of leftAnchor with positive offsets)
  • Swaps left/right inset reporting so the Java side receives the correct inset for RTL layout
  • Positions full-screen buttons on the right when RTL is active
  • Detects runtime RTL flag changes and forces a full titlebar re-setup

Note

This solution is only applied to the custom titlebar implementation. Default/AWT window controls were not changed.

Changes

File Change
Window.java Add internalCustomTitleBarControlsRtl() JNI convenience method
AWTWindow.h Add customTitleBarControlsRtl property
AWTWindow.m Read RTL flag; adjust button positioning, insets, full-screen buttons

Evidences

LTR (default) RTL (controls.rtl = true)
Capture d’écran 2026-02-07 à 23 40 27 Capture d’écran 2026-02-07 à 23 39 31

Tested with the Jewel standalone sample on JBR 25, macOS aarch64.

Read the `controls.rtl` property on macOS and mirror the traffic light
buttons (close, miniaturize, zoom) to the right side of the title bar
when enabled. This mirrors the Windows implementation from PR JetBrains#540.

Changes:
- Add internalCustomTitleBarControlsRtl() JNI accessor in Window.java
- Add customTitleBarControlsRtl property to AWTWindow
- Anchor buttons to rightAnchor with negative offsets when RTL
- Swap left/right insets reporting when RTL
- Position full-screen buttons on the right when RTL
- Force full titlebar re-setup when RTL flag changes at runtime
@kdroidFilter kdroidFilter marked this pull request as ready for review February 7, 2026 21:47
@kdroidFilter
Copy link
Copy Markdown
Author

@faogustavo can you take a look?

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

Successfully merging this pull request may close these issues.

2 participants