Struct fltk::app::Screen

source ·
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§

source§

impl Screen

source

pub fn all_screens() -> Vec<Screen>

Returns a vector containing all the Screens, ordered by screen number

Examples found in repository?
examples/screens_info.rs (line 8)
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());
    }
}
source

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.

source

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?
examples/screens_info.rs (line 24)
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());
    }
}
source

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?
examples/screens_info.rs (line 25)
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());
    }
}
source

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?
examples/screens_info.rs (line 13)
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());
    }
}
source

pub fn scaling_supported_separately() -> bool

Returns true if each screen can have its own scaling factor value

Examples found in repository?
examples/screens_info.rs (line 14)
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());
    }
}
source

pub fn count() -> i32

Returns the number of available screens

Examples found in repository?
examples/screens_info.rs (line 10)
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());
    }
}
source

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.

source

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?
examples/screens_info.rs (line 28)
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());
    }
}
source

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?
examples/screens_info.rs (line 29)
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());
    }
}
source

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.

source

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?
examples/screens_info.rs (line 32)
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());
    }
}
source

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?
examples/screens_info.rs (line 33)
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());
    }
}
source

pub fn xywh_mouse() -> Rect

Gets the bounding rectangle of the screen currently under the mouse pointer coordinates

Examples found in repository?
examples/screens_info.rs (line 34)
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());
    }
}
source

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.

source

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.

source

pub fn is_valid(&self) -> bool

Returns true if the current screen’s number corresponds to a currently connected screen, or false otherwise.

source

pub fn dpi(&self) -> (f32, f32)

Returns the current screen (vertical, horizontal) resolution in dots-per-inch

Examples found in repository?
examples/screens_info.rs (line 40)
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());
    }
}
source

pub fn set_scale(&self, factor: f32)

Sets the value of the GUI scaling factor for the current screen

source

pub fn scale(&self) -> f32

Returns the value of the GUI scaling factor for the current screen

Examples found in repository?
examples/screens_info.rs (line 41)
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());
    }
}
source

pub fn work_area(&self) -> Rect

Returns the the work area of the current screen

Examples found in repository?
examples/screens_info.rs (line 39)
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());
    }
}
source

pub fn y(&self) -> i32

Returns the topmost y coordinate of the current screen’s work area

source

pub fn x(&self) -> i32

Returns the bottom-right x coordinate of the current screen’s work area

source

pub fn w(&self) -> i32

Returns the width in pixels of the current screen’s work area

source

pub fn h(&self) -> i32

Returns the height in pixels of the current screen’s work area

source

pub fn top_left(&self) -> Coordinates<i32>

Returns the top-left x,y coordinates of the current screen’s work area

source

pub fn bottom_right(&self) -> Coordinates<i32>

Returns the bottom-right x+w, y+h coordinates of the current screen’s work area

Trait Implementations§

source§

impl Clone for Screen

source§

fn clone(&self) -> Screen

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Screen

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for Screen

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.