pub struct TrafficLights {}Expand description
The macOS traffic-light offset, usable on its own.
A plain library type: it needs neither the shell plugin nor the managed ShellState. An app that
keeps its own lifecycle manages one itself and forwards window events to it:
app.manage(rightkit_tauri_shell::frameless::TrafficLights::default());
// in `on_window_event`:
if let Some(t) = app.try_state::<TrafficLights>() { t.handle_window_event(&webview, event); }
// in a command: `t.set_offset(&window, dx, dy)`With the shell plugin installed the calls run through the shell’s main-thread dispatch (which rejects work during shutdown). Without it they run inline when already on the main thread and are queued to it otherwise (fire and forget), so no lifecycle hook or single-instance claim is needed. Cloning shares the captured default origins and the last offset.
Implementations§
Source§impl TrafficLights
impl TrafficLights
Sourcepub fn set_offset(&self, window: &WebviewWindow<Wry>, dx: f64, dy: f64)
pub fn set_offset(&self, window: &WebviewWindow<Wry>, dx: f64, dy: f64)
Offset the close/minimise/zoom buttons from their macOS default origin (x right, y down). No-op off macOS.
Sourcepub fn set_inset(&self, window: &WebviewWindow<Wry>, x: f64, y: f64)
pub fn set_inset(&self, window: &WebviewWindow<Wry>, x: f64, y: f64)
Place the close / minimise / zoom buttons at an absolute inset instead of a relative offset: the
close button’s top-left corner sits x points from the window’s left edge and y points from its
top (y down), and the other two keep the macOS spacing. Replaces the last set_offset (and the
reverse), and is re-asserted by TrafficLights::reapply. No-op off macOS.
Sourcepub fn reapply(&self, window: &WebviewWindow<Wry>)
pub fn reapply(&self, window: &WebviewWindow<Wry>)
Re-assert the last offset (call from resize / focus / fullscreen events).
Sourcepub fn handle_window_event(
&self,
window: &WebviewWindow<Wry>,
event: &WindowEvent,
)
pub fn handle_window_event( &self, window: &WebviewWindow<Wry>, event: &WindowEvent, )
Re-assert the offset when event is one AppKit answers by resetting the buttons: a resize or
a focus gain (fullscreen exit refocuses). Other events are ignored. No-op off macOS.