Skip to content

Commit 3c8f9e9

Browse files
committed
fix playback oop
1 parent d85a766 commit 3c8f9e9

File tree

2 files changed

+28
-14
lines changed
  • packages/selenium-ide/src/main/session/controllers

2 files changed

+28
-14
lines changed

packages/selenium-ide/src/main/session/controllers/ResizablePanels/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,44 @@ export default class ResizablePanelsController extends BaseController {
3434
return currentValue || [50, 50]
3535
}
3636

37-
async recalculatePlaybackWindows() {
37+
async getPlaybackWindowDimensions() {
3838
const panelScreenPosition = await this.getPanelScreenPosition(
3939
'playback-panel'
4040
)
4141
const isWindows = process.platform === 'win32'
42-
this.session.windows.playbackWindows.forEach((playbackWindow) => {
43-
playbackWindow.setSize(
44-
panelScreenPosition.width,
45-
panelScreenPosition.height
46-
)
47-
playbackWindow.setPosition(
42+
return {
43+
position: [
4844
panelScreenPosition.x + (isWindows ? 12 : 0),
49-
panelScreenPosition.y + (isWindows ? 21 : 0)
50-
)
45+
panelScreenPosition.y + (isWindows ? 21 : 0),
46+
],
47+
size: [panelScreenPosition.width, panelScreenPosition.height],
48+
} as {
49+
position: [number, number]
50+
size: [number, number]
51+
}
52+
}
53+
54+
async recalculatePlaybackWindows() {
55+
const panelDims = await this.getPlaybackWindowDimensions()
56+
this.session.windows.playbackWindows.forEach((playbackWindow) => {
57+
playbackWindow.setSize(...panelDims.size)
58+
playbackWindow.setPosition(...panelDims.position)
5159
})
5260
}
5361

5462
async setPanelGroup(id: string, dimensions: number[]) {
5563
this.session.store.set(`panelGroup.${id}`, dimensions)
5664
this.recalculatePlaybackWindows()
5765
}
66+
5867
async getPanelScreenPosition(id: string) {
5968
const projectWindow = await this.session.windows.get('project-editor')
6069
const projectWindowBounds = await projectWindow.getBounds()
6170
const panelGroupPosition =
6271
(await projectWindow.webContents.executeJavaScript(
6372
`JSON.parse(JSON.stringify(document.querySelector('[data-panel-id="${id}"]').getBoundingClientRect()))`
6473
)) as Rect
74+
// Holy shit what are these numbers even related to :\
6575
return {
6676
x: Math.round(panelGroupPosition.x + projectWindowBounds.x) + 2,
6777
y: Math.round(panelGroupPosition.y + projectWindowBounds.y) + 30,

packages/selenium-ide/src/main/session/controllers/Windows/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { Session } from 'main/types'
1313
import { isAutomated } from 'main/util'
1414
import { join } from 'node:path'
1515
import BaseController from '../Base'
16+
import { window as playbackWindowOpts } from 'browser/windows/PlaybackWindow/controller'
1617

1718
const playbackWindowName = 'playback-window'
1819
const playbackCSS = readFileSync(join(__dirname, 'highlight.css'), 'utf-8')
1920
const playbackWindowOptions = {
21+
...playbackWindowOpts(),
2022
webPreferences: {
2123
devTools: !isAutomated,
22-
nodeIntegration: false,
23-
nodeIntegrationInSubFrames: true,
2424
preload: join(__dirname, `playback-window-preload-bundle.js`),
2525
},
2626
}
@@ -53,13 +53,14 @@ const windowLoaderFactoryMap: WindowLoaderFactoryMap = Object.fromEntries(
5353
const windowConfig = window()
5454
const options: Electron.BrowserWindowConstructorOptions = {
5555
...windowConfig,
56+
..._options,
5657
webPreferences: {
5758
devTools: !isAutomated,
5859
...(windowConfig?.webPreferences ?? {}),
5960
preload: hasPreload ? preloadPath : undefined,
6061
sandbox: true,
62+
...(_options.webPreferences ?? {})
6163
},
62-
..._options,
6364
}
6465
const win = new BrowserWindow(options)
6566
win.loadFile(join(__dirname, `${filename}.html`))
@@ -162,7 +163,7 @@ export default class WindowsController extends BaseController {
162163
this.playbackWindows = []
163164
}
164165

165-
async get(name: string): Promise<BrowserWindow> {
166+
get(name: string): BrowserWindow {
166167
return this.windows[name]
167168
}
168169

@@ -388,7 +389,10 @@ export default class WindowsController extends BaseController {
388389
window.webContents.setWindowOpenHandler(() => {
389390
return {
390391
action: 'allow',
391-
overrideBrowserWindowOptions: playbackWindowOptions,
392+
overrideBrowserWindowOptions: {
393+
...playbackWindowOptions,
394+
parent: this.get(projectEditorWindowName),
395+
},
392396
}
393397
})
394398

0 commit comments

Comments
 (0)