pub struct Screen {
pub n: i32,
}
Expand description
An available screen
Unlike the standalone functions, it automatically checks the provided coordinates and screen numbers are currently valid and inside boundaries.
Fields
n: i32
The screen number
Implementations
sourceimpl Screen
impl Screen
sourcepub fn all_screens() -> Vec<Screen>
pub fn all_screens() -> Vec<Screen>
Returns a vector containing all the Screen
s, ordered by screen number
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn new(number: i32) -> Result<Screen, FltkError>
pub fn new(number: i32) -> Result<Screen, FltkError>
Returns the Screen
associated with the given screen number
Returns an error if the provided number
is not a valid screen number.
sourcepub fn new_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Screen, FltkError>
pub fn new_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Screen, FltkError>
Returns the Screen
that contains the specified screen position
Returns an error if the provided coordinates are out of bounds.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn new_inside<R: Into<Rect> + Copy>(rect: R) -> Result<Screen, FltkError>
pub fn new_inside<R: Into<Rect> + Copy>(rect: R) -> Result<Screen, FltkError>
Returns the Screen
which intersects the most with the provided rectangle
Returns an error if any coordinates on the provided retangle are out of bounds.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn scaling_supported() -> bool
pub fn scaling_supported() -> bool
Returns true if scaling factors are supported by this platform, wether shared by all screens, or each screen having its own value
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn scaling_supported_separately() -> bool
pub fn scaling_supported_separately() -> bool
Returns true if each screen can have its own scaling factor value
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn count() -> i32
pub fn count() -> i32
Returns the number of available screens
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn num_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<i32, FltkError>
pub fn num_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<i32, FltkError>
Returns the screen number of the screen that contains the specified screen position coordinates
Returns an error if the provided coordinates are out of bounds.
sourcepub fn work_area_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Rect, FltkError>
pub fn work_area_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Rect, FltkError>
Returns the bounding rectangle of the work area of the screen that contains the specified screen position coordinates
Returns an error if the provided coordinates are out of bounds.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn work_area_mouse() -> Rect
pub fn work_area_mouse() -> Rect
Returns the bounding rectangle of the work area of the screen currently under the mouse pointer coordinates
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn work_area_num(number: i32) -> Result<Rect, FltkError>
pub fn work_area_num(number: i32) -> Result<Rect, FltkError>
Returns the bounding rectangle of the work area
with the provided screen number
Returns an error if the provided number
is not a valid screen number.
sourcepub fn xywh_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Rect, FltkError>
pub fn xywh_at<C: Into<Coordinates<i32>> + Copy>(
pos: C
) -> Result<Rect, FltkError>
Returns the bounding rectangle of the screen that contains the specified screen position coordinates
Returns an error if the provided coordinates are out of bounds.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn xywh_inside<R: Into<Rect> + Copy>(rect: R) -> Result<Rect, FltkError>
pub fn xywh_inside<R: Into<Rect> + Copy>(rect: R) -> Result<Rect, FltkError>
Returns the bounding rectangle of the screen that contains the specified screen position coordinates
Returns an error if the provided coordinates are out of bounds.
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn xywh_mouse() -> Rect
pub fn xywh_mouse() -> Rect
Gets the bounding rectangle of the screen currently under the mouse pointer coordinates
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn xywh_num(number: i32) -> Result<Rect, FltkError>
pub fn xywh_num(number: i32) -> Result<Rect, FltkError>
Returns the bounding rectangle of the screen
with the provided screen number
Returns an error if the provided number
is not a valid screen number.
sourcepub fn keyboard_scaling(value: bool)
pub fn keyboard_scaling(value: bool)
Controls the possibility to scale all windows by ctrl/+/-/0/ or cmd/+/-/0/
This function should be called before app::open_display
runs.
If it is not called, the default is to handle these keys for window scaling.
Pass a value
of false
to stop recognition of ctrl/+/-/0/
(or cmd/+/-/0/ under macOS) keys as window scaling.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if the current screen’s number corresponds
to a currently connected screen, or false
otherwise.
sourcepub fn dpi(&self) -> (f32, f32)
pub fn dpi(&self) -> (f32, f32)
Returns the current screen (vertical, horizontal) resolution in dots-per-inch
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn set_scale(&self, factor: f32)
pub fn set_scale(&self, factor: f32)
Sets the value of the GUI scaling factor for the current screen
sourcepub fn scale(&self) -> f32
pub fn scale(&self) -> f32
Returns the value of the GUI scaling factor for the current screen
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn work_area(&self) -> Rect
pub fn work_area(&self) -> Rect
Returns the the work area of the current screen
Examples found in repository?
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
fn main() {
let screens = Screen::all_screens();
println!("Number of detected screens = {}\n", screens.len());
assert_eq![screens.len(), Screen::count() as usize];
println!("Is scaling supported:");
println!("- at all = {}", Screen::scaling_supported());
println!("- separately = {}", Screen::scaling_supported_separately());
let coord: Coord = [100, 100].into();
let rect: Rect = [100, 100, 100, 100].into();
// uncomment these lines to see out-of-boundaries errors:
// let coord: Coord = [-100, 10_000].into();
// let rect: Rect = [-100, 100, 10_000, 10_000].into();
println!("\nScreen found:");
println!("- at {coord:?} = {:?}", Screen::new_at(coord));
println!("- inside {rect:?} = {:?}", Screen::new_inside(rect));
println!("\nWork area:");
println!("- at {coord:?} = {:?}", Screen::work_area_at(coord));
println!("- under the mouse = {:?}", Screen::work_area_mouse());
println!("\nXYWH:");
println!("- at {coord:?} = {:?}", Screen::xywh_at(coord));
println!("- inside {rect:?} = {:?}", Screen::xywh_inside(rect));
println!("- under the mouse = {:?}", Screen::xywh_mouse());
println!("\nFor each screen:");
for s in screens {
println!("+ {s:?}");
println!(" - work area = {:?}:", s.work_area());
println!(" - dpi = {:?}", s.dpi());
println!(" - scale = {:?}", s.scale());
}
}
sourcepub fn top_left(&self) -> Coordinates<i32>
pub fn top_left(&self) -> Coordinates<i32>
Returns the top-left x,y
coordinates of the current screen’s work area
sourcepub fn bottom_right(&self) -> Coordinates<i32>
pub fn bottom_right(&self) -> Coordinates<i32>
Returns the bottom-right x+w, y+h
coordinates of the current screen’s work area