pinnacle_api/
debug.rs

1//! Debugging utilities.
2//!
3//! WARNING: This module is not governed by the API stability guarantees.
4
5use pinnacle_api_defs::pinnacle::{
6    debug::v1::{
7        SetCursorPlaneScanoutRequest, SetDamageVisualizationRequest,
8        SetOpaqueRegionVisualizationRequest, SetProcessPipingRequest,
9    },
10    util::v1::SetOrToggle,
11};
12
13use crate::{client::Client, BlockOnTokio};
14
15/// Sets damage visualization.
16///
17/// When on, parts of the screen that are damaged after rendering will have
18/// red rectangles drawn where the damage is.
19pub fn set_damage_visualization(set: bool) {
20    Client::debug()
21        .set_damage_visualization(SetDamageVisualizationRequest {
22            set_or_toggle: match set {
23                true => SetOrToggle::Set,
24                false => SetOrToggle::Unset,
25            }
26            .into(),
27        })
28        .block_on_tokio()
29        .unwrap();
30}
31
32/// Toggles damage visualization.
33///
34/// When on, parts of the screen that are damaged after rendering will have
35/// red rectangles drawn where the damage is.
36pub fn toggle_damage_visualization() {
37    Client::debug()
38        .set_damage_visualization(SetDamageVisualizationRequest {
39            set_or_toggle: SetOrToggle::Toggle.into(),
40        })
41        .block_on_tokio()
42        .unwrap();
43}
44
45/// Sets opaque region visualization.
46///
47/// When on, parts of the screen that are opaque will have a transparent blue rectangle
48/// drawn over it, while parts that are not opaque will have a transparent red rectangle
49/// drawn.
50pub fn set_opaque_region_visualization(set: bool) {
51    Client::debug()
52        .set_opaque_region_visualization(SetOpaqueRegionVisualizationRequest {
53            set_or_toggle: match set {
54                true => SetOrToggle::Set,
55                false => SetOrToggle::Unset,
56            }
57            .into(),
58        })
59        .block_on_tokio()
60        .unwrap();
61}
62
63/// Toggles opaque region visualization.
64///
65/// When on, parts of the screen that are opaque will have a transparent blue rectangle
66/// drawn over it, while parts that are not opaque will have a transparent red rectangle
67/// drawn.
68pub fn toggle_opaque_region_visualization() {
69    Client::debug()
70        .set_opaque_region_visualization(SetOpaqueRegionVisualizationRequest {
71            set_or_toggle: SetOrToggle::Toggle.into(),
72        })
73        .block_on_tokio()
74        .unwrap();
75}
76
77/// Enables or disables cursor plane scanout.
78pub fn set_cursor_plane_scanout(set: bool) {
79    Client::debug()
80        .set_cursor_plane_scanout(SetCursorPlaneScanoutRequest {
81            set_or_toggle: match set {
82                true => SetOrToggle::Set,
83                false => SetOrToggle::Unset,
84            }
85            .into(),
86        })
87        .block_on_tokio()
88        .unwrap();
89}
90
91/// Toggles cursor plane scanout.
92pub fn toggle_cursor_plane_scanout() {
93    Client::debug()
94        .set_cursor_plane_scanout(SetCursorPlaneScanoutRequest {
95            set_or_toggle: SetOrToggle::Toggle.into(),
96        })
97        .block_on_tokio()
98        .unwrap();
99}
100
101/// Enables or disables process spawning setting up pipes to expose fds to the config.
102pub fn set_process_piping(set: bool) {
103    Client::debug()
104        .set_process_piping(SetProcessPipingRequest {
105            set_or_toggle: match set {
106                true => SetOrToggle::Set,
107                false => SetOrToggle::Unset,
108            }
109            .into(),
110        })
111        .block_on_tokio()
112        .unwrap();
113}
114
115/// Toggles process spawning setting up pipes to expose fds to the config.
116pub fn toggle_process_piping() {
117    Client::debug()
118        .set_process_piping(SetProcessPipingRequest {
119            set_or_toggle: SetOrToggle::Toggle.into(),
120        })
121        .block_on_tokio()
122        .unwrap();
123}