MCPcopy
hub / github.com/Eugeny/tabby / constructor

Method constructor

app/lib/window.ts:54–181  ·  view source on GitHub ↗
(private application: Application, private configStore: any, options?: WindowOptions)

Source from the content-addressed store, hash-verified

52
53 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
54 constructor (private application: Application, private configStore: any, options?: WindowOptions) {
55 options = options ?? {}
56
57 this.windowConfig = new ElectronConfig({ name: 'window' })
58 this.windowBounds = this.windowConfig.get('windowBoundaries')
59
60 const maximized = this.windowConfig.get('maximized')
61 const bwOptions: BrowserWindowConstructorOptions = {
62 width: 800,
63 height: 600,
64 title: 'Tabby',
65 minWidth: 400,
66 minHeight: 300,
67 webPreferences: {
68 nodeIntegration: true,
69 preload: path.join(__dirname, 'sentry.js'),
70 backgroundThrottling: false,
71 contextIsolation: false,
72 },
73 maximizable: true,
74 frame: false,
75 show: false,
76 backgroundColor: '#00000000',
77 acceptFirstMouse: true,
78 }
79
80 if (this.windowBounds) {
81 Object.assign(bwOptions, this.windowBounds)
82 const closestDisplay = screen.getDisplayNearestPoint( { x: this.windowBounds.x, y: this.windowBounds.y } )
83
84 const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height]
85 const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height]
86
87 if ((left2 > right1 || right2 < left1 || top2 > bottom1 || bottom2 < top1) && !maximized) {
88 bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2
89 bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2
90 }
91 }
92
93 if (this.configStore.appearance?.frame === 'native') {
94 bwOptions.frame = true
95 } else {
96 bwOptions.titleBarStyle = 'hidden'
97 if (process.platform === 'win32') {
98 bwOptions.titleBarOverlay = {
99 color: '#00000000',
100 }
101 }
102 }
103
104 if (process.platform === 'darwin') {
105 bwOptions.visualEffectState = 'active'
106 }
107
108 if (process.platform === 'darwin') {
109 this.window = new BrowserWindow(bwOptions) as GlasstronWindow
110 } else {
111 this.window = new glasstron.BrowserWindow(bwOptions)

Callers

nothing calls this directly

Calls 12

setVibrancyMethod · 0.95
setDarkModeMethod · 0.95
hideMethod · 0.95
sendMethod · 0.95
setupWindowManagementMethod · 0.95
setupUpdaterMethod · 0.95
maximizeMethod · 0.80
onMethod · 0.80
loadFileMethod · 0.80
setTouchBarMethod · 0.80
showMethod · 0.45
focusMethod · 0.45

Tested by

no test coverage detected