pub trait WindowOps {
Show 14 methods
// Required methods
fn open_window(&mut self, config: WindowConfig) -> TeksiloWindowId;
fn find_window(&self, string_id: &str) -> Option<TeksiloWindowId>;
fn window_state(&self, id: TeksiloWindowId) -> Option<WindowState>;
fn windows(&self) -> Vec<WindowState>;
fn focus_window(&mut self, id: TeksiloWindowId);
fn close_window_by_id(&mut self, id: TeksiloWindowId);
// Provided methods
fn request_activation_token(
&mut self,
_id: TeksiloWindowId,
cb: Box<dyn FnOnce(Option<String>)>,
) { ... }
fn request_activation_token_self(
&mut self,
cb: Box<dyn FnOnce(Option<String>)>,
) { ... }
fn current_parent_handle(&self) -> Option<ParentHandle> { ... }
fn set_ime_cursor_area(&mut self, _area: Rect) { ... }
fn begin_os_drag(
&mut self,
_data: OutboundDragData,
_image: Option<DragImageData>,
_pointer: PointerKind,
) -> bool { ... }
fn set_drop_accepted(&mut self, _accepted: bool) { ... }
fn cancel_os_drag(&mut self) { ... }
fn soft_keyboard_support(&self) -> SoftKeyboardSupport { ... }
}Expand description
App-level window operations exposed to handlers.
Implemented by teksilo_app::WindowManager (via a short-lived
wrapper that also holds &ActiveEventLoop). Passed into every
dispatch site as &mut dyn WindowOps and stored on
EventContext.
Required Methods§
Sourcefn open_window(&mut self, config: WindowConfig) -> TeksiloWindowId
fn open_window(&mut self, config: WindowConfig) -> TeksiloWindowId
Open a new window. Creates the winit-level window synchronously inside this call and returns its id, which is immediately valid for any other method on this trait.
Sourcefn find_window(&self, string_id: &str) -> Option<TeksiloWindowId>
fn find_window(&self, string_id: &str) -> Option<TeksiloWindowId>
Look up a window by the stable string id it was opened with
(WindowConfig::id). Returns None if no live window carries
that id.
Sourcefn window_state(&self, id: TeksiloWindowId) -> Option<WindowState>
fn window_state(&self, id: TeksiloWindowId) -> Option<WindowState>
Read the reactive state for a specific window.
Sourcefn windows(&self) -> Vec<WindowState>
fn windows(&self) -> Vec<WindowState>
Every live window’s state, in creation order.
Sourcefn focus_window(&mut self, id: TeksiloWindowId)
fn focus_window(&mut self, id: TeksiloWindowId)
Raise a window and give it keyboard focus.
Sourcefn close_window_by_id(&mut self, id: TeksiloWindowId)
fn close_window_by_id(&mut self, id: TeksiloWindowId)
Close a specific window by id. The window is fully torn down before the next event-loop tick.
Provided Methods§
Sourcefn request_activation_token(
&mut self,
_id: TeksiloWindowId,
cb: Box<dyn FnOnce(Option<String>)>,
)
fn request_activation_token( &mut self, _id: TeksiloWindowId, cb: Box<dyn FnOnce(Option<String>)>, )
Request an xdg_activation_v1 token for id — to hand to another window
or a child process so it can raise itself on Wayland. cb fires once with
the token string, or with None where unsupported (everything but
Wayland/X11). Default implementation: immediate None.
Sourcefn request_activation_token_self(&mut self, cb: Box<dyn FnOnce(Option<String>)>)
fn request_activation_token_self(&mut self, cb: Box<dyn FnOnce(Option<String>)>)
Like request_activation_token but for
the current dispatching window — the one whose handler is running.
Works even mid-dispatch, when that window is temporarily out of the
manager’s map, because it uses the captured window handle instead of an id
lookup. Use this when a focused widget needs a token to hand to another
window or process. Default implementation: immediate None.
Sourcefn current_parent_handle(&self) -> Option<ParentHandle>
fn current_parent_handle(&self) -> Option<ParentHandle>
Extract the platform parent handle of the window currently
dispatching the event (the one that owns the in-flight
EventContext). Used by native-dialog integrations
(teksilo_platform::file_dialog) to parent OS dialogs to the
originating Teksilo window.
Returns None for the standalone / test sink and on rare
platform paths where the underlying surface refuses a handle
(e.g. during shutdown).
Sourcefn set_ime_cursor_area(&mut self, _area: Rect)
fn set_ime_cursor_area(&mut self, _area: Rect)
Report the focused text widget’s caret rectangle (in window-logical
pixels) so the platform can position the OS IME candidate window
next to the insertion point. Called from text-editing widgets
whenever the caret moves. The app applies it to the in-flight
window’s set_ime_cursor_area, deduped against the last value.
No-op on the standalone / test sink.
Sourcefn begin_os_drag(
&mut self,
_data: OutboundDragData,
_image: Option<DragImageData>,
_pointer: PointerKind,
) -> bool
fn begin_os_drag( &mut self, _data: OutboundDragData, _image: Option<DragImageData>, _pointer: PointerKind, ) -> bool
Hand an OS-level drag to the platform when an in-app drag escalates at
the window boundary (the pointer left the window carrying an
OS-exportable payload). The platform backend
(teksilo_platform::external_dnd) starts a native drag session
(NSDraggingSource / wl_data_source / OLE IDropSource) using
data, optionally drawing image as the drag cursor.
Returns true if a native drag session actually started. The default
(standalone / test sink, and platforms without an outbound backend,
a headless build, or a target with no drop-target implementation)
returns false, in which case the framework cancels the drag
— the pre-existing “pointer left the window ⇒ drag cancels” behavior.
pointer is the device carrying the drag. It is not decoration: on
Wayland wl_data_device::start_drag must be given the serial of the
input event that began the implicit grab, and a finger’s grab was opened
by a wl_touch::down, not a wl_pointer::button — hand the wrong
serial over and the compositor rejects the request silently and sends no
terminal event at all.
Sourcefn set_drop_accepted(&mut self, _accepted: bool)
fn set_drop_accepted(&mut self, _accepted: bool)
Tell the platform whether the widget under an inbound OS drag accepts it, so the OS shows the right cursor and permits (or refuses) the drop.
An inbound backend must answer the drag source synchronously — XDND
requires an XdndStatus for every XdndPosition, and Wayland wants
wl_data_offer::accept + set_actions on the offer — which happens on
the backend’s own thread, before the widget tree has seen the sample. So
the backend’s first answer can only be about format compatibility;
this is how the widget’s actual verdict gets back to the OS. Called by
the tree only when the answer changes.
The negotiated operation follows from the bit: Copy when accepted,
none when refused. Copy is the only operation Teksilo advertises in
either direction, so there is nothing else for a widget to choose — see
docs/drag-and-drop.md §11.5.
Default: no-op — the standalone sink and any platform without an inbound backend.
Sourcefn cancel_os_drag(&mut self)
fn cancel_os_drag(&mut self)
Abandon an OS drag started by Self::begin_os_drag (the user pressed
Escape).
Only backends that drive the drag themselves can honour this. macOS and
Windows hand the drag to a modal OS loop that owns Escape already, and
Wayland’s compositor does the same; X11 tracks the pointer on its own
connection, so without this its drags could only end by releasing the
button. The backend still reports the terminal DropOutcome either way,
so the source widget’s on_drag_ended fires exactly once regardless.
Default: no-op.
Sourcefn soft_keyboard_support(&self) -> SoftKeyboardSupport
fn soft_keyboard_support(&self) -> SoftKeyboardSupport
What the host platform can do about an on-screen keyboard.
Read by a widget that must decide whether a touch-only user can reach a
keyboard at all: where the answer is SoftKeyboardSupport::None the
framework will never raise one and promises nothing about whether the
platform will, so a text surface that expects a finger has to offer its
own affordance.
Default: SoftKeyboardSupport::None, which is the truth for a
standalone tree with no window under it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".