Giter Site home page Giter Site logo

greenhat616 / display-info Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nashaofu/display-info

0.0 0.0 0.0 85 KB

Cross-platform get display info for MacOS、Windows、Linux, Like electron Display Object.

Home Page: https://docs.rs/display-info

License: Apache License 2.0

Rust 100.00%

display-info's Introduction

display-info

Cross-platform get display info for MacOS、Windows、Linux. Like electron Display Object

Example

use display_info::DisplayInfo;
use std::time::Instant;

fn main() {
  let start = Instant::now();

  let display_infos = DisplayInfo::all().unwrap();
  for display_info in display_infos {
    println!("display_info {display_info:?}");
  }
  let display_info = DisplayInfo::from_point(100, 100).unwrap();
  println!("display_info {display_info:?}");
  println!("运行耗时: {:?}", start.elapsed());
}

DisplayInfo struct

  • id u32 - Unique identifier associated with the display.
  • name String - The name of the display
  • raw_handle CGDisplay/HMONITOR/Output - Native display raw handle
  • x i32 - The display x coordinate.
  • y i32 - The display y coordinate.
  • width u32 - The display pixel width.
  • height u32 - The display pixel height.
  • rotation f32 - Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees.
  • scale_factor f32 - Output device's pixel scale factor.
  • frequency f32 - The display refresh rate.
  • is_primary bool - Whether the screen is the main screen

Linux requirements

On Linux, you need to install libxcblibxrandr

Debian/Ubuntu:

apt-get install libxcb1 libxrandr2

Alpine:

apk add libxcb libxrandr

ArchLinux:

pacman -S libxcb libxrandr

display-info's People

Contributors

nashaofu avatar greenhat616 avatar mdacach avatar sergioribera avatar olssdani avatar stefnotch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.