Skip to main content

teksilo_platform/pen/
null.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! The pen source for a platform that has none — X11 and macOS.
5//!
6//! Both could grow one. X11 has XInput2 valuators, which is how GIMP and Krita
7//! read a tablet; macOS has `NSEvent`'s `tabletPoint` / `tabletProximity`
8//! subtypes. Neither is implemented here, for the same reason: winit 0.31 will
9//! supply both through its own `TabletTool*` events, and a shim written now
10//! would be deleted before it earned its maintenance. The two shims that *are*
11//! written cover the platforms where a stylus is common and where the pen data
12//! is already flowing past the app unread — a Windows Ink tablet and a Wayland
13//! session with a Wacom.
14//!
15//! The point of this type is that the absence is **declared** rather than
16//! faked: [`PenCaps::NONE`] flows into the window's `BackendCaps`, so a
17//! consumer asking "does this window report tilt?" gets `false` instead of
18//! reading a zero that could have been a real measurement.
19
20use super::{PenCaps, PenPacket, PenSource};
21
22/// A pen source that never has a pen.
23#[derive(Copy, Clone, Debug, Default)]
24pub struct NullPenSource;
25
26impl NullPenSource {
27    /// The one and only value.
28    pub const fn new() -> Self {
29        Self
30    }
31}
32
33impl PenSource for NullPenSource {
34    fn poll(&mut self, _out: &mut Vec<PenPacket>) {}
35
36    fn capabilities(&self) -> PenCaps {
37        PenCaps::NONE
38    }
39}