zng_app/view_process/raw_events.rs
1//! Events directly from the view-process targeting the app windows.
2//!
3//! These events get processed by app extensions to generate the events used in widgets, for example
4//! the `KEYBOARD` service maps the [`RAW_KEY_INPUT_EVENT`] into focus targeted events.
5//!
6//! # Synthetic Input
7//!
8//! You can [`notify`] these events to fake hardware input, please be careful that you mimic the exact sequence a real
9//! hardware would generate, [app extensions] can assume that the raw events are correct. The [`InputDeviceId`] for fake
10//! input must be unique but constant for each distinctive *synthetic event source*.
11//!
12//! [`RAW_KEY_INPUT_EVENT`]: crate::view_process::raw_events::RAW_KEY_INPUT_EVENT
13//! [`notify`]: crate::event::Event::notify
14//! [`InputDeviceId`]: crate::view_process::raw_device_events::InputDeviceId
15
16use zng_layout::unit::{DipPoint, DipSideOffsets, DipSize, Factor, PxPoint};
17use zng_txt::Txt;
18use zng_var::WeakEq;
19use zng_view_api::{
20 AxisId, DragDropId, Ime,
21 api_extension::{ApiExtensionId, ApiExtensionPayload},
22 audio::{AudioDecoded, AudioMetadata},
23 config::{AnimationsConfig, ColorsConfig, FontAntiAliasing, KeyRepeatConfig, LocaleConfig, MultiClickConfig, TouchConfig},
24 drag_drop::{DragDropData, DragDropEffect},
25 image::{ImageDecoded, ImageMetadata},
26 keyboard::{Key, KeyCode, KeyLocation, KeyState},
27 mouse::{ButtonState, MouseButton, MouseScrollDelta},
28 touch::{TouchPhase, TouchUpdate},
29 window::{EventCause, FrameId, FrameWaitId, HeadlessOpenData, MonitorInfo, WindowStateAll},
30};
31
32use crate::{
33 event::{event, event_args},
34 view_process::{AudioOutputId, ViewImageHandle, WeakViewAudioHandle, WeakViewAudioOutput},
35 window::{MonitorId, WindowId},
36};
37
38use super::{WeakViewHeadless, WeakViewImageHandle, WeakViewWindow, WindowOpenData, raw_device_events::InputDeviceId};
39
40event_args! {
41 /// Arguments for the [`RAW_KEY_INPUT_EVENT`].
42 pub struct RawKeyInputArgs {
43 /// Window that received the event.
44 pub window_id: WindowId,
45
46 /// Keyboard device that generated the event.
47 pub device_id: InputDeviceId,
48
49 /// Physical key.
50 pub key_code: KeyCode,
51
52 /// The location of the key on the keyboard.
53 pub key_location: KeyLocation,
54
55 /// If the key was pressed or released.
56 pub state: KeyState,
57
58 /// Semantic key.
59 ///
60 /// Pressing `Shift+A` key will produce `Key::Char('a')` in QWERTY keyboards, the modifiers are not applied.
61 pub key: Key,
62 /// Semantic key modified by the current active modifiers.
63 ///
64 /// Pressing `Shift+A` key will produce `Key::Char('A')` in QWERTY keyboards, the modifiers are applied.
65 pub key_modified: Key,
66
67 /// Text typed.
68 ///
69 /// This is only set for `KeyState::Pressed` of a key that generates text.
70 ///
71 /// This is usually the `key_modified` char, but is also `'\r'` for `Key::Enter`. On Windows when a dead key was
72 /// pressed earlier but cannot be combined with the character from this key press, the produced text
73 /// will consist of two characters: the dead-key-character followed by the character resulting from this key press.
74 pub text: Txt,
75
76 ..
77
78 /// Broadcast to all widgets.
79 fn is_in_target(&self, id: WidgetId) -> bool {
80 true
81 }
82 }
83
84 /// Arguments for the [`RAW_IME_EVENT`].
85 pub struct RawImeArgs {
86 /// Window that received the event.
87 pub window_id: WindowId,
88
89 /// The IME event.
90 pub ime: Ime,
91
92 ..
93
94 /// Broadcast to all widgets.
95 fn is_in_target(&self, id: WidgetId) -> bool {
96 true
97 }
98 }
99
100 /// Arguments for the [`RAW_WINDOW_FOCUS_EVENT`].
101 pub struct RawWindowFocusArgs {
102 /// Window that load focus.
103 pub prev_focus: Option<WindowId>,
104
105 /// Window that got focus.
106 pub new_focus: Option<WindowId>,
107
108 ..
109
110 /// Broadcast to all widgets.
111 fn is_in_target(&self, id: WidgetId) -> bool {
112 true
113 }
114 }
115
116 /// Arguments for the [`RAW_FRAME_RENDERED_EVENT`].
117 pub struct RawFrameRenderedArgs {
118 /// Window that presents the rendered frame.
119 pub window_id: WindowId,
120
121 /// Frame tag.
122 pub frame_id: FrameId,
123
124 /// The frame pixels if it was requested when the frame request was sent to the view process.
125 ///
126 /// The handle can be upgraded on hook only, after it is dropped. This is so the
127 /// latest event does not keep the image alive indefinitely.
128 pub frame_image: Option<WeakEq<(ViewImageHandle, ImageDecoded)>>,
129
130 ..
131
132 /// Broadcast to all widgets.
133 fn is_in_target(&self, id: WidgetId) -> bool {
134 true
135 }
136 }
137
138 /// Arguments for the [`RAW_WINDOW_CHANGED_EVENT`].
139 pub struct RawWindowChangedArgs {
140 /// Window that has moved, resized or has a state change.
141 pub window_id: WindowId,
142
143 /// New state if any part of it has changed.
144 pub state: Option<WindowStateAll>,
145
146 /// New window position if it was moved.
147 ///
148 /// The values are `(global_position, position_in_monitor)`.
149 pub position: Option<(PxPoint, DipPoint)>,
150
151 /// New window monitor.
152 ///
153 /// The window's monitor change when it is moved enough so that most of the
154 /// client area is in the new monitor screen.
155 pub monitor: Option<MonitorId>,
156
157 /// New window size if it was resized.
158 pub size: Option<DipSize>,
159
160 /// New window safe padding.
161 pub safe_padding: Option<DipSideOffsets>,
162
163 /// If the app or operating system caused the change.
164 pub cause: EventCause,
165
166 /// If the view-process is blocking the event loop for a time waiting for a frame for the new `size` this
167 /// ID must be send with the frame to signal that it is the frame for the new size.
168 ///
169 /// Event loop implementations can use this to resize without visible artifacts
170 /// like the clear color flashing on the window corners, there is a timeout to this delay but it
171 /// can be a noticeable stutter, a [`render`] or [`render_update`] request for the window unblocks the loop early
172 /// to continue the resize operation.
173 ///
174 /// [`render`]: crate::view_process::ViewRenderer::render
175 /// [`render_update`]: crate::view_process::ViewRenderer::render_update
176 pub frame_wait_id: Option<FrameWaitId>,
177
178 ..
179
180 /// Broadcast to all widgets.
181 fn is_in_target(&self, id: WidgetId) -> bool {
182 true
183 }
184 }
185
186 /// Arguments for the [`RAW_WINDOW_OPEN_EVENT`].
187 pub struct RawWindowOpenArgs {
188 /// Window that finished opening.
189 pub window_id: WindowId,
190
191 /// Live connection to the window in the view-process.
192 ///
193 /// The handle can be upgraded on hook only, after it is dropped. This is so the
194 /// latest event does not keep the window alive indefinitely.
195 pub window: WeakViewWindow,
196
197 /// Extra data send by the view-process.
198 pub data: WindowOpenData,
199
200 ..
201
202 /// Broadcast to all widgets.
203 fn is_in_target(&self, id: WidgetId) -> bool {
204 true
205 }
206 }
207
208 /// Arguments for the [`RAW_HEADLESS_OPEN_EVENT`].
209 pub struct RawHeadlessOpenArgs {
210 /// Window id that represents the headless surface that finished opening.
211 pub window_id: WindowId,
212
213 /// Live connection to the headless surface in the view-process.
214 ///
215 /// The handle can be upgraded on hook only, after it is dropped. This is so the
216 /// latest event does not keep the surface alive indefinitely.
217 pub surface: WeakViewHeadless,
218
219 /// Extra data send by the view-process.
220 pub data: HeadlessOpenData,
221
222 ..
223
224 /// Broadcast to all widgets.
225 fn is_in_target(&self, id: WidgetId) -> bool {
226 true
227 }
228 }
229
230 /// Arguments for the [`RAW_WINDOW_OR_HEADLESS_OPEN_ERROR_EVENT`].
231 pub struct RawWindowOrHeadlessOpenErrorArgs {
232 /// Window id that failed to open.
233 pub window_id: WindowId,
234 /// Error message from the view-process.
235 pub error: Txt,
236
237 ..
238
239 /// Broadcast to all widgets.
240 fn is_in_target(&self, id: WidgetId) -> bool {
241 true
242 }
243 }
244
245 /// Arguments for the [`RAW_WINDOW_CLOSE_REQUESTED_EVENT`].
246 pub struct RawWindowCloseRequestedArgs {
247 /// Window that was requested to close.
248 pub window_id: WindowId,
249
250 ..
251
252 /// Broadcast to all widgets.
253 fn is_in_target(&self, id: WidgetId) -> bool {
254 true
255 }
256 }
257
258 /// Arguments for the [`RAW_WINDOW_CLOSE_EVENT`].
259 pub struct RawWindowCloseArgs {
260 /// Window that has closed.
261 pub window_id: WindowId,
262
263 ..
264
265 /// Broadcast to all widgets.
266 fn is_in_target(&self, id: WidgetId) -> bool {
267 true
268 }
269 }
270
271 /// Arguments for the [`RAW_DRAG_HOVERED_EVENT`].
272 pub struct RawDragHoveredArgs {
273 /// Window where it was dragged over.
274 pub window_id: WindowId,
275
276 /// Data payload.
277 pub data: Vec<DragDropData>,
278 /// Allowed effects.
279 pub allowed: DragDropEffect,
280
281 ..
282
283 /// Broadcast to all widgets.
284 fn is_in_target(&self, id: WidgetId) -> bool {
285 true
286 }
287 }
288
289 /// Arguments for the [`RAW_DRAG_MOVED_EVENT`].
290 pub struct RawDragMovedArgs {
291 /// Window that is hovered by drag&drop.
292 pub window_id: WindowId,
293
294 /// Cursor positions in between the previous event and this one.
295 ///
296 /// Drag move events can be coalesced, i.e. multiple moves packed into a single event.
297 pub coalesced_pos: Vec<DipPoint>,
298
299 /// Position of the cursor over the window, (0, 0) is the top-left.
300 pub position: DipPoint,
301
302 ..
303
304 /// Broadcast to all widgets.
305 fn is_in_target(&self, id: WidgetId) -> bool {
306 true
307 }
308 }
309
310 /// Arguments for the [`RAW_DRAG_DROPPED_EVENT`].
311 pub struct RawDragDroppedArgs {
312 /// Window where it was dropped.
313 pub window_id: WindowId,
314
315 /// Data payload.
316 pub data: Vec<DragDropData>,
317 /// Allowed effects.
318 pub allowed: DragDropEffect,
319 /// ID of this drop operation.
320 ///
321 /// Handlers must call `drag_dropped` with this ID and what effect was applied to the data.
322 pub drop_id: DragDropId,
323
324 ..
325
326 /// Broadcast to all widgets.
327 fn is_in_target(&self, id: WidgetId) -> bool {
328 true
329 }
330 }
331
332 /// Arguments for the [`RAW_DRAG_CANCELLED_EVENT`].
333 pub struct RawDragCancelledArgs {
334 /// Window where the file was previously dragged over.
335 pub window_id: WindowId,
336
337 ..
338
339 /// Broadcast to all widgets.
340 fn is_in_target(&self, id: WidgetId) -> bool {
341 true
342 }
343 }
344
345 /// Arguments for the [`RAW_APP_DRAG_ENDED_EVENT`].
346 pub struct RawAppDragEndedArgs {
347 /// Window that started the drag operation.
348 pub window_id: WindowId,
349
350 /// ID of the drag & drop operation.
351 pub id: DragDropId,
352
353 /// Effect applied to the data by the drop target.
354 ///
355 /// Is a single flag if the data was dropped in a valid drop target, or is empty if was canceled.
356 pub applied: DragDropEffect,
357
358 ..
359
360 /// Broadcast to all widgets.
361 fn is_in_target(&self, id: WidgetId) -> bool {
362 true
363 }
364 }
365
366 /// Arguments for the [`RAW_MOUSE_MOVED_EVENT`].
367 pub struct RawMouseMovedArgs {
368 /// Window the mouse was moved over.
369 pub window_id: WindowId,
370
371 /// Device that generated this event.
372 pub device_id: InputDeviceId,
373
374 /// Positions of the mouse in between the previous event and this one.
375 ///
376 /// Mouse move events can be coalesced, i.e. multiple mouse moves packed into a single event.
377 pub coalesced_pos: Vec<DipPoint>,
378
379 /// Position of the mouse over the window, (0, 0) is the top-left.
380 pub position: DipPoint,
381
382 ..
383
384 /// Broadcast to all widgets.
385 fn is_in_target(&self, id: WidgetId) -> bool {
386 true
387 }
388 }
389
390 /// Arguments for the [`RAW_MOUSE_ENTERED_EVENT`] and [`RAW_MOUSE_LEFT_EVENT`].
391 pub struct RawMouseArgs {
392 /// Window the mouse entered or left.
393 pub window_id: WindowId,
394
395 /// Device that generated this event.
396 pub device_id: InputDeviceId,
397
398 ..
399
400 /// Broadcast to all widgets.
401 fn is_in_target(&self, id: WidgetId) -> bool {
402 true
403 }
404 }
405
406 /// Arguments for the [`RAW_MOUSE_WHEEL_EVENT`].
407 pub struct RawMouseWheelArgs {
408 /// Window that is hovered by the mouse.
409 pub window_id: WindowId,
410
411 /// Device that generated this event.
412 pub device_id: InputDeviceId,
413
414 /// Wheel motion delta, value is in pixels if the *wheel* is a touchpad.
415 pub delta: MouseScrollDelta,
416
417 /// Touch state if the device that generated the event is a touchpad.
418 pub phase: TouchPhase,
419
420 ..
421
422 /// Broadcast to all widgets.
423 fn is_in_target(&self, id: WidgetId) -> bool {
424 true
425 }
426 }
427
428 /// Arguments for the [`RAW_MOUSE_INPUT_EVENT`].
429 pub struct RawMouseInputArgs {
430 /// Window that is hovered by the mouse.
431 pub window_id: WindowId,
432
433 /// Device that generated this event.
434 pub device_id: InputDeviceId,
435
436 /// If the button was pressed or released.
437 pub state: ButtonState,
438
439 /// What button was pressed or released.
440 pub button: MouseButton,
441
442 ..
443
444 /// Broadcast to all widgets.
445 fn is_in_target(&self, id: WidgetId) -> bool {
446 true
447 }
448 }
449
450 /// Arguments for the [`RAW_TOUCHPAD_PRESSURE_EVENT`].
451 pub struct RawTouchpadPressureArgs {
452 /// Window that is touched.
453 pub window_id: WindowId,
454
455 /// Device that generated this event.
456 pub device_id: InputDeviceId,
457
458 /// Pressure level between 0 and 1.
459 pub pressure: Factor,
460
461 /// Click level.
462 pub stage: i64,
463
464 ..
465
466 /// Broadcast to all widgets.
467 fn is_in_target(&self, id: WidgetId) -> bool {
468 true
469 }
470 }
471
472 /// Arguments for the [`RAW_AXIS_MOTION_EVENT`].
473 pub struct RawAxisMotionArgs {
474 /// Window that received the event.
475 pub window_id: WindowId,
476
477 /// Device that generated the event.
478 pub device_id: InputDeviceId,
479
480 /// Analog axis.
481 pub axis: AxisId,
482
483 /// Motion amount.
484 pub value: f64,
485
486 ..
487
488 /// Broadcast to all widgets.
489 fn is_in_target(&self, id: WidgetId) -> bool {
490 true
491 }
492 }
493
494 /// Arguments for the [`RAW_TOUCH_EVENT`].
495 pub struct RawTouchArgs {
496 /// Window that was touched.
497 pub window_id: WindowId,
498
499 /// Device that generated this event.
500 pub device_id: InputDeviceId,
501
502 /// Coalesced touch updates.
503 pub touches: Vec<TouchUpdate>,
504
505 ..
506
507 /// Broadcast to all widgets.
508 fn is_in_target(&self, id: WidgetId) -> bool {
509 true
510 }
511 }
512
513 /// Arguments for the [`RAW_SCALE_FACTOR_CHANGED_EVENT`].
514 pub struct RawScaleFactorChangedArgs {
515 /// Monitor that has changed.
516 pub monitor_id: MonitorId,
517
518 /// Window in the monitor that has changed.
519 pub windows: Vec<WindowId>,
520
521 /// New pixel scale factor.
522 pub scale_factor: Factor,
523
524 ..
525
526 /// Broadcast to all widgets.
527 fn is_in_target(&self, id: WidgetId) -> bool {
528 true
529 }
530 }
531
532 /// Arguments for the [`RAW_MONITORS_CHANGED_EVENT`].
533 pub struct RawMonitorsChangedArgs {
534 /// Up-to-date monitors list.
535 pub available_monitors: Vec<(MonitorId, MonitorInfo)>,
536
537 ..
538
539 /// Broadcast to all widgets.
540 fn is_in_target(&self, id: WidgetId) -> bool {
541 true
542 }
543 }
544
545 /// Arguments for [`RAW_IMAGE_METADATA_DECODED_EVENT`].
546 pub struct RawImageMetadataDecodedArgs {
547 /// Handle to the image in the view-process.
548 ///
549 /// The handle can be upgraded on hook only, after it is dropped. This is so the
550 /// latest event does not keep the image alive indefinitely.
551 pub handle: WeakViewImageHandle,
552 /// Image metadata.
553 pub meta: ImageMetadata,
554
555 ..
556
557 /// Broadcast to all widgets.
558 fn is_in_target(&self, id: WidgetId) -> bool {
559 true
560 }
561 }
562
563 /// Arguments for the [`RAW_IMAGE_DECODED_EVENT`].
564 pub struct RawImageDecodedArgs {
565 /// Handle to the image in the view-process.
566 ///
567 /// The handle can be upgraded on hook only, after it is dropped. This is so the
568 /// latest event does not keep the image alive indefinitely.
569 pub handle: WeakViewImageHandle,
570 /// Image data.
571 ///
572 /// The handle can be upgraded on hook only, after it is dropped.
573 pub image: WeakEq<ImageDecoded>,
574
575 ..
576
577 /// Broadcast to all widgets.
578 fn is_in_target(&self, id: WidgetId) -> bool {
579 true
580 }
581 }
582
583 /// Arguments for the [`RAW_IMAGE_DECODE_ERROR_EVENT`].
584 pub struct RawImageDecodeErrorArgs {
585 /// Handle that identifies the image request.
586 ///
587 /// The image data is already removed in the view-process.
588 ///
589 /// The handle can be upgraded on hook only, after it is dropped.
590 pub handle: WeakViewImageHandle,
591 /// Error message.
592 pub error: Txt,
593
594 ..
595
596 /// Broadcast to all widgets.
597 fn is_in_target(&self, id: WidgetId) -> bool {
598 true
599 }
600 }
601
602 /// Arguments for [`RAW_AUDIO_METADATA_DECODED_EVENT`].
603 pub struct RawAudioMetadataDecodedArgs {
604 /// Handle to the audio in the view-process.
605 ///
606 /// The handle can be upgraded on hook only, after it is dropped. This is so the
607 /// latest event does not keep the audio alive indefinitely.
608 pub handle: WeakViewAudioHandle,
609 /// Audio metadata.
610 pub meta: AudioMetadata,
611
612 ..
613
614 /// Broadcast to all widgets.
615 fn is_in_target(&self, id: WidgetId) -> bool {
616 true
617 }
618 }
619
620 /// Arguments for the [`RAW_AUDIO_DECODED_EVENT`].
621 pub struct RawAudioDecodedArgs {
622 /// Handle to the audio in the view-process.
623 /// The handle can be upgraded on hook only, after it is dropped. This is so the
624 /// latest event does not keep the audio alive indefinitely.
625 pub handle: WeakViewAudioHandle,
626 /// Audio data.
627 pub audio: WeakEq<AudioDecoded>,
628
629 ..
630
631 /// Broadcast to all widgets.
632 fn is_in_target(&self, id: WidgetId) -> bool {
633 true
634 }
635 }
636
637 /// Arguments for the [`RAW_AUDIO_DECODE_ERROR_EVENT`].
638 pub struct RawAudioDecodeErrorArgs {
639 /// Handle that identifies the audio request.
640 ///
641 /// The audio data is already removed in the view-process.
642 ///
643 /// The handle can be upgraded on hook only, after it is dropped. This is so the
644 /// latest event does not keep the audio alive indefinitely.
645 pub handle: WeakViewAudioHandle,
646 /// Error message.
647 pub error: Txt,
648
649 ..
650
651 /// Broadcast to all widgets.
652 fn is_in_target(&self, id: WidgetId) -> bool {
653 true
654 }
655 }
656
657 /// Arguments for the [`RAW_AUDIO_OUTPUT_OPEN_EVENT`].
658 pub struct RawAudioOutputOpenArgs {
659 /// Output that finished opening.
660 pub output_id: AudioOutputId,
661
662 /// Live connection to audio output stream.
663 ///
664 /// The handle can be upgraded on hook only, after it is dropped. This is so the
665 /// latest event does not keep the image audio indefinitely.
666 pub output: WeakViewAudioOutput,
667
668 ..
669
670 /// Broadcast to all widgets.
671 fn is_in_target(&self, id: WidgetId) -> bool {
672 true
673 }
674 }
675
676 /// Arguments for the [`RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT`].
677 pub struct RawAudioOutputOpenErrorArgs {
678 /// Output that failed to open.
679 pub output_id: AudioOutputId,
680 /// Error opening output.
681 pub error: Txt,
682
683 ..
684
685 /// Broadcast to all widgets.
686 fn is_in_target(&self, id: WidgetId) -> bool {
687 true
688 }
689 }
690
691 /// [`RAW_FONT_CHANGED_EVENT`] arguments.
692 pub struct RawFontChangedArgs {
693
694 ..
695
696 /// Broadcast to all widgets.
697 fn is_in_target(&self, id: WidgetId) -> bool {
698 true
699 }
700 }
701
702 /// Arguments for the [`RAW_FONT_AA_CHANGED_EVENT`].
703 pub struct RawFontAaChangedArgs {
704 /// The new anti-aliasing config.
705 pub aa: FontAntiAliasing,
706
707 ..
708
709 /// Broadcast to all widgets.
710 fn is_in_target(&self, id: WidgetId) -> bool {
711 true
712 }
713 }
714
715 /// Arguments for the [`RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT`].
716 pub struct RawMultiClickConfigChangedArgs {
717 /// New config.
718 pub config: MultiClickConfig,
719
720 ..
721
722 /// Broadcast to all widgets.
723 fn is_in_target(&self, id: WidgetId) -> bool {
724 true
725 }
726 }
727
728 /// Arguments for the [`RAW_ANIMATIONS_CONFIG_CHANGED_EVENT`].
729 pub struct RawAnimationsConfigChangedArgs {
730 /// New config.
731 pub config: AnimationsConfig,
732
733 ..
734
735 /// Broadcast to all widgets.
736 fn is_in_target(&self, id: WidgetId) -> bool {
737 true
738 }
739 }
740
741 /// Arguments for the [`RAW_KEY_REPEAT_CONFIG_CHANGED_EVENT`].
742 pub struct RawKeyRepeatConfigChangedArgs {
743 /// New config.
744 pub config: KeyRepeatConfig,
745
746 ..
747
748 /// Broadcast to all widgets.
749 fn is_in_target(&self, id: WidgetId) -> bool {
750 true
751 }
752 }
753
754 /// Arguments for the [`RAW_TOUCH_CONFIG_CHANGED_EVENT`].
755 pub struct RawTouchConfigChangedArgs {
756 /// New config.
757 pub config: TouchConfig,
758
759 ..
760
761 /// Broadcast to all widgets.
762 fn is_in_target(&self, id: WidgetId) -> bool {
763 true
764 }
765 }
766
767 /// Arguments for the [`RAW_LOCALE_CONFIG_CHANGED_EVENT`].
768 pub struct RawLocaleChangedArgs {
769 /// New config.
770 pub config: LocaleConfig,
771
772 ..
773
774 /// Broadcast to all widgets.
775 fn is_in_target(&self, id: WidgetId) -> bool {
776 true
777 }
778 }
779
780 /// Arguments for the [`RAW_COLORS_CONFIG_CHANGED_EVENT`].
781 pub struct RawColorsConfigChangedArgs {
782 /// New config.
783 pub config: ColorsConfig,
784
785 ..
786
787 /// Broadcast to all widgets.
788 fn is_in_target(&self, id: WidgetId) -> bool {
789 true
790 }
791 }
792
793 /// Arguments for the [`RAW_EXTENSION_EVENT`].
794 pub struct RawExtensionEventArgs {
795 /// Id of the sender extension.
796 pub extension_id: ApiExtensionId,
797 /// Event payload.
798 pub payload: ApiExtensionPayload,
799
800 ..
801
802 /// Broadcast to all widgets.
803 fn is_in_target(&self, id: WidgetId) -> bool {
804 true
805 }
806 }
807
808 /// Arguments for [`LOW_MEMORY_EVENT`].
809 pub struct LowMemoryArgs {
810
811 ..
812
813 /// Broadcast to all widgets.
814 fn is_in_target(&self, id: WidgetId) -> bool {
815 true
816 }
817 }
818}
819
820event! {
821 /// A key press or release targeting a window.
822 ///
823 /// This event represents a key input directly from the operating system. It is processed
824 /// by `KeyboardManager` to generate the `KEY_INPUT_EVENT` that actually targets the focused widget.
825 ///
826 /// *See also the [module level documentation](self) for details of how you can fake this event*
827 pub static RAW_KEY_INPUT_EVENT: RawKeyInputArgs;
828
829 /// An IME event was received by a window.
830 pub static RAW_IME_EVENT: RawImeArgs;
831
832 /// A window received or lost focus.
833 pub static RAW_WINDOW_FOCUS_EVENT: RawWindowFocusArgs;
834
835 /// A window was moved, resized or has a state change.
836 ///
837 /// This event aggregates events moves, resizes and other state changes into a
838 /// single event to simplify tracking composite changes, for example, the window changes size and position
839 /// when maximized, this can be trivially observed with this event.
840 pub static RAW_WINDOW_CHANGED_EVENT: RawWindowChangedArgs;
841
842 /// A frame finished rendering and was presented in a window.
843 pub static RAW_FRAME_RENDERED_EVENT: RawFrameRenderedArgs;
844
845 /// A window has finished initializing in the view-process.
846 pub static RAW_WINDOW_OPEN_EVENT: RawWindowOpenArgs;
847
848 /// A headless surface has finished initializing in the view-process.
849 pub static RAW_HEADLESS_OPEN_EVENT: RawHeadlessOpenArgs;
850
851 /// A window or headless surface initialization failed in the view-process.
852 pub static RAW_WINDOW_OR_HEADLESS_OPEN_ERROR_EVENT: RawWindowOrHeadlessOpenErrorArgs;
853
854 /// A window was requested to close.
855 pub static RAW_WINDOW_CLOSE_REQUESTED_EVENT: RawWindowCloseRequestedArgs;
856
857 /// A window was destroyed.
858 pub static RAW_WINDOW_CLOSE_EVENT: RawWindowCloseArgs;
859
860 /// Data was dragged over a window.
861 pub static RAW_DRAG_HOVERED_EVENT: RawDragHoveredArgs;
862
863 /// Data dragging over the window has moved.
864 pub static RAW_DRAG_MOVED_EVENT: RawDragMovedArgs;
865
866 /// Data was drag-dropped on a window.
867 pub static RAW_DRAG_DROPPED_EVENT: RawDragDroppedArgs;
868
869 /// Data was dragged away from the window or the operation was cancelled.
870 pub static RAW_DRAG_CANCELLED_EVENT: RawDragCancelledArgs;
871
872 /// Drag & drop operation started by the app has dropped or was cancelled.
873 pub static RAW_APP_DRAG_ENDED_EVENT: RawAppDragEndedArgs;
874
875 /// Mouse pointer moved over a window.
876 pub static RAW_MOUSE_MOVED_EVENT: RawMouseMovedArgs;
877
878 /// Mouse pointer started hovering a window.
879 pub static RAW_MOUSE_ENTERED_EVENT: RawMouseArgs;
880
881 /// Mouse pointer stopped hovering a window.
882 pub static RAW_MOUSE_LEFT_EVENT: RawMouseArgs;
883
884 /// Mouse wheel scrolled when the mouse was over a window.
885 pub static RAW_MOUSE_WHEEL_EVENT: RawMouseWheelArgs;
886
887 /// Mouse button was pressed or released when the mouse was over a window.
888 pub static RAW_MOUSE_INPUT_EVENT: RawMouseInputArgs;
889
890 /// Touchpad touched when the mouse was over a window.
891 pub static RAW_TOUCHPAD_PRESSURE_EVENT: RawTouchpadPressureArgs;
892
893 /// Motion on some analog axis send to a window.
894 pub static RAW_AXIS_MOTION_EVENT: RawAxisMotionArgs;
895
896 /// A window was touched.
897 pub static RAW_TOUCH_EVENT: RawTouchArgs;
898
899 /// Pixel scale factor for a monitor screen and its windows has changed.
900 ///
901 /// This can happen if the user change the screen settings. Note that a
902 /// window's scale factor can also change if it is moved to a different monitor,
903 /// this change can be monitored using [`RAW_WINDOW_CHANGED_EVENT`].
904 pub static RAW_SCALE_FACTOR_CHANGED_EVENT: RawScaleFactorChangedArgs;
905
906 /// Monitors added, removed or modified.
907 pub static RAW_MONITORS_CHANGED_EVENT: RawMonitorsChangedArgs;
908
909 /// Color scheme or accent color preference changed for a window.
910 pub static RAW_COLORS_CONFIG_CHANGED_EVENT: RawColorsConfigChangedArgs;
911
912 /// Change in system font anti-aliasing config.
913 pub static RAW_FONT_AA_CHANGED_EVENT: RawFontAaChangedArgs;
914
915 /// Change in system text fonts, install or uninstall.
916 pub static RAW_FONT_CHANGED_EVENT: RawFontChangedArgs;
917
918 /// Change in system "double-click" config.
919 pub static RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT: RawMultiClickConfigChangedArgs;
920
921 /// Change in system animation enabled config.
922 pub static RAW_ANIMATIONS_CONFIG_CHANGED_EVENT: RawAnimationsConfigChangedArgs;
923
924 /// Change in system key repeat interval config.
925 pub static RAW_KEY_REPEAT_CONFIG_CHANGED_EVENT: RawKeyRepeatConfigChangedArgs;
926
927 /// Change in system touch config.
928 pub static RAW_TOUCH_CONFIG_CHANGED_EVENT: RawTouchConfigChangedArgs;
929
930 /// Change in system locale config.
931 pub static RAW_LOCALE_CONFIG_CHANGED_EVENT: RawLocaleChangedArgs;
932
933 /// Image metadata loaded.
934 pub static RAW_IMAGE_METADATA_DECODED_EVENT: RawImageMetadataDecodedArgs;
935
936 /// Image loaded without errors.
937 pub static RAW_IMAGE_DECODED_EVENT: RawImageDecodedArgs;
938
939 /// Image failed to load.
940 pub static RAW_IMAGE_DECODE_ERROR_EVENT: RawImageDecodeErrorArgs;
941
942 /// Audio metadata loaded.
943 pub static RAW_AUDIO_METADATA_DECODED_EVENT: RawAudioMetadataDecodedArgs;
944
945 /// Audio loaded without errors.
946 pub static RAW_AUDIO_DECODED_EVENT: RawAudioDecodedArgs;
947
948 /// Image failed to load.
949 pub static RAW_AUDIO_DECODE_ERROR_EVENT: RawAudioDecodeErrorArgs;
950
951 /// Audio output stream opened.
952 pub static RAW_AUDIO_OUTPUT_OPEN_EVENT: RawAudioOutputOpenArgs;
953
954 /// Audio output stream failed to open.
955 pub static RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT: RawAudioOutputOpenErrorArgs;
956
957 /// System low memory warning, some platforms may kill the app if it does not release memory.
958 pub static LOW_MEMORY_EVENT: LowMemoryArgs;
959
960 /// Custom view-process extension event.
961 pub static RAW_EXTENSION_EVENT: RawExtensionEventArgs;
962}