MCPcopy
hub / github.com/agalwood/Motrix / openWindow

Method openWindow

src/main/ui/WindowManager.js:85–151  ·  view source on GitHub ↗
(page, options = {})

Source from the content-addressed store, hash-verified

83 }
84
85 openWindow (page, options = {}) {
86 const pageOptions = this.getPageOptions(page)
87 const { hidden } = options
88 const autoHideWindow = this.userConfig['auto-hide-window']
89 let window = this.windows[page] || null
90 if (window) {
91 window.show()
92 window.focus()
93 return window
94 }
95
96 window = new BrowserWindow({
97 ...defaultBrowserOptions,
98 ...pageOptions.attrs,
99 webPreferences: {
100 enableRemoteModule: true,
101 contextIsolation: false,
102 nodeIntegration: true,
103 nodeIntegrationInWorker: true
104 }
105 })
106
107 const bounds = this.getPageBounds(page)
108 if (bounds) {
109 window.setBounds(bounds)
110 }
111
112 if (is.dev() && pageOptions.openDevTools) {
113 window.webContents.openDevTools()
114 }
115
116 window.webContents.setWindowOpenHandler(({ url }) => {
117 shell.openExternal(url)
118 return { action: 'deny' }
119 })
120
121 if (pageOptions.url) {
122 window.loadURL(pageOptions.url)
123 }
124
125 window.once('ready-to-show', () => {
126 if (!hidden) {
127 window.show()
128 }
129 })
130
131 window.on('enter-full-screen', () => {
132 this.emit('enter-full-screen', window)
133 })
134
135 window.on('leave-full-screen', () => {
136 this.emit('leave-full-screen', window)
137 })
138
139 this.handleWindowState(page, window)
140
141 this.handleWindowClose(pageOptions, page, window)
142

Callers 1

showPageMethod · 0.80

Calls 9

getPageOptionsMethod · 0.95
getPageBoundsMethod · 0.95
handleWindowStateMethod · 0.95
handleWindowCloseMethod · 0.95
bindAfterClosedMethod · 0.95
addWindowMethod · 0.95
handleWindowBlurMethod · 0.95
showMethod · 0.80
openExternalMethod · 0.80

Tested by

no test coverage detected