macOS: add traffic‑light inset API and demo example#4466
macOS: add traffic‑light inset API and demo example#4466AndrewJSchoen wants to merge 4 commits intorust-windowing:masterfrom
Conversation
Introduces API and implementation for setting the offset of macOS window controls (traffic lights) via LogicalSize. Updates WindowExtMacOS and WindowAttributesMacOS, implements logic in window_delegate, and adds a traffic_lights.rs example demonstrating usage and interactive adjustment.
Updates documentation, example usage, and changelog to reflect the new macOS traffic light placement API.
Better handles non-macOS platforms for CI
|
I think this should be ready to go if everything checks out with the owners. |
|
A note on this: I can reproduce a “dual hover” issue after applying the traffic‑light inset: the original (pre‑inset) hover region still highlights the buttons, even though clicks only work at the new position. I tried some fixes, such as resizing the titlebar container/titlebar view and forcing tracking area refreshes ( This appears to be tied to AppKit internals: standard traffic‑light hover is driven by a private superview method ( Otherwise, it might be worth documenting this limitation (hover highlight remains at the original location) and/or recommending a custom decorator approach for apps that need inset traffic lights with correct hover behavior (e.g. #4450), which seems to be more similar to the approach Tauri uses. |
|
From your StackOverflow link https://stackoverflow.com/a/36292700/140293 and https://stackoverflow.com/a/30417372/140293 both look like they might work to fix the issue you're seeing. |
changelogmodule if knowledge of this change could be valuable to usersDescription:
WindowAttributesMacOS::with_traffic_light_insetandWindowExtMacOS::set_traffic_light_insetto offset the traffic‑light buttons in logical points.traffic_lightsexample for interactive adjustment (arrow keys, Shift for coarse, R reset, Esc exit).winit/src/changelog/unreleased.md.Fixes #4436
Tests:
cargo check -p winit-appkitcargo check -p winit --example traffic_lights