Skip to main content

TrafficLights

Struct TrafficLights 

Source
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

Source

pub fn new() -> Self

A fresh instance with no offset applied.

Source

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.

Source

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.

Source

pub fn reapply(&self, window: &WebviewWindow<Wry>)

Re-assert the last offset (call from resize / focus / fullscreen events).

Source

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.

Trait Implementations§

Source§

impl Clone for TrafficLights

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TrafficLights

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TrafficLights

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,