Skip to main content

DndWorld

Struct DndWorld 

Source
pub struct DndWorld<T: Clone + 'static> { /* private fields */ }
Expand description

A drag world shared by several windows: one DndContext every joined provider re-provides, plus the window table cross-window hit-testing walks. Cheap to copy; seed sibling windows with Self::vdom.

Implementations§

Source§

impl<T: Clone + 'static> DndWorld<T>

Source

pub fn begin_from(&self, key: WindowKey)

Mark a drag as begun from key and reset stale presentation state. Draggable calls this at pickup; call it from custom drag sources so the world knows which window’s client px ctx.pointer() is in.

Source

pub fn active_record(&self) -> Option<WindowRecord<T>>

The record of the window the in-flight drag started in.

Source

pub fn global_pointer(&self) -> Option<Point>

The in-flight pointer in global physical px. None until a world pointer can be resolved or after the world drag finishes.

Source

pub fn source_location(&self) -> Option<ZoneLocation>

Window-qualified source and hover locations for the active world drag. The legacy DndContext id accessors remain unchanged.

Source

pub fn over_location(&self) -> Option<ZoneLocation>

Source

pub fn drag_session(&self) -> Option<DragSessionId>

Current tracked pointer-drag generation, if this world owns one.

Source§

impl<T: Clone + 'static> DndWorld<T>

Host-side drive: entry points for desktop glue that sees the pointer where webviews cannot. Webview pointer events stop at the viewport edge (and under a pointer grab, every non-origin window is fully event-blind on all platforms), so cross-window pointer data must come from the windowing layer: poll the global cursor while a drag is in flight and feed it here.

Source

pub fn modifiers(&self) -> Modifiers

Modifiers currently associated with host delivery. Returns an empty set outside an active world drag.

Source

pub fn update_modifiers(&self, modifiers: Modifiers)

Update the live modifiers for the active world drag. Late host events after completion are ignored once the context stops dragging.

Source

pub fn track_global(&self, global: Point)

Track an in-flight pointer drag from a host-reported cursor position (global physical px): updates the shared pointer (in the origin window’s client px, the coordinate anchor everything else expects) and enters/leaves zones across every joined window. No-op when nothing is dragging or the origin window is unknown.

Every host leg converges here, so overlapping legs are safe by construction rather than by leg exclusivity:

  • Two legs reporting the same tick are idempotent: every write below is guarded by an equality check, and re-entering the current zone is a no-op.
  • Legs run on one event-loop thread, so ticks serialize; a staler position arriving after a fresher one moves the hover briefly and the next tick corrects it - visual, transient, never structural.
  • A tick landing after a drop cannot resurrect the drag: the dragging() gate below is dead after completion, and each leg additionally re-validates its captured BridgeGeneration immediately before calling in, so drag N’s sleeper cannot feed replacement drag N+1 even during the same event burst.
Source

pub fn drop_at_global(&self, global: Point) -> Option<ZoneId>
where T: PartialEq,

Complete an in-flight pointer drag at a host-reported cursor position (global physical px), using the receiving registry’s full acceptance, collision, effect, and recovery policy. Returns the receiving zone. Used by glue that detects a release the webviews never saw - e.g. a non-origin window receiving its first pointer event mid-“drag”, which proves the button is up. A no-op returning None when nothing is dragging, so double delivery (webview pointerup plus host echo) is harmless.

Source

pub fn cancel_drag(&self)

Abort an in-flight drag from the host side (a window manager signal, an escape hatch). If delivery already succeeded and only its visual settle is still running, this finishes that settle without turning the committed drop into a cancellation. No-op when neither a drag nor a settle is active.

Source

pub fn origin_window(&self) -> Option<WindowKey>

The key of the window the in-flight drag started in, if any - glue uses it to tell “origin window, webview owns the events” from “foreign window, I am the drag’s eyes”.

Source§

impl<T: Clone + 'static> DndWorld<T>

Source

pub fn claim_settle(&self, key: WindowKey)

Elect key to present the next world settle. Custom world delivery calls this before crate::core::DndContext::take_settling; built-in delivery claims automatically.

The claim is required, not advisory: in a joined world, only the elected window’s overlay presents and finishes a settle. A custom source that calls take_settling without claiming gets no glide anywhere; that claimless settle is only cleaned up when its origin window closes or the next drag begins.

Source

pub fn finish_settle_from(&self, key: WindowKey) -> bool

Finish a custom or built-in settle from its elected window. Custom world overlays should use this rather than finishing the shared context directly, so world metadata is cleared with it.

Source

pub fn settling_in(&self) -> Option<WindowKey>

The window elected to present the current settle glide.

Source§

impl<T: Clone + 'static> DndWorld<T>

Source

pub fn new() -> Self

Create a world. Its state is process-lived (see the module docs on lifetimes), so windows may close in any order afterwards. Must run inside a Dioxus app; prefer use_dnd_world, which also provides the world in context.

Source

pub fn vdom(self, root: fn() -> Element) -> VirtualDom

Create a sibling window’s VirtualDom with this world already in its root context.

Chain with_root_context for the app model and any per-window data:

let dom = world
    .vdom(tray_window)
    .with_root_context(model)
    .with_root_context(tray);

This is the preferred way to seed spawned windows because omitting the world would otherwise leave their providers silently isolated.

Source

pub fn context(&self) -> DndContext<T>

The shared drag context every joined provider re-provides.

Source

pub fn set_bridging(&self, enabled: bool)

Enable or disable host-side bridging at runtime - the lever for the day a webview or OS update ships a cross-window regression that a rebuild cannot wait for. While disabled, every host-drive entry point (Self::track_global, Self::drop_at_global) is inert and the desktop feature’s bridge legs stand down, so drags degrade to per-window - exactly the already-modeled Wayland behavior. Local drags, geometry, settle and delivery are untouched. Self::cancel_drag deliberately stays live: it is an escape hatch, not a bridge leg.

End users can flip the same switch without a rebuild by setting DIOXUS_DND_NO_BRIDGE=1 before launch (read once at world creation; 0 or an empty value leaves bridging on).

Source

pub fn bridging_enabled(&self) -> bool

Is host-side bridging currently enabled? (See Self::set_bridging.)

Source

pub fn record(&self, key: WindowKey) -> Option<WindowRecord<T>>

Look up a joined window. None for unknown keys.

Source

pub fn windows(&self) -> Vec<WindowRecord<T>>

Every joined window, in join order. Subscribing read, like ZoneRegistry::records - its consumers are renderers and tests.

Source

pub fn window_under(&self, global: Point) -> Option<WindowRecord<T>>

The window containing global (physical px), most recently focused first when several overlap. None while no live geometry contains the point.

Source

pub fn resolve_global(&self, global: Point) -> Option<(WindowRecord<T>, Point)>

Resolve a global point to (window, client-local point). None when no live window contains it.

Source

pub fn refresh_all_rects(&self)

Ask every joined window to re-measure its zones, each inside its own runtime through the window’s internal refresh callback.

Trait Implementations§

Source§

impl<T: Clone + 'static> Clone for DndWorld<T>

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<T: Clone + 'static> Copy for DndWorld<T>

Source§

impl<T: Clone + 'static> Default for DndWorld<T>

Source§

fn default() -> Self

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

impl<T: Clone + 'static> PartialEq for DndWorld<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for DndWorld<T>

§

impl<T> !Send for DndWorld<T>

§

impl<T> !Sync for DndWorld<T>

§

impl<T> !UnwindSafe for DndWorld<T>

§

impl<T> Freeze for DndWorld<T>

§

impl<T> Unpin for DndWorld<T>

§

impl<T> UnsafeUnpin for DndWorld<T>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DependencyElement for T
where T: 'static + PartialEq + Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
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, <T as TryFrom<U>>::Error>

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more