Skip to content

Add support for JComponent.titleBarCaption for macOS#1124

Open
ps-porpoise wants to merge 3 commits into
JFormDesigner:mainfrom
ps-porpoise:macos-titlebar-caption
Open

Add support for JComponent.titleBarCaption for macOS#1124
ps-porpoise wants to merge 3 commits into
JFormDesigner:mainfrom
ps-porpoise:macos-titlebar-caption

Conversation

@ps-porpoise

Copy link
Copy Markdown

This PR adds support for the existing JComponent.titleBarCaption client property when using fullWindowContent in macOS. The motivation is to allow configuration as to what components within the title bar region should drag the window, and which should block window dragging and have the events handled by AWT.

The solution requires updates to the native code to support us attaching a callback which gets handled when attempting to drag the window, using a similar approach to that in FlatTitlePane for Windows. The approach also attaches a custom NSView (FlatTitleBarDragView) to receive the mouse events from AppKit & conditionally forward them on.

I've added some buttons to demonstrate & test the functionality within the FlatMacOSTest utility.

I've not rebuilt the .dylibs in these commits.

Please let me know any thoughts! Thanks :)

Adds JNI hooks setupFullWindowContentTitleBarCaption /
removeFullWindowContentTitleBarCaption with a per-window callback
(FullWindowContentTitleBarCaptionCallback) that decides whether a
left mouse down in the title bar area should start a native window
drag instead of being delivered to AWT.

Implementation installs a FlatTitleBarDragView as a sibling of the
standard window buttons; AppKit's normal hit-testing routes button
and contentView clicks unchanged, only background clicks land on us
and are either handed off via -[NSWindow performWindowDragWithEvent:]
or forwarded to the contentView.
Registers a per-window callback with the native library when
apple.awt.fullWindowContent is enabled. The callback runs the same
shared isTitleBarCaptionAt traversal used on Windows, returning
true for components marked with JComponent.titleBarCaption (or
their children, recursively).
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.

1 participant