Skip to main content

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, Frequency, 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        /// New window scale factor, if it changed.
179        pub scale_factor: Option<Factor>,
180
181        /// New window refresh rate, if it changed.
182        pub refresh_rate: Option<Frequency>,
183
184        ..
185
186        /// Broadcast to all widgets.
187        fn is_in_target(&self, id: WidgetId) -> bool {
188            true
189        }
190    }
191
192    /// Arguments for the [`RAW_WINDOW_OPEN_EVENT`].
193    pub struct RawWindowOpenArgs {
194        /// Window that finished opening.
195        pub window_id: WindowId,
196
197        /// Live connection to the window in the view-process.
198        ///
199        /// The handle can be upgraded on hook only, after it is dropped. This is so the
200        /// latest event does not keep the window alive indefinitely.
201        pub window: WeakViewWindow,
202
203        /// Extra data send by the view-process.
204        pub data: WindowOpenData,
205
206        ..
207
208        /// Broadcast to all widgets.
209        fn is_in_target(&self, id: WidgetId) -> bool {
210            true
211        }
212    }
213
214    /// Arguments for the [`RAW_HEADLESS_OPEN_EVENT`].
215    pub struct RawHeadlessOpenArgs {
216        /// Window id that represents the headless surface that finished opening.
217        pub window_id: WindowId,
218
219        /// Live connection to the headless surface in the view-process.
220        ///
221        /// The handle can be upgraded on hook only, after it is dropped. This is so the
222        /// latest event does not keep the surface alive indefinitely.
223        pub surface: WeakViewHeadless,
224
225        /// Extra data send by the view-process.
226        pub data: HeadlessOpenData,
227
228        ..
229
230        /// Broadcast to all widgets.
231        fn is_in_target(&self, id: WidgetId) -> bool {
232            true
233        }
234    }
235
236    /// Arguments for the [`RAW_WINDOW_OR_HEADLESS_OPEN_ERROR_EVENT`].
237    pub struct RawWindowOrHeadlessOpenErrorArgs {
238        /// Window id that failed to open.
239        pub window_id: WindowId,
240        /// Error message from the view-process.
241        pub error: Txt,
242
243        ..
244
245        /// Broadcast to all widgets.
246        fn is_in_target(&self, id: WidgetId) -> bool {
247            true
248        }
249    }
250
251    /// Arguments for the [`RAW_WINDOW_CLOSE_REQUESTED_EVENT`].
252    pub struct RawWindowCloseRequestedArgs {
253        /// Window that was requested to close.
254        pub window_id: WindowId,
255
256        ..
257
258        /// Broadcast to all widgets.
259        fn is_in_target(&self, id: WidgetId) -> bool {
260            true
261        }
262    }
263
264    /// Arguments for the [`RAW_WINDOW_CLOSE_EVENT`].
265    pub struct RawWindowCloseArgs {
266        /// Window that has closed.
267        pub window_id: WindowId,
268
269        ..
270
271        /// Broadcast to all widgets.
272        fn is_in_target(&self, id: WidgetId) -> bool {
273            true
274        }
275    }
276
277    /// Arguments for the [`RAW_DRAG_HOVERED_EVENT`].
278    pub struct RawDragHoveredArgs {
279        /// Window where it was dragged over.
280        pub window_id: WindowId,
281
282        /// Data payload.
283        pub data: Vec<DragDropData>,
284        /// Allowed effects.
285        pub allowed: DragDropEffect,
286
287        ..
288
289        /// Broadcast to all widgets.
290        fn is_in_target(&self, id: WidgetId) -> bool {
291            true
292        }
293    }
294
295    /// Arguments for the [`RAW_DRAG_MOVED_EVENT`].
296    pub struct RawDragMovedArgs {
297        /// Window that is hovered by drag&drop.
298        pub window_id: WindowId,
299
300        /// Cursor positions in between the previous event and this one.
301        ///
302        /// Drag move events can be coalesced, i.e. multiple moves packed into a single event.
303        pub coalesced_pos: Vec<DipPoint>,
304
305        /// Position of the cursor over the window, (0, 0) is the top-left.
306        pub position: DipPoint,
307
308        ..
309
310        /// Broadcast to all widgets.
311        fn is_in_target(&self, id: WidgetId) -> bool {
312            true
313        }
314    }
315
316    /// Arguments for the [`RAW_DRAG_DROPPED_EVENT`].
317    pub struct RawDragDroppedArgs {
318        /// Window where it was dropped.
319        pub window_id: WindowId,
320
321        /// Data payload.
322        pub data: Vec<DragDropData>,
323        /// Allowed effects.
324        pub allowed: DragDropEffect,
325        /// ID of this drop operation.
326        ///
327        /// Handlers must call `drag_dropped` with this ID and what effect was applied to the data.
328        pub drop_id: DragDropId,
329
330        ..
331
332        /// Broadcast to all widgets.
333        fn is_in_target(&self, id: WidgetId) -> bool {
334            true
335        }
336    }
337
338    /// Arguments for the [`RAW_DRAG_CANCELLED_EVENT`].
339    pub struct RawDragCancelledArgs {
340        /// Window where the file was previously dragged over.
341        pub window_id: WindowId,
342
343        ..
344
345        /// Broadcast to all widgets.
346        fn is_in_target(&self, id: WidgetId) -> bool {
347            true
348        }
349    }
350
351    /// Arguments for the [`RAW_APP_DRAG_ENDED_EVENT`].
352    pub struct RawAppDragEndedArgs {
353        /// Window that started the drag operation.
354        pub window_id: WindowId,
355
356        /// ID of the drag & drop operation.
357        pub id: DragDropId,
358
359        /// Effect applied to the data by the drop target.
360        ///
361        /// Is a single flag if the data was dropped in a valid drop target, or is empty if was canceled.
362        pub applied: DragDropEffect,
363
364        ..
365
366        /// Broadcast to all widgets.
367        fn is_in_target(&self, id: WidgetId) -> bool {
368            true
369        }
370    }
371
372    /// Arguments for the [`RAW_MOUSE_MOVED_EVENT`].
373    pub struct RawMouseMovedArgs {
374        /// Window the mouse was moved over.
375        pub window_id: WindowId,
376
377        /// Device that generated this event.
378        pub device_id: InputDeviceId,
379
380        /// Positions of the mouse in between the previous event and this one.
381        ///
382        /// Mouse move events can be coalesced, i.e. multiple mouse moves packed into a single event.
383        pub coalesced_pos: Vec<DipPoint>,
384
385        /// Position of the mouse over the window, (0, 0) is the top-left.
386        pub position: DipPoint,
387
388        ..
389
390        /// Broadcast to all widgets.
391        fn is_in_target(&self, id: WidgetId) -> bool {
392            true
393        }
394    }
395
396    /// Arguments for the [`RAW_MOUSE_ENTERED_EVENT`] and [`RAW_MOUSE_LEFT_EVENT`].
397    pub struct RawMouseArgs {
398        /// Window the mouse entered or left.
399        pub window_id: WindowId,
400
401        /// Device that generated this event.
402        pub device_id: InputDeviceId,
403
404        ..
405
406        /// Broadcast to all widgets.
407        fn is_in_target(&self, id: WidgetId) -> bool {
408            true
409        }
410    }
411
412    /// Arguments for the [`RAW_MOUSE_WHEEL_EVENT`].
413    pub struct RawMouseWheelArgs {
414        /// Window that is hovered by the mouse.
415        pub window_id: WindowId,
416
417        /// Device that generated this event.
418        pub device_id: InputDeviceId,
419
420        /// Wheel motion delta, value is in pixels if the *wheel* is a touchpad.
421        pub delta: MouseScrollDelta,
422
423        /// Touch state if the device that generated the event is a touchpad.
424        pub phase: TouchPhase,
425
426        ..
427
428        /// Broadcast to all widgets.
429        fn is_in_target(&self, id: WidgetId) -> bool {
430            true
431        }
432    }
433
434    /// Arguments for the [`RAW_MOUSE_INPUT_EVENT`].
435    pub struct RawMouseInputArgs {
436        /// Window that is hovered by the mouse.
437        pub window_id: WindowId,
438
439        /// Device that generated this event.
440        pub device_id: InputDeviceId,
441
442        /// If the button was pressed or released.
443        pub state: ButtonState,
444
445        /// What button was pressed or released.
446        pub button: MouseButton,
447
448        ..
449
450        /// Broadcast to all widgets.
451        fn is_in_target(&self, id: WidgetId) -> bool {
452            true
453        }
454    }
455
456    /// Arguments for the [`RAW_TOUCHPAD_PRESSURE_EVENT`].
457    pub struct RawTouchpadPressureArgs {
458        /// Window that is touched.
459        pub window_id: WindowId,
460
461        /// Device that generated this event.
462        pub device_id: InputDeviceId,
463
464        /// Pressure level between 0 and 1.
465        pub pressure: Factor,
466
467        /// Click level.
468        pub stage: i64,
469
470        ..
471
472        /// Broadcast to all widgets.
473        fn is_in_target(&self, id: WidgetId) -> bool {
474            true
475        }
476    }
477
478    /// Arguments for the [`RAW_AXIS_MOTION_EVENT`].
479    pub struct RawAxisMotionArgs {
480        /// Window that received the event.
481        pub window_id: WindowId,
482
483        /// Device that generated the event.
484        pub device_id: InputDeviceId,
485
486        /// Analog axis.
487        pub axis: AxisId,
488
489        /// Motion amount.
490        pub value: f64,
491
492        ..
493
494        /// Broadcast to all widgets.
495        fn is_in_target(&self, id: WidgetId) -> bool {
496            true
497        }
498    }
499
500    /// Arguments for the [`RAW_TOUCH_EVENT`].
501    pub struct RawTouchArgs {
502        /// Window that was touched.
503        pub window_id: WindowId,
504
505        /// Device that generated this event.
506        pub device_id: InputDeviceId,
507
508        /// Coalesced touch updates.
509        pub touches: Vec<TouchUpdate>,
510
511        ..
512
513        /// Broadcast to all widgets.
514        fn is_in_target(&self, id: WidgetId) -> bool {
515            true
516        }
517    }
518
519    /// Arguments for the [`RAW_MONITORS_CHANGED_EVENT`].
520    pub struct RawMonitorsChangedArgs {
521        /// Up-to-date monitors list.
522        pub available_monitors: Vec<(MonitorId, MonitorInfo)>,
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 [`RAW_IMAGE_METADATA_DECODED_EVENT`].
533    pub struct RawImageMetadataDecodedArgs {
534        /// Handle to the image in the view-process.
535        ///
536        /// The handle can be upgraded on hook only, after it is dropped. This is so the
537        /// latest event does not keep the image alive indefinitely.
538        pub handle: WeakViewImageHandle,
539        /// Image metadata.
540        pub meta: ImageMetadata,
541
542        ..
543
544        /// Broadcast to all widgets.
545        fn is_in_target(&self, id: WidgetId) -> bool {
546            true
547        }
548    }
549
550    /// Arguments for the [`RAW_IMAGE_DECODED_EVENT`].
551    pub struct RawImageDecodedArgs {
552        /// Handle to the image in the view-process.
553        ///
554        /// The handle can be upgraded on hook only, after it is dropped. This is so the
555        /// latest event does not keep the image alive indefinitely.
556        pub handle: WeakViewImageHandle,
557        /// Image data.
558        ///
559        /// The handle can be upgraded on hook only, after it is dropped.
560        pub image: WeakEq<ImageDecoded>,
561
562        ..
563
564        /// Broadcast to all widgets.
565        fn is_in_target(&self, id: WidgetId) -> bool {
566            true
567        }
568    }
569
570    /// Arguments for the [`RAW_IMAGE_DECODE_ERROR_EVENT`].
571    pub struct RawImageDecodeErrorArgs {
572        /// Handle that identifies the image request.
573        ///
574        /// The image data is already removed in the view-process.
575        ///
576        /// The handle can be upgraded on hook only, after it is dropped.
577        pub handle: WeakViewImageHandle,
578        /// Error message.
579        pub error: Txt,
580
581        ..
582
583        /// Broadcast to all widgets.
584        fn is_in_target(&self, id: WidgetId) -> bool {
585            true
586        }
587    }
588
589    /// Arguments for [`RAW_AUDIO_METADATA_DECODED_EVENT`].
590    pub struct RawAudioMetadataDecodedArgs {
591        /// Handle to the audio in the view-process.
592        ///
593        /// The handle can be upgraded on hook only, after it is dropped. This is so the
594        /// latest event does not keep the audio alive indefinitely.
595        pub handle: WeakViewAudioHandle,
596        /// Audio metadata.
597        pub meta: AudioMetadata,
598
599        ..
600
601        /// Broadcast to all widgets.
602        fn is_in_target(&self, id: WidgetId) -> bool {
603            true
604        }
605    }
606
607    /// Arguments for the [`RAW_AUDIO_DECODED_EVENT`].
608    pub struct RawAudioDecodedArgs {
609        /// Handle to the audio in the view-process.
610        /// The handle can be upgraded on hook only, after it is dropped. This is so the
611        /// latest event does not keep the audio alive indefinitely.
612        pub handle: WeakViewAudioHandle,
613        /// Audio data.
614        pub audio: WeakEq<AudioDecoded>,
615
616        ..
617
618        /// Broadcast to all widgets.
619        fn is_in_target(&self, id: WidgetId) -> bool {
620            true
621        }
622    }
623
624    /// Arguments for the [`RAW_AUDIO_DECODE_ERROR_EVENT`].
625    pub struct RawAudioDecodeErrorArgs {
626        /// Handle that identifies the audio request.
627        ///
628        /// The audio data is already removed in the view-process.
629        ///
630        /// The handle can be upgraded on hook only, after it is dropped. This is so the
631        /// latest event does not keep the audio alive indefinitely.
632        pub handle: WeakViewAudioHandle,
633        /// Error message.
634        pub error: Txt,
635
636        ..
637
638        /// Broadcast to all widgets.
639        fn is_in_target(&self, id: WidgetId) -> bool {
640            true
641        }
642    }
643
644    /// Arguments for the [`RAW_AUDIO_OUTPUT_OPEN_EVENT`].
645    pub struct RawAudioOutputOpenArgs {
646        /// Output that finished opening.
647        pub output_id: AudioOutputId,
648
649        /// Live connection to audio output stream.
650        ///
651        /// The handle can be upgraded on hook only, after it is dropped. This is so the
652        /// latest event does not keep the image audio indefinitely.
653        pub output: WeakViewAudioOutput,
654
655        ..
656
657        /// Broadcast to all widgets.
658        fn is_in_target(&self, id: WidgetId) -> bool {
659            true
660        }
661    }
662
663    /// Arguments for the [`RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT`].
664    pub struct RawAudioOutputOpenErrorArgs {
665        /// Output that failed to open.
666        pub output_id: AudioOutputId,
667        /// Error opening output.
668        pub error: Txt,
669
670        ..
671
672        /// Broadcast to all widgets.
673        fn is_in_target(&self, id: WidgetId) -> bool {
674            true
675        }
676    }
677
678    /// [`RAW_FONT_CHANGED_EVENT`] arguments.
679    pub struct RawFontChangedArgs {
680
681        ..
682
683        /// Broadcast to all widgets.
684        fn is_in_target(&self, id: WidgetId) -> bool {
685            true
686        }
687    }
688
689    /// Arguments for the [`RAW_FONT_AA_CHANGED_EVENT`].
690    pub struct RawFontAaChangedArgs {
691        /// The new anti-aliasing config.
692        pub aa: FontAntiAliasing,
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_MULTI_CLICK_CONFIG_CHANGED_EVENT`].
703    pub struct RawMultiClickConfigChangedArgs {
704        /// New config.
705        pub config: MultiClickConfig,
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_ANIMATIONS_CONFIG_CHANGED_EVENT`].
716    pub struct RawAnimationsConfigChangedArgs {
717        /// New config.
718        pub config: AnimationsConfig,
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_KEY_REPEAT_CONFIG_CHANGED_EVENT`].
729    pub struct RawKeyRepeatConfigChangedArgs {
730        /// New config.
731        pub config: KeyRepeatConfig,
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_TOUCH_CONFIG_CHANGED_EVENT`].
742    pub struct RawTouchConfigChangedArgs {
743        /// New config.
744        pub config: TouchConfig,
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_LOCALE_CONFIG_CHANGED_EVENT`].
755    pub struct RawLocaleChangedArgs {
756        /// New config.
757        pub config: LocaleConfig,
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_COLORS_CONFIG_CHANGED_EVENT`].
768    pub struct RawColorsConfigChangedArgs {
769        /// New config.
770        pub config: ColorsConfig,
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_EXTENSION_EVENT`].
781    pub struct RawExtensionEventArgs {
782        /// Id of the sender extension.
783        pub extension_id: ApiExtensionId,
784        /// Event payload.
785        pub payload: ApiExtensionPayload,
786
787        ..
788
789        /// Broadcast to all widgets.
790        fn is_in_target(&self, id: WidgetId) -> bool {
791            true
792        }
793    }
794
795    /// Arguments for [`LOW_MEMORY_EVENT`].
796    pub struct LowMemoryArgs {
797
798        ..
799
800        /// Broadcast to all widgets.
801        fn is_in_target(&self, id: WidgetId) -> bool {
802            true
803        }
804    }
805}
806
807event! {
808    /// A key press or release targeting a window.
809    ///
810    /// This event represents a key input directly from the operating system. It is processed
811    /// by `KeyboardManager` to generate the `KEY_INPUT_EVENT` that actually targets the focused widget.
812    ///
813    /// *See also the [module level documentation](self) for details of how you can fake this event*
814    pub static RAW_KEY_INPUT_EVENT: RawKeyInputArgs;
815
816    /// An IME event was received by a window.
817    pub static RAW_IME_EVENT: RawImeArgs;
818
819    /// A window received or lost focus.
820    pub static RAW_WINDOW_FOCUS_EVENT: RawWindowFocusArgs;
821
822    /// A window was moved, resized or has a state change.
823    ///
824    /// This event aggregates events moves, resizes and other state changes into a
825    /// single event to simplify tracking composite changes, for example, the window changes size and position
826    /// when maximized, this can be trivially observed with this event.
827    pub static RAW_WINDOW_CHANGED_EVENT: RawWindowChangedArgs;
828
829    /// A frame finished rendering and was presented in a window.
830    pub static RAW_FRAME_RENDERED_EVENT: RawFrameRenderedArgs;
831
832    /// A window has finished initializing in the view-process.
833    pub static RAW_WINDOW_OPEN_EVENT: RawWindowOpenArgs;
834
835    /// A headless surface has finished initializing in the view-process.
836    pub static RAW_HEADLESS_OPEN_EVENT: RawHeadlessOpenArgs;
837
838    /// A window or headless surface initialization failed in the view-process.
839    pub static RAW_WINDOW_OR_HEADLESS_OPEN_ERROR_EVENT: RawWindowOrHeadlessOpenErrorArgs;
840
841    /// A window was requested to close.
842    pub static RAW_WINDOW_CLOSE_REQUESTED_EVENT: RawWindowCloseRequestedArgs;
843
844    /// A window was destroyed.
845    pub static RAW_WINDOW_CLOSE_EVENT: RawWindowCloseArgs;
846
847    /// Data was dragged over a window.
848    pub static RAW_DRAG_HOVERED_EVENT: RawDragHoveredArgs;
849
850    /// Data dragging over the window has moved.
851    pub static RAW_DRAG_MOVED_EVENT: RawDragMovedArgs;
852
853    /// Data was drag-dropped on a window.
854    pub static RAW_DRAG_DROPPED_EVENT: RawDragDroppedArgs;
855
856    /// Data was dragged away from the window or the operation was cancelled.
857    pub static RAW_DRAG_CANCELLED_EVENT: RawDragCancelledArgs;
858
859    /// Drag & drop operation started by the app has dropped or was cancelled.
860    pub static RAW_APP_DRAG_ENDED_EVENT: RawAppDragEndedArgs;
861
862    /// Mouse pointer moved over a window.
863    pub static RAW_MOUSE_MOVED_EVENT: RawMouseMovedArgs;
864
865    /// Mouse pointer started hovering a window.
866    pub static RAW_MOUSE_ENTERED_EVENT: RawMouseArgs;
867
868    /// Mouse pointer stopped hovering a window.
869    pub static RAW_MOUSE_LEFT_EVENT: RawMouseArgs;
870
871    /// Mouse wheel scrolled when the mouse was over a window.
872    pub static RAW_MOUSE_WHEEL_EVENT: RawMouseWheelArgs;
873
874    /// Mouse button was pressed or released when the mouse was over a window.
875    pub static RAW_MOUSE_INPUT_EVENT: RawMouseInputArgs;
876
877    /// Touchpad touched when the mouse was over a window.
878    pub static RAW_TOUCHPAD_PRESSURE_EVENT: RawTouchpadPressureArgs;
879
880    /// Motion on some analog axis send to a window.
881    pub static RAW_AXIS_MOTION_EVENT: RawAxisMotionArgs;
882
883    /// A window was touched.
884    pub static RAW_TOUCH_EVENT: RawTouchArgs;
885
886    /// Monitors added, removed or modified.
887    pub static RAW_MONITORS_CHANGED_EVENT: RawMonitorsChangedArgs;
888
889    /// Color scheme or accent color preference changed for a window.
890    pub static RAW_COLORS_CONFIG_CHANGED_EVENT: RawColorsConfigChangedArgs;
891
892    /// Change in system font anti-aliasing config.
893    pub static RAW_FONT_AA_CHANGED_EVENT: RawFontAaChangedArgs;
894
895    /// Change in system text fonts, install or uninstall.
896    pub static RAW_FONT_CHANGED_EVENT: RawFontChangedArgs;
897
898    /// Change in system "double-click" config.
899    pub static RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT: RawMultiClickConfigChangedArgs;
900
901    /// Change in system animation enabled config.
902    pub static RAW_ANIMATIONS_CONFIG_CHANGED_EVENT: RawAnimationsConfigChangedArgs;
903
904    /// Change in system key repeat interval config.
905    pub static RAW_KEY_REPEAT_CONFIG_CHANGED_EVENT: RawKeyRepeatConfigChangedArgs;
906
907    /// Change in system touch config.
908    pub static RAW_TOUCH_CONFIG_CHANGED_EVENT: RawTouchConfigChangedArgs;
909
910    /// Change in system locale config.
911    pub static RAW_LOCALE_CONFIG_CHANGED_EVENT: RawLocaleChangedArgs;
912
913    /// Image metadata loaded.
914    pub static RAW_IMAGE_METADATA_DECODED_EVENT: RawImageMetadataDecodedArgs;
915
916    /// Image loaded without errors.
917    pub static RAW_IMAGE_DECODED_EVENT: RawImageDecodedArgs;
918
919    /// Image failed to load.
920    pub static RAW_IMAGE_DECODE_ERROR_EVENT: RawImageDecodeErrorArgs;
921
922    /// Audio metadata loaded.
923    pub static RAW_AUDIO_METADATA_DECODED_EVENT: RawAudioMetadataDecodedArgs;
924
925    /// Audio loaded without errors.
926    pub static RAW_AUDIO_DECODED_EVENT: RawAudioDecodedArgs;
927
928    /// Image failed to load.
929    pub static RAW_AUDIO_DECODE_ERROR_EVENT: RawAudioDecodeErrorArgs;
930
931    /// Audio output stream opened.
932    pub static RAW_AUDIO_OUTPUT_OPEN_EVENT: RawAudioOutputOpenArgs;
933
934    /// Audio output stream failed to open.
935    pub static RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT: RawAudioOutputOpenErrorArgs;
936
937    /// System low memory warning, some platforms may kill the app if it does not release memory.
938    pub static LOW_MEMORY_EVENT: LowMemoryArgs;
939
940    /// Custom view-process extension event.
941    pub static RAW_EXTENSION_EVENT: RawExtensionEventArgs;
942}