nashaofu / node-screenshots

Zero-dependent. A native nodejs screenshots library for Mac、Windows、Linux.
Apache License 2.0
301 stars 11 forks source link

why is from_display func removed in release 0.1.0? #35

Closed bruceauyeung closed 6 months ago

bruceauyeung commented 6 months ago

we need this api to get capturer when i have an Electron.Display object.would you please add this api back to future release version?

nashaofu commented 6 months ago

Display_id is different from Electron, so it is removed

bruceauyeung commented 6 months ago

Display_id is different from Electron, so it is removed

according to https://github.com/nashaofu/display-info/blob/55071ca8d10277966ceb2ba28343853787f49a6b/src/linux/xorg.rs#L135

and https://www.electronjs.org/docs/latest/api/structures/display

id number - Unique identifier associated with the display. A value of of -1 means the display is invalid or the correct id is not yet known, and a value of -10 means the display is a virtual display assigned to a unified desktop.

display id from node_screenshots and electron(most time) both come from os and they are identical ,at least for Xorg case, right ? are they different for Wayland case ?

this code snippets works well with electron v22.3.27, on linux-arm64-xorg platform

const all = Screenshots.all()
for(const s of all){
  if(s.id ===electronDisplayId){
    return s
  }
}