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_SCALE_FACTOR_CHANGED_EVENT`].
520 pub struct RawScaleFactorChangedArgs {
521 /// Monitor that has changed.
522 pub monitor_id: MonitorId,
523
524 /// Window in the monitor that has changed.
525 pub windows: Vec<WindowId>,
526
527 /// New pixel scale factor.
528 pub scale_factor: Factor,
529
530 ..
531
532 /// Broadcast to all widgets.
533 fn is_in_target(&self, id: WidgetId) -> bool {
534 true
535 }
536 }
537
538 /// Arguments for the [`RAW_MONITORS_CHANGED_EVENT`].
539 pub struct RawMonitorsChangedArgs {
540 /// Up-to-date monitors list.
541 pub available_monitors: Vec<(MonitorId, MonitorInfo)>,
542
543 ..
544
545 /// Broadcast to all widgets.
546 fn is_in_target(&self, id: WidgetId) -> bool {
547 true
548 }
549 }
550
551 /// Arguments for [`RAW_IMAGE_METADATA_DECODED_EVENT`].
552 pub struct RawImageMetadataDecodedArgs {
553 /// Handle to the image in the view-process.
554 ///
555 /// The handle can be upgraded on hook only, after it is dropped. This is so the
556 /// latest event does not keep the image alive indefinitely.
557 pub handle: WeakViewImageHandle,
558 /// Image metadata.
559 pub meta: ImageMetadata,
560
561 ..
562
563 /// Broadcast to all widgets.
564 fn is_in_target(&self, id: WidgetId) -> bool {
565 true
566 }
567 }
568
569 /// Arguments for the [`RAW_IMAGE_DECODED_EVENT`].
570 pub struct RawImageDecodedArgs {
571 /// Handle to the image in the view-process.
572 ///
573 /// The handle can be upgraded on hook only, after it is dropped. This is so the
574 /// latest event does not keep the image alive indefinitely.
575 pub handle: WeakViewImageHandle,
576 /// Image data.
577 ///
578 /// The handle can be upgraded on hook only, after it is dropped.
579 pub image: WeakEq<ImageDecoded>,
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 the [`RAW_IMAGE_DECODE_ERROR_EVENT`].
590 pub struct RawImageDecodeErrorArgs {
591 /// Handle that identifies the image request.
592 ///
593 /// The image data is already removed in the view-process.
594 ///
595 /// The handle can be upgraded on hook only, after it is dropped.
596 pub handle: WeakViewImageHandle,
597 /// Error message.
598 pub error: Txt,
599
600 ..
601
602 /// Broadcast to all widgets.
603 fn is_in_target(&self, id: WidgetId) -> bool {
604 true
605 }
606 }
607
608 /// Arguments for [`RAW_AUDIO_METADATA_DECODED_EVENT`].
609 pub struct RawAudioMetadataDecodedArgs {
610 /// Handle to the audio in the view-process.
611 ///
612 /// The handle can be upgraded on hook only, after it is dropped. This is so the
613 /// latest event does not keep the audio alive indefinitely.
614 pub handle: WeakViewAudioHandle,
615 /// Audio metadata.
616 pub meta: AudioMetadata,
617
618 ..
619
620 /// Broadcast to all widgets.
621 fn is_in_target(&self, id: WidgetId) -> bool {
622 true
623 }
624 }
625
626 /// Arguments for the [`RAW_AUDIO_DECODED_EVENT`].
627 pub struct RawAudioDecodedArgs {
628 /// Handle to the audio in the view-process.
629 /// The handle can be upgraded on hook only, after it is dropped. This is so the
630 /// latest event does not keep the audio alive indefinitely.
631 pub handle: WeakViewAudioHandle,
632 /// Audio data.
633 pub audio: WeakEq<AudioDecoded>,
634
635 ..
636
637 /// Broadcast to all widgets.
638 fn is_in_target(&self, id: WidgetId) -> bool {
639 true
640 }
641 }
642
643 /// Arguments for the [`RAW_AUDIO_DECODE_ERROR_EVENT`].
644 pub struct RawAudioDecodeErrorArgs {
645 /// Handle that identifies the audio request.
646 ///
647 /// The audio data is already removed in the view-process.
648 ///
649 /// The handle can be upgraded on hook only, after it is dropped. This is so the
650 /// latest event does not keep the audio alive indefinitely.
651 pub handle: WeakViewAudioHandle,
652 /// Error message.
653 pub error: Txt,
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_EVENT`].
664 pub struct RawAudioOutputOpenArgs {
665 /// Output that finished opening.
666 pub output_id: AudioOutputId,
667
668 /// Live connection to audio output stream.
669 ///
670 /// The handle can be upgraded on hook only, after it is dropped. This is so the
671 /// latest event does not keep the image audio indefinitely.
672 pub output: WeakViewAudioOutput,
673
674 ..
675
676 /// Broadcast to all widgets.
677 fn is_in_target(&self, id: WidgetId) -> bool {
678 true
679 }
680 }
681
682 /// Arguments for the [`RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT`].
683 pub struct RawAudioOutputOpenErrorArgs {
684 /// Output that failed to open.
685 pub output_id: AudioOutputId,
686 /// Error opening output.
687 pub error: Txt,
688
689 ..
690
691 /// Broadcast to all widgets.
692 fn is_in_target(&self, id: WidgetId) -> bool {
693 true
694 }
695 }
696
697 /// [`RAW_FONT_CHANGED_EVENT`] arguments.
698 pub struct RawFontChangedArgs {
699
700 ..
701
702 /// Broadcast to all widgets.
703 fn is_in_target(&self, id: WidgetId) -> bool {
704 true
705 }
706 }
707
708 /// Arguments for the [`RAW_FONT_AA_CHANGED_EVENT`].
709 pub struct RawFontAaChangedArgs {
710 /// The new anti-aliasing config.
711 pub aa: FontAntiAliasing,
712
713 ..
714
715 /// Broadcast to all widgets.
716 fn is_in_target(&self, id: WidgetId) -> bool {
717 true
718 }
719 }
720
721 /// Arguments for the [`RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT`].
722 pub struct RawMultiClickConfigChangedArgs {
723 /// New config.
724 pub config: MultiClickConfig,
725
726 ..
727
728 /// Broadcast to all widgets.
729 fn is_in_target(&self, id: WidgetId) -> bool {
730 true
731 }
732 }
733
734 /// Arguments for the [`RAW_ANIMATIONS_CONFIG_CHANGED_EVENT`].
735 pub struct RawAnimationsConfigChangedArgs {
736 /// New config.
737 pub config: AnimationsConfig,
738
739 ..
740
741 /// Broadcast to all widgets.
742 fn is_in_target(&self, id: WidgetId) -> bool {
743 true
744 }
745 }
746
747 /// Arguments for the [`RAW_KEY_REPEAT_CONFIG_CHANGED_EVENT`].
748 pub struct RawKeyRepeatConfigChangedArgs {
749 /// New config.
750 pub config: KeyRepeatConfig,
751
752 ..
753
754 /// Broadcast to all widgets.
755 fn is_in_target(&self, id: WidgetId) -> bool {
756 true
757 }
758 }
759
760 /// Arguments for the [`RAW_TOUCH_CONFIG_CHANGED_EVENT`].
761 pub struct RawTouchConfigChangedArgs {
762 /// New config.
763 pub config: TouchConfig,
764
765 ..
766
767 /// Broadcast to all widgets.
768 fn is_in_target(&self, id: WidgetId) -> bool {
769 true
770 }
771 }
772
773 /// Arguments for the [`RAW_LOCALE_CONFIG_CHANGED_EVENT`].
774 pub struct RawLocaleChangedArgs {
775 /// New config.
776 pub config: LocaleConfig,
777
778 ..
779
780 /// Broadcast to all widgets.
781 fn is_in_target(&self, id: WidgetId) -> bool {
782 true
783 }
784 }
785
786 /// Arguments for the [`RAW_COLORS_CONFIG_CHANGED_EVENT`].
787 pub struct RawColorsConfigChangedArgs {
788 /// New config.
789 pub config: ColorsConfig,
790
791 ..
792
793 /// Broadcast to all widgets.
794 fn is_in_target(&self, id: WidgetId) -> bool {
795 true
796 }
797 }
798
799 /// Arguments for the [`RAW_EXTENSION_EVENT`].
800 pub struct RawExtensionEventArgs {
801 /// Id of the sender extension.
802 pub extension_id: ApiExtensionId,
803 /// Event payload.
804 pub payload: ApiExtensionPayload,
805
806 ..
807
808 /// Broadcast to all widgets.
809 fn is_in_target(&self, id: WidgetId) -> bool {
810 true
811 }
812 }
813
814 /// Arguments for [`LOW_MEMORY_EVENT`].
815 pub struct LowMemoryArgs {
816
817 ..
818
819 /// Broadcast to all widgets.
820 fn is_in_target(&self, id: WidgetId) -> bool {
821 true
822 }
823 }
824}
825
826event! {
827 /// A key press or release targeting a window.
828 ///
829 /// This event represents a key input directly from the operating system. It is processed
830 /// by `KeyboardManager` to generate the `KEY_INPUT_EVENT` that actually targets the focused widget.
831 ///
832 /// *See also the [module level documentation](self) for details of how you can fake this event*
833 pub static RAW_KEY_INPUT_EVENT: RawKeyInputArgs;
834
835 /// An IME event was received by a window.
836 pub static RAW_IME_EVENT: RawImeArgs;
837
838 /// A window received or lost focus.
839 pub static RAW_WINDOW_FOCUS_EVENT: RawWindowFocusArgs;
840
841 /// A window was moved, resized or has a state change.
842 ///
843 /// This event aggregates events moves, resizes and other state changes into a
844 /// single event to simplify tracking composite changes, for example, the window changes size and position
845 /// when maximized, this can be trivially observed with this event.
846 pub static RAW_WINDOW_CHANGED_EVENT: RawWindowChangedArgs;
847
848 /// A frame finished rendering and was presented in a window.
849 pub static RAW_FRAME_RENDERED_EVENT: RawFrameRenderedArgs;
850
851 /// A window has finished initializing in the view-process.
852 pub static RAW_WINDOW_OPEN_EVENT: RawWindowOpenArgs;
853
854 /// A headless surface has finished initializing in the view-process.
855 pub static RAW_HEADLESS_OPEN_EVENT: RawHeadlessOpenArgs;
856
857 /// A window or headless surface initialization failed in the view-process.
858 pub static RAW_WINDOW_OR_HEADLESS_OPEN_ERROR_EVENT: RawWindowOrHeadlessOpenErrorArgs;
859
860 /// A window was requested to close.
861 pub static RAW_WINDOW_CLOSE_REQUESTED_EVENT: RawWindowCloseRequestedArgs;
862
863 /// A window was destroyed.
864 pub static RAW_WINDOW_CLOSE_EVENT: RawWindowCloseArgs;
865
866 /// Data was dragged over a window.
867 pub static RAW_DRAG_HOVERED_EVENT: RawDragHoveredArgs;
868
869 /// Data dragging over the window has moved.
870 pub static RAW_DRAG_MOVED_EVENT: RawDragMovedArgs;
871
872 /// Data was drag-dropped on a window.
873 pub static RAW_DRAG_DROPPED_EVENT: RawDragDroppedArgs;
874
875 /// Data was dragged away from the window or the operation was cancelled.
876 pub static RAW_DRAG_CANCELLED_EVENT: RawDragCancelledArgs;
877
878 /// Drag & drop operation started by the app has dropped or was cancelled.
879 pub static RAW_APP_DRAG_ENDED_EVENT: RawAppDragEndedArgs;
880
881 /// Mouse pointer moved over a window.
882 pub static RAW_MOUSE_MOVED_EVENT: RawMouseMovedArgs;
883
884 /// Mouse pointer started hovering a window.
885 pub static RAW_MOUSE_ENTERED_EVENT: RawMouseArgs;
886
887 /// Mouse pointer stopped hovering a window.
888 pub static RAW_MOUSE_LEFT_EVENT: RawMouseArgs;
889
890 /// Mouse wheel scrolled when the mouse was over a window.
891 pub static RAW_MOUSE_WHEEL_EVENT: RawMouseWheelArgs;
892
893 /// Mouse button was pressed or released when the mouse was over a window.
894 pub static RAW_MOUSE_INPUT_EVENT: RawMouseInputArgs;
895
896 /// Touchpad touched when the mouse was over a window.
897 pub static RAW_TOUCHPAD_PRESSURE_EVENT: RawTouchpadPressureArgs;
898
899 /// Motion on some analog axis send to a window.
900 pub static RAW_AXIS_MOTION_EVENT: RawAxisMotionArgs;
901
902 /// A window was touched.
903 pub static RAW_TOUCH_EVENT: RawTouchArgs;
904
905 /// Pixel scale factor for a monitor screen and its windows has changed.
906 ///
907 /// This can happen if the user change the screen settings. Note that a
908 /// window's scale factor can also change if it is moved to a different monitor,
909 /// this change can be monitored using [`RAW_WINDOW_CHANGED_EVENT`].
910 #[deprecated = "use RAW_MONITORS_CHANGED_EVENT"]
911 pub static RAW_SCALE_FACTOR_CHANGED_EVENT: RawScaleFactorChangedArgs;
912
913 /// Monitors added, removed or modified.
914 pub static RAW_MONITORS_CHANGED_EVENT: RawMonitorsChangedArgs;
915
916 /// Color scheme or accent color preference changed for a window.
917 pub static RAW_COLORS_CONFIG_CHANGED_EVENT: RawColorsConfigChangedArgs;
918
919 /// Change in system font anti-aliasing config.
920 pub static RAW_FONT_AA_CHANGED_EVENT: RawFontAaChangedArgs;
921
922 /// Change in system text fonts, install or uninstall.
923 pub static RAW_FONT_CHANGED_EVENT: RawFontChangedArgs;
924
925 /// Change in system "double-click" config.
926 pub static RAW_MULTI_CLICK_CONFIG_CHANGED_EVENT: RawMultiClickConfigChangedArgs;
927
928 /// Change in system animation enabled config.
929 pub static RAW_ANIMATIONS_CONFIG_CHANGED_EVENT: RawAnimationsConfigChangedArgs;
930
931 /// Change in system key repeat interval config.
932 pub static RAW_KEY_REPEAT_CONFIG_CHANGED_EVENT: RawKeyRepeatConfigChangedArgs;
933
934 /// Change in system touch config.
935 pub static RAW_TOUCH_CONFIG_CHANGED_EVENT: RawTouchConfigChangedArgs;
936
937 /// Change in system locale config.
938 pub static RAW_LOCALE_CONFIG_CHANGED_EVENT: RawLocaleChangedArgs;
939
940 /// Image metadata loaded.
941 pub static RAW_IMAGE_METADATA_DECODED_EVENT: RawImageMetadataDecodedArgs;
942
943 /// Image loaded without errors.
944 pub static RAW_IMAGE_DECODED_EVENT: RawImageDecodedArgs;
945
946 /// Image failed to load.
947 pub static RAW_IMAGE_DECODE_ERROR_EVENT: RawImageDecodeErrorArgs;
948
949 /// Audio metadata loaded.
950 pub static RAW_AUDIO_METADATA_DECODED_EVENT: RawAudioMetadataDecodedArgs;
951
952 /// Audio loaded without errors.
953 pub static RAW_AUDIO_DECODED_EVENT: RawAudioDecodedArgs;
954
955 /// Image failed to load.
956 pub static RAW_AUDIO_DECODE_ERROR_EVENT: RawAudioDecodeErrorArgs;
957
958 /// Audio output stream opened.
959 pub static RAW_AUDIO_OUTPUT_OPEN_EVENT: RawAudioOutputOpenArgs;
960
961 /// Audio output stream failed to open.
962 pub static RAW_AUDIO_OUTPUT_OPEN_ERROR_EVENT: RawAudioOutputOpenErrorArgs;
963
964 /// System low memory warning, some platforms may kill the app if it does not release memory.
965 pub static LOW_MEMORY_EVENT: LowMemoryArgs;
966
967 /// Custom view-process extension event.
968 pub static RAW_EXTENSION_EVENT: RawExtensionEventArgs;
969}