@mun-ui/ui 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +114 -2
- package/bin/compile.mjs +38 -0
- package/bin/desktop.mjs +143 -0
- package/bin/dev-protocol.mjs +94 -0
- package/bin/formatter.mjs +109 -0
- package/bin/hot-reload.mjs +38 -0
- package/bin/mun.mjs +538 -0
- package/bin/native.mjs +133 -0
- package/bin/pnpm-workspace.mjs +58 -0
- package/bin/program-patch.mjs +104 -0
- package/bin/project.mjs +322 -0
- package/bin/watch.mjs +316 -0
- package/bin/workflow.mjs +261 -0
- package/dist/astro.d.ts +3 -0
- package/dist/astro.d.ts.map +1 -0
- package/dist/astro.js +3 -0
- package/dist/astro.js.map +1 -0
- package/dist/closures.d.ts +2 -0
- package/dist/closures.d.ts.map +1 -0
- package/dist/closures.js +2 -0
- package/dist/closures.js.map +1 -0
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +2 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +3 -0
- package/dist/core.js.map +1 -0
- package/dist/experimental.d.ts +2 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +2 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +2 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/legacy.d.ts +3 -0
- package/dist/legacy.d.ts.map +1 -0
- package/dist/legacy.js +3 -0
- package/dist/legacy.js.map +1 -0
- package/dist/mun.d.ts +5 -0
- package/dist/mun.d.ts.map +1 -0
- package/dist/mun.js +4 -0
- package/dist/mun.js.map +1 -0
- package/dist/progressive-blur/index.d.ts +8 -0
- package/dist/progressive-blur/index.d.ts.map +1 -0
- package/dist/progressive-blur/index.js +8 -0
- package/dist/progressive-blur/index.js.map +1 -0
- package/dist/progressive-blur/plan.d.ts +3 -0
- package/dist/progressive-blur/plan.d.ts.map +1 -0
- package/dist/progressive-blur/plan.js +3 -0
- package/dist/progressive-blur/plan.js.map +1 -0
- package/dist/react-types.d.ts +2 -0
- package/dist/react-types.d.ts.map +1 -0
- package/dist/react-types.js +2 -0
- package/dist/react-types.js.map +1 -0
- package/dist/rendering-quality.d.ts +4 -0
- package/dist/rendering-quality.d.ts.map +1 -0
- package/dist/rendering-quality.js +4 -0
- package/dist/rendering-quality.js.map +1 -0
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +2 -0
- package/dist/state.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +2 -0
- package/dist/vite.js.map +1 -0
- package/editors/install.mjs +102 -0
- package/editors/lsp/mun-lsp.mjs +123 -0
- package/editors/lsp/service.mjs +306 -0
- package/editors/lsp/source.mjs +58 -0
- package/editors/vscode/client.mjs +40 -0
- package/editors/vscode/dev-client.mjs +83 -0
- package/editors/vscode/discovery.mjs +46 -0
- package/editors/vscode/export.mjs +42 -0
- package/editors/vscode/extension.cjs +226 -0
- package/editors/vscode/language-configuration.json +15 -0
- package/editors/vscode/package.json +119 -0
- package/editors/vscode/protocol.mjs +29 -0
- package/editors/vscode/syntaxes/mun.tmLanguage.json +130 -0
- package/native/Cargo.lock +3581 -0
- package/native/Cargo.toml +21 -0
- package/native/README.md +21 -0
- package/native/mun-native/Cargo.toml +23 -0
- package/native/mun-native/src/accessibility.rs +738 -0
- package/native/mun-native/src/dev.rs +604 -0
- package/native/mun-native/src/host_services.rs +202 -0
- package/native/mun-native/src/lib.rs +2843 -0
- package/native/mun-native/src/main.rs +204 -0
- package/native/mun-native/src/offscreen.rs +393 -0
- package/native/mun-native/src/rect.wgsl +63 -0
- package/native/mun-native/src/text.rs +401 -0
- package/native/mun-native/tests/offscreen_rendering.rs +161 -0
- package/native/mun-native/tests/stress.rs +408 -0
- package/native/mun-native/tests/window_lifecycle.rs +183 -0
- package/native/mun-runtime/Cargo.toml +13 -0
- package/native/mun-runtime/src/accessibility.rs +193 -0
- package/native/mun-runtime/src/collection.rs +1090 -0
- package/native/mun-runtime/src/gesture.rs +1070 -0
- package/native/mun-runtime/src/input.rs +325 -0
- package/native/mun-runtime/src/ir.rs +852 -0
- package/native/mun-runtime/src/kinetics.rs +500 -0
- package/native/mun-runtime/src/layout.rs +258 -0
- package/native/mun-runtime/src/layout_cache.rs +209 -0
- package/native/mun-runtime/src/lib.rs +52 -0
- package/native/mun-runtime/src/motion.rs +1162 -0
- package/native/mun-runtime/src/retained.rs +574 -0
- package/native/mun-runtime/src/runtime.rs +7449 -0
- package/native/mun-runtime/src/scene.rs +567 -0
- package/native/mun-runtime/src/scroll.rs +521 -0
- package/native/mun-runtime/src/scroll_view.rs +220 -0
- package/native/mun-runtime/src/text_edit.rs +670 -0
- package/native/mun-runtime/src/timeline.rs +1534 -0
- package/native/mun-runtime/src/validate.rs +677 -0
- package/native/mun-runtime/tests/accessibility_semantics.rs +168 -0
- package/native/mun-runtime/tests/compiler_contract.rs +110 -0
- package/native/mun-runtime/tests/flexible_frames.rs +47 -0
- package/native/mun-runtime/tests/host_services.rs +107 -0
- package/native/mun-runtime/tests/hot_update.rs +367 -0
- package/native/mun-runtime/tests/incremental_runtime.rs +323 -0
- package/native/mun-runtime/tests/ir_validation.rs +167 -0
- package/native/mun-runtime/tests/keyed_collections.rs +251 -0
- package/native/mun-runtime/tests/minimum_window_size.rs +80 -0
- package/native/mun-runtime/tests/native_controls_style.rs +491 -0
- package/native/mun-runtime/tests/native_demo.rs +285 -0
- package/native/mun-runtime/tests/native_layout_style.rs +175 -0
- package/native/mun-runtime/tests/native_settings_pane.rs +152 -0
- package/native/mun-runtime/tests/priority_proposals.rs +69 -0
- package/native/mun-runtime/tests/scroll_view.rs +403 -0
- package/native/mun-runtime/tests/text_editing.rs +491 -0
- package/native/mun-runtime/tests/text_proposals.rs +42 -0
- package/native/mun-runtime/tests/typography.rs +63 -0
- package/package.json +213 -3
- package/schemas/README.md +19 -0
- package/schemas/semantic-ui-ir-v1.schema.json +2061 -0
- package/templates/desktop/gitignore +5 -0
- package/templates/desktop/package.json +10 -0
- package/templates/desktop/src-tauri/Cargo.toml +14 -0
- package/templates/desktop/src-tauri/build.rs +1 -0
- package/templates/desktop/src-tauri/capabilities/main.json +12 -0
- package/templates/desktop/src-tauri/icons/icon.icns +0 -0
- package/templates/desktop/src-tauri/icons/icon.ico +0 -0
- package/templates/desktop/src-tauri/icons/icon.png +0 -0
- package/templates/desktop/src-tauri/src/main.rs +2 -0
- package/templates/desktop/src-tauri/tauri.conf.json +42 -0
- package/templates/desktop/vite.config.ts +10 -0
- package/templates/native/App.mun +15 -0
- package/templates/native/gitignore +3 -0
- package/templates/native/mun.toml +8 -0
- package/templates/project/gitignore +5 -0
- package/templates/project/index.html +13 -0
- package/templates/project/package.json +24 -0
- package/templates/project/src/App.mun +13 -0
- package/templates/project/src/index.css +30 -0
- package/templates/project/src/main.ts +5 -0
- package/templates/project/tsconfig.json +20 -0
- package/templates/project/vite.config.ts +6 -0
- package/templates/vite/src/App.css +134 -0
- package/templates/vite/src/App.tsx +91 -0
- package/templates/vite/src/index.css +23 -0
- package/templates/vite/vite.config.ts +10 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
use std::collections::{HashMap, HashSet};
|
|
2
|
+
|
|
3
|
+
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
|
4
|
+
pub struct InputPoint {
|
|
5
|
+
pub x: f32,
|
|
6
|
+
pub y: f32,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
impl InputPoint {
|
|
10
|
+
pub const fn new(x: f32, y: f32) -> Self {
|
|
11
|
+
Self { x, y }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
16
|
+
pub struct PointerId(pub u128);
|
|
17
|
+
|
|
18
|
+
impl PointerId {
|
|
19
|
+
pub const MOUSE: Self = Self(0);
|
|
20
|
+
const TOUCH_NAMESPACE: u128 = 1_u128 << 64;
|
|
21
|
+
|
|
22
|
+
/// Construct a touch pointer identity without aliasing the mouse or ordinary
|
|
23
|
+
/// runtime-local pointer IDs representable by a u64.
|
|
24
|
+
pub const fn touch(id: u64) -> Self {
|
|
25
|
+
Self(Self::TOUCH_NAMESPACE | id as u128)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
30
|
+
pub enum PointerButton {
|
|
31
|
+
Primary,
|
|
32
|
+
Secondary,
|
|
33
|
+
Middle,
|
|
34
|
+
Back,
|
|
35
|
+
Forward,
|
|
36
|
+
Other(u16),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
40
|
+
pub enum ButtonState {
|
|
41
|
+
Pressed,
|
|
42
|
+
Released,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
46
|
+
pub struct Modifiers {
|
|
47
|
+
pub shift: bool,
|
|
48
|
+
pub control: bool,
|
|
49
|
+
pub alt: bool,
|
|
50
|
+
pub meta: bool,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
54
|
+
pub enum LogicalKey {
|
|
55
|
+
Tab,
|
|
56
|
+
Enter,
|
|
57
|
+
Space,
|
|
58
|
+
Escape,
|
|
59
|
+
ArrowUp,
|
|
60
|
+
ArrowDown,
|
|
61
|
+
ArrowLeft,
|
|
62
|
+
ArrowRight,
|
|
63
|
+
Home,
|
|
64
|
+
End,
|
|
65
|
+
PageUp,
|
|
66
|
+
PageDown,
|
|
67
|
+
Backspace,
|
|
68
|
+
Delete,
|
|
69
|
+
Character(String),
|
|
70
|
+
Unidentified,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
74
|
+
pub enum PhysicalKey {
|
|
75
|
+
Tab,
|
|
76
|
+
Enter,
|
|
77
|
+
Space,
|
|
78
|
+
Escape,
|
|
79
|
+
ArrowUp,
|
|
80
|
+
ArrowDown,
|
|
81
|
+
ArrowLeft,
|
|
82
|
+
ArrowRight,
|
|
83
|
+
Home,
|
|
84
|
+
End,
|
|
85
|
+
PageUp,
|
|
86
|
+
PageDown,
|
|
87
|
+
Backspace,
|
|
88
|
+
Delete,
|
|
89
|
+
Other,
|
|
90
|
+
Unidentified,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
94
|
+
pub enum KeyState {
|
|
95
|
+
Pressed,
|
|
96
|
+
Released,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// Canonical scroll content movement.
|
|
100
|
+
///
|
|
101
|
+
/// Positive X/Y moves content right/down. Line deltas remain device-scale-neutral
|
|
102
|
+
/// until a semantic scroll container resolves its line extent. Pixel deltas are
|
|
103
|
+
/// logical points after platform-adapter normalization.
|
|
104
|
+
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
105
|
+
pub enum ScrollDelta {
|
|
106
|
+
Lines { x: f32, y: f32 },
|
|
107
|
+
Pixels { x: f32, y: f32 },
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
111
|
+
pub enum ScrollPhase {
|
|
112
|
+
Began,
|
|
113
|
+
Changed,
|
|
114
|
+
Ended,
|
|
115
|
+
Cancelled,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#[derive(Clone, Debug, PartialEq)]
|
|
119
|
+
pub enum InputEvent {
|
|
120
|
+
PointerMoved {
|
|
121
|
+
pointer: PointerId,
|
|
122
|
+
position: InputPoint,
|
|
123
|
+
},
|
|
124
|
+
PointerButton {
|
|
125
|
+
pointer: PointerId,
|
|
126
|
+
button: PointerButton,
|
|
127
|
+
state: ButtonState,
|
|
128
|
+
},
|
|
129
|
+
ModifiersChanged(Modifiers),
|
|
130
|
+
Key {
|
|
131
|
+
logical: LogicalKey,
|
|
132
|
+
physical: PhysicalKey,
|
|
133
|
+
state: KeyState,
|
|
134
|
+
repeat: bool,
|
|
135
|
+
},
|
|
136
|
+
TextEdit(crate::text_edit::TextEdit),
|
|
137
|
+
ClipboardWriteCompleted {
|
|
138
|
+
request: u64,
|
|
139
|
+
success: bool,
|
|
140
|
+
},
|
|
141
|
+
/// Host response to `ClipboardRequest::Read`. `None` means the clipboard was
|
|
142
|
+
/// unavailable, empty, or held no text representation.
|
|
143
|
+
ClipboardReadCompleted {
|
|
144
|
+
request: u64,
|
|
145
|
+
text: Option<String>,
|
|
146
|
+
},
|
|
147
|
+
TextInput {
|
|
148
|
+
text: String,
|
|
149
|
+
},
|
|
150
|
+
Scroll {
|
|
151
|
+
pointer: Option<PointerId>,
|
|
152
|
+
delta: ScrollDelta,
|
|
153
|
+
phase: ScrollPhase,
|
|
154
|
+
},
|
|
155
|
+
Cancel {
|
|
156
|
+
pointer: Option<PointerId>,
|
|
157
|
+
},
|
|
158
|
+
WindowFocusChanged(bool),
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// Service requests are consumed by the platform host, not controls or rendering.
|
|
162
|
+
///
|
|
163
|
+
/// Host contract: `Write` is fire-and-forget (copy never mutates text). `Cut`
|
|
164
|
+
/// must be acknowledged with `InputEvent::ClipboardWriteCompleted`; the runtime
|
|
165
|
+
/// deletes the selection only for a successful acknowledgement of the latest
|
|
166
|
+
/// cut while the field, binding and selection are unchanged. `Read` must be
|
|
167
|
+
/// answered with `InputEvent::ClipboardReadCompleted`, possibly asynchronously.
|
|
168
|
+
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
169
|
+
pub enum ClipboardRequest {
|
|
170
|
+
Write(String),
|
|
171
|
+
Cut { request: u64, text: String },
|
|
172
|
+
Read { request: u64, target: String },
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
176
|
+
pub struct InputOutcome {
|
|
177
|
+
pub handled: bool,
|
|
178
|
+
pub needs_redraw: bool,
|
|
179
|
+
pub focus_changed: bool,
|
|
180
|
+
pub pressed_changed: bool,
|
|
181
|
+
pub activated: bool,
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#[derive(Debug, Default)]
|
|
185
|
+
pub(crate) struct InputState {
|
|
186
|
+
pointer_positions: HashMap<PointerId, InputPoint>,
|
|
187
|
+
primary_captures: HashMap<PointerId, String>,
|
|
188
|
+
keyboard_capture: Option<String>,
|
|
189
|
+
modifiers: Modifiers,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
impl InputState {
|
|
193
|
+
pub(crate) fn set_pointer_position(&mut self, pointer: PointerId, position: InputPoint) {
|
|
194
|
+
self.pointer_positions.insert(pointer, position);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
pub(crate) fn pointer_position(&self, pointer: PointerId) -> Option<InputPoint> {
|
|
198
|
+
self.pointer_positions.get(&pointer).copied()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
pub(crate) fn primary_capture(&self, pointer: PointerId) -> Option<&str> {
|
|
202
|
+
self.primary_captures.get(&pointer).map(String::as_str)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
pub(crate) fn capture_primary(&mut self, pointer: PointerId, action: String) -> bool {
|
|
206
|
+
if self.primary_captures.contains_key(&pointer) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
self.primary_captures.insert(pointer, action);
|
|
210
|
+
true
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
pub(crate) fn take_primary_capture(&mut self, pointer: PointerId) -> Option<String> {
|
|
214
|
+
self.primary_captures.remove(&pointer)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
pub(crate) fn retain_primary_captures(&mut self, valid_actions: &HashSet<String>) -> bool {
|
|
218
|
+
let before = self.primary_captures.len();
|
|
219
|
+
self.primary_captures
|
|
220
|
+
.retain(|_, action| valid_actions.contains(action));
|
|
221
|
+
self.primary_captures.len() != before
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
pub(crate) fn remove_captures_for_actions(
|
|
225
|
+
&mut self,
|
|
226
|
+
replaced_actions: &HashSet<String>,
|
|
227
|
+
) -> bool {
|
|
228
|
+
if replaced_actions.is_empty() {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let primary_before = self.primary_captures.len();
|
|
233
|
+
self.primary_captures
|
|
234
|
+
.retain(|_, action| !replaced_actions.contains(action));
|
|
235
|
+
let primary_changed = self.primary_captures.len() != primary_before;
|
|
236
|
+
|
|
237
|
+
let keyboard_changed = self
|
|
238
|
+
.keyboard_capture
|
|
239
|
+
.as_ref()
|
|
240
|
+
.is_some_and(|action| replaced_actions.contains(action));
|
|
241
|
+
if keyboard_changed {
|
|
242
|
+
self.keyboard_capture = None;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
primary_changed || keyboard_changed
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
pub(crate) fn keyboard_capture(&self) -> Option<&str> {
|
|
249
|
+
self.keyboard_capture.as_deref()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
pub(crate) fn capture_keyboard(&mut self, action: String) -> bool {
|
|
253
|
+
let changed = self.keyboard_capture.as_deref() != Some(action.as_str());
|
|
254
|
+
self.keyboard_capture = Some(action);
|
|
255
|
+
changed
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
pub(crate) fn take_keyboard_capture(&mut self) -> Option<String> {
|
|
259
|
+
self.keyboard_capture.take()
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
pub(crate) fn clear_keyboard_capture(&mut self) -> bool {
|
|
263
|
+
self.keyboard_capture.take().is_some()
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
pub(crate) fn set_modifiers(&mut self, modifiers: Modifiers) {
|
|
267
|
+
self.modifiers = modifiers;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
pub(crate) fn modifiers(&self) -> Modifiers {
|
|
271
|
+
self.modifiers
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
pub(crate) fn cancel_pointer(&mut self, pointer: Option<PointerId>) -> bool {
|
|
275
|
+
if let Some(pointer) = pointer {
|
|
276
|
+
self.pointer_positions.remove(&pointer);
|
|
277
|
+
self.primary_captures.remove(&pointer).is_some()
|
|
278
|
+
} else {
|
|
279
|
+
self.pointer_positions.clear();
|
|
280
|
+
let had_capture = !self.primary_captures.is_empty();
|
|
281
|
+
self.primary_captures.clear();
|
|
282
|
+
had_capture
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#[cfg(test)]
|
|
288
|
+
mod tests {
|
|
289
|
+
use super::*;
|
|
290
|
+
|
|
291
|
+
#[test]
|
|
292
|
+
fn primary_capture_is_stable_until_release_or_cancel() {
|
|
293
|
+
let mut input = InputState::default();
|
|
294
|
+
let pointer = PointerId(91);
|
|
295
|
+
|
|
296
|
+
assert!(input.capture_primary(pointer, "first".into()));
|
|
297
|
+
assert!(!input.capture_primary(pointer, "second".into()));
|
|
298
|
+
assert_eq!(input.primary_capture(pointer), Some("first"));
|
|
299
|
+
|
|
300
|
+
assert_eq!(
|
|
301
|
+
input.take_primary_capture(pointer).as_deref(),
|
|
302
|
+
Some("first")
|
|
303
|
+
);
|
|
304
|
+
assert!(input.capture_primary(pointer, "second".into()));
|
|
305
|
+
assert_eq!(input.primary_capture(pointer), Some("second"));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
#[test]
|
|
309
|
+
fn semantic_replacement_drops_only_matching_action_captures() {
|
|
310
|
+
let mut input = InputState::default();
|
|
311
|
+
let replaced_pointer = PointerId(1);
|
|
312
|
+
let stable_pointer = PointerId(2);
|
|
313
|
+
input.capture_primary(replaced_pointer, "replaced".to_owned());
|
|
314
|
+
input.capture_primary(stable_pointer, "stable".to_owned());
|
|
315
|
+
input.capture_keyboard("replaced".to_owned());
|
|
316
|
+
|
|
317
|
+
let replaced = HashSet::from(["replaced".to_owned()]);
|
|
318
|
+
assert!(input.remove_captures_for_actions(&replaced));
|
|
319
|
+
|
|
320
|
+
assert_eq!(input.primary_capture(replaced_pointer), None);
|
|
321
|
+
assert_eq!(input.primary_capture(stable_pointer), Some("stable"));
|
|
322
|
+
assert_eq!(input.keyboard_capture(), None);
|
|
323
|
+
assert!(!input.remove_captures_for_actions(&replaced));
|
|
324
|
+
}
|
|
325
|
+
}
|