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>
impl<T: Clone + 'static> DndWorld<T>
Sourcepub fn begin_from(&self, key: WindowKey)
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.
Sourcepub fn active_record(&self) -> Option<WindowRecord<T>>
pub fn active_record(&self) -> Option<WindowRecord<T>>
The record of the window the in-flight drag started in.
Sourcepub fn global_pointer(&self) -> Option<Point>
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.
Sourcepub fn source_location(&self) -> Option<ZoneLocation>
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.
pub fn over_location(&self) -> Option<ZoneLocation>
Sourcepub fn drag_session(&self) -> Option<DragSessionId>
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.
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.
Sourcepub fn modifiers(&self) -> Modifiers
pub fn modifiers(&self) -> Modifiers
Modifiers currently associated with host delivery. Returns an empty set outside an active world drag.
Sourcepub fn update_modifiers(&self, modifiers: Modifiers)
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.
Sourcepub fn track_global(&self, global: Point)
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 capturedBridgeGenerationimmediately before calling in, so drag N’s sleeper cannot feed replacement drag N+1 even during the same event burst.
Sourcepub fn drop_at_global(&self, global: Point) -> Option<ZoneId>where
T: PartialEq,
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.
Sourcepub fn cancel_drag(&self)
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.
Sourcepub fn origin_window(&self) -> Option<WindowKey>
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>
impl<T: Clone + 'static> DndWorld<T>
Sourcepub fn claim_settle(&self, key: WindowKey)
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.
Sourcepub fn finish_settle_from(&self, key: WindowKey) -> bool
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.
Sourcepub fn settling_in(&self) -> Option<WindowKey>
pub fn settling_in(&self) -> Option<WindowKey>
The window elected to present the current settle glide.
Source§impl<T: Clone + 'static> DndWorld<T>
impl<T: Clone + 'static> DndWorld<T>
Sourcepub fn new() -> Self
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.
Sourcepub fn vdom(self, root: fn() -> Element) -> VirtualDom
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.
Sourcepub fn context(&self) -> DndContext<T>
pub fn context(&self) -> DndContext<T>
The shared drag context every joined provider re-provides.
Sourcepub fn set_bridging(&self, enabled: bool)
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).
Sourcepub fn bridging_enabled(&self) -> bool
pub fn bridging_enabled(&self) -> bool
Is host-side bridging currently enabled? (See Self::set_bridging.)
Sourcepub fn record(&self, key: WindowKey) -> Option<WindowRecord<T>>
pub fn record(&self, key: WindowKey) -> Option<WindowRecord<T>>
Look up a joined window. None for unknown keys.
Sourcepub fn windows(&self) -> Vec<WindowRecord<T>>
pub fn windows(&self) -> Vec<WindowRecord<T>>
Every joined window, in join order. Subscribing read, like
ZoneRegistry::records - its consumers are renderers and tests.
Sourcepub fn window_under(&self, global: Point) -> Option<WindowRecord<T>>
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.
Sourcepub fn resolve_global(&self, global: Point) -> Option<(WindowRecord<T>, Point)>
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.
Sourcepub fn refresh_all_rects(&self)
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§
impl<T: Clone + 'static> Copy for DndWorld<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().