-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMockDisplay.ts
75 lines (69 loc) · 1.87 KB
/
MockDisplay.ts
1
2
3
4
5
6
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { Rectangle, Size } from 'electron'
type Availability = 'available' | 'unavailable' | 'unknown'
let displayId = 1
export class MockDisplay implements Electron.Display {
private _bounds = { x: 0, y: 0, width: 1920, height: 1080 }
private _menuBarHeight = 30
id: number
rotation = 0
scaleFactor = 1
touchSupport = 'available' as Availability
get bounds(): Rectangle {
return { ...this._bounds }
}
set bounds(bounds: Rectangle) {
Object.assign(this._bounds, bounds)
}
get workArea(): Rectangle {
return {
x: this._bounds.x,
y: this._bounds.y + this._menuBarHeight,
width: this._bounds.width,
height: this._bounds.height - this._menuBarHeight,
}
}
set workArea(workArea: Rectangle) {
Object.assign(this.bounds, {
x: workArea.x,
y: workArea.y - this._menuBarHeight,
width: workArea.width,
height: workArea.height + this._menuBarHeight,
})
}
accelerometerSupport: 'available' | 'unavailable' | 'unknown' = 'unknown'
monochrome = false
colorDepth = 24
colorSpace = 'rgb8'
get size(): Size {
return {
width: this._bounds.width,
height: this._bounds.height,
}
}
set size(size: Size) {
Object.assign(this._bounds, size)
}
get workAreaSize(): Size {
return {
width: this.workArea.width,
height: this.workArea.height,
}
}
set workAreaSize(size: Size) {
Object.assign(this.workArea, size)
}
depthPerComponent = 24
displayFrequency = 60
internal = displayId ? false : true
label: string
// for Electron 32 update
detected = true
maximumCursorSize = { width: 128, height: 128 }
nativeOrigin = { x: 0, y: 0 }
constructor(display: Partial<Electron.Display> = {}) {
this.id = displayId++
this.label = `Display ${this.id}`
Object.assign(this, display)
Object.assign(this._bounds, display.size, display.bounds)
}
}