scene_management/
pointerinjector_config.rs1use async_utils::hanging_get::server as hanging_get;
6use {
7 fidl_fuchsia_ui_pointerinjector as ui_pointerinjector,
8 fidl_fuchsia_ui_pointerinjector_configuration as ui_pointerinjector_config,
9};
10
11#[derive(Copy, Clone)]
14pub struct InjectorViewportSpec {
15 pub width: f32,
16 pub height: f32,
17 pub scale: f32,
18 pub x_offset: f32,
19 pub y_offset: f32,
20}
21
22impl std::convert::From<InjectorViewportSpec> for ui_pointerinjector::Viewport {
24 fn from(spec: InjectorViewportSpec) -> Self {
25 ui_pointerinjector::Viewport {
26 extents: Some([[0.0, 0.0], [spec.width, spec.height]]),
27 viewport_to_context_transform: Some([
28 spec.scale,
30 0.,
31 0.,
32 0.,
33 spec.scale,
34 0.,
35 spec.x_offset,
36 spec.y_offset,
37 1.,
38 ]),
39 ..Default::default()
40 }
41 }
42}
43
44pub type InjectorViewportChangeFn = Box<
46 dyn Fn(&InjectorViewportSpec, ui_pointerinjector_config::SetupWatchViewportResponder) -> bool
47 + Send
48 + Sync,
49>;
50
51pub type InjectorViewportHangingGet = hanging_get::HangingGet<
53 InjectorViewportSpec,
54 ui_pointerinjector_config::SetupWatchViewportResponder,
55 InjectorViewportChangeFn,
56>;
57
58pub type InjectorViewportPublisher = hanging_get::Publisher<
60 InjectorViewportSpec,
61 ui_pointerinjector_config::SetupWatchViewportResponder,
62 InjectorViewportChangeFn,
63>;
64
65pub type InjectorViewportSubscriber = hanging_get::Subscriber<
67 InjectorViewportSpec,
68 ui_pointerinjector_config::SetupWatchViewportResponder,
69 InjectorViewportChangeFn,
70>;