ui/screen.rs#
Source: lib/ui/screen.rs
screen -- the monitors, global shortcuts, a colour from anywhere on the screen and pictures of
the screen for the app (plat::screen, plat::hotkey)
monitors() -> Vec<Monitor> every monitor, the primary one first (rect / work area in
desktop units, dpi, refresh, name); a change comes as
App::command(UIC_SETTINGS, plat::SET_MONITORS)
hotkey_register(id, chord, description) -> Result<(), HotkeyError> a global shortcut
("Ctrl+Alt+K"; plat::Chord::parse names the keys): when it
is pressed anywhere, App::command(UIC_HOTKEY, id); when the
desktop drops it later (the portal's dialog),
App::command(UIC_HOTKEY_LOST, id) and hotkey_error(id)
tells why. Needs `input.global` in the manifest.
hotkey_unregister(id) -> bool hotkeys_available() -> bool
pick_color() -> bool the user clicks a pixel anywhere on the screen (Esc
cancels); then App::command(UIC_PICK, 1 picked / 0 not) and
picked_color() -> Some(0xRRGGBB); false: not possible here
pick_available() -> bool a colour picker with CP_PIPETTE shows its pipette then
screenshot(rect) -> bool a picture of the whole desktop (None) or a rectangle; then
App::command(UIC_SCREENSHOT, 1 / 0) and screenshot_take() ->
Option<Surface> (FMT_XRGB); needs `screen.capture`
screen_error() -> Option<ScreenError> why the last pick / picture failed
Headless runs (scripts, --shot) touch nothing real: shortcuts are only recorded (the script
command `system hotkey ID` presses one), a pick waits for `system pick RRGGBB|cancel`, the
monitors are the window (or the script's `screen` rectangle) at the run's dpi, pictures are
Unavailable.
impl Ui
fn monitors(&mut self) -> Vec<Monitor>every monitor, the primary one firstfn hotkeys_available(&mut self) -> boolwhether global shortcuts work herefn hotkey_register(&mut self, id: u32, chord: &str, description: &str) -> Result<(), HotkeyError>register chord ("Ctrl+Alt+K") as the global shortcut id; description tells the user what it does (the desktop's dialog shows it)fn hotkey_unregister(&mut self, id: u32) -> boolremove the global shortcut id -> false when it was not registeredfn hotkey_error(&self, id: u32) -> Option<HotkeyError>why the desktop dropped the shortcut id (after UIC_HOTKEY_LOST)fn pick_available(&self) -> boolwhether the user can pick a colour anywhere on the screen here (headless: yes, the script answers)fn pick_color(&mut self) -> boolthe user picks a pixel anywhere on the screen; UIC_PICK reports the end -> false when that is not possible here (or a pick runs)fn picked_color(&mut self) -> Option<u32>the colour of the last pick (0xRRGGBB), oncefn screenshot(&mut self, rect: Option<[i32; 4]>) -> boola picture of the whole desktop (None) or of a rectangle (desktop units); UIC_SCREENSHOT reports it -> false when that is not possible herefn screenshot_take(&mut self) -> Option<Surface>the picture of the last screenshot, oncefn screen_error(&self) -> Option<ScreenError>why the last pick or picture failed (None: it worked or was not asked for)