-
-
Notifications
You must be signed in to change notification settings - Fork 834
update emain-window to do repositioning in a simpler way #3087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,8 +40,8 @@ export function calculateWindowBounds( | |
| ): { x: number; y: number; width: number; height: number } { | ||
| let winWidth = winSize?.width; | ||
| let winHeight = winSize?.height; | ||
| let winPosX = pos?.x ?? 100; | ||
| let winPosY = pos?.y ?? 100; | ||
| const winPosX = pos?.x ?? 100; | ||
| const winPosY = pos?.y ?? 100; | ||
|
|
||
| if ( | ||
| (winWidth == null || winWidth === 0 || winHeight == null || winHeight === 0) && | ||
|
|
@@ -86,7 +86,7 @@ export function calculateWindowBounds( | |
| winWidth = Math.max(winWidth, MinWindowWidth); | ||
| winHeight = Math.max(winHeight, MinWindowHeight); | ||
|
|
||
| let winBounds = { | ||
| const winBounds = { | ||
| x: winPosX, | ||
| y: winPosY, | ||
| width: winWidth, | ||
|
|
@@ -393,6 +393,8 @@ export class WaveBrowserWindow extends BaseWindow { | |
| private async initializeTab(tabView: WaveTabView, primaryStartupTab: boolean) { | ||
| const clientId = await getClientId(); | ||
| await this.awaitWithDevTimeout(tabView.initPromise, "initPromise", tabView.waveTabId); | ||
| const winBounds = this.getContentBounds(); | ||
| tabView.setBounds({ x: 0, y: 0, width: winBounds.width, height: winBounds.height }); | ||
| this.contentView.addChildView(tabView); | ||
| const initOpts: WaveInitOpts = { | ||
| tabId: tabView.waveTabId, | ||
|
|
@@ -406,7 +408,7 @@ export class WaveBrowserWindow extends BaseWindow { | |
| tabView.savedInitOpts = { ...initOpts }; | ||
| tabView.savedInitOpts.activate = false; | ||
| delete tabView.savedInitOpts.primaryTabStartup; | ||
| let startTime = Date.now(); | ||
| const startTime = Date.now(); | ||
| console.log( | ||
| "before wave ready, init tab, sending wave-init", | ||
| tabView.waveTabId, | ||
|
|
@@ -456,14 +458,12 @@ export class WaveBrowserWindow extends BaseWindow { | |
| this.allLoadedTabViews.set(tabView.waveTabId, tabView); | ||
| if (!tabInitialized) { | ||
| console.log("initializing a new tab", primaryStartupTab ? "(primary startup)" : ""); | ||
| const p1 = this.initializeTab(tabView, primaryStartupTab); | ||
| const p2 = this.repositionTabsSlowly(100); | ||
| await Promise.all([p1, p2]); | ||
| await this.initializeTab(tabView, primaryStartupTab); | ||
| this.finalizePositioning(); | ||
| } else { | ||
| console.log("reusing an existing tab, calling wave-init", tabView.waveTabId); | ||
| const p1 = this.repositionTabsSlowly(35); | ||
| const p2 = tabView.webContents.send("wave-init", tabView.savedInitOpts); // reinit | ||
| await Promise.all([p1, p2]); | ||
| tabView.webContents.send("wave-init", tabView.savedInitOpts); // reinit | ||
| this.finalizePositioning(); | ||
| } | ||
|
|
||
| // something is causing the new tab to lose focus so it requires manual refocusing | ||
|
|
@@ -480,35 +480,6 @@ export class WaveBrowserWindow extends BaseWindow { | |
| }, 30); | ||
| } | ||
|
|
||
| private async repositionTabsSlowly(delayMs: number) { | ||
| const activeTabView = this.activeTabView; | ||
| const winBounds = this.getContentBounds(); | ||
| if (activeTabView == null) { | ||
| return; | ||
| } | ||
| if (activeTabView.isOnScreen()) { | ||
| activeTabView.setBounds({ | ||
| x: 0, | ||
| y: 0, | ||
| width: winBounds.width, | ||
| height: winBounds.height, | ||
| }); | ||
| } else { | ||
| activeTabView.setBounds({ | ||
| x: winBounds.width - 10, | ||
| y: winBounds.height - 10, | ||
| width: winBounds.width, | ||
| height: winBounds.height, | ||
| }); | ||
| } | ||
| await delay(delayMs); | ||
| if (this.activeTabView != activeTabView) { | ||
| // another tab view has been set, do not finalize this layout | ||
| return; | ||
| } | ||
| this.finalizePositioning(); | ||
| } | ||
|
|
||
| private finalizePositioning() { | ||
| if (this.isDestroyed()) { | ||
| return; | ||
|
|
@@ -546,7 +517,7 @@ export class WaveBrowserWindow extends BaseWindow { | |
| private removeTabViewLater(tabId: string, delayMs: number) { | ||
| setTimeout(() => { | ||
| this.removeTabView(tabId, false); | ||
| }, 1000); | ||
| }, delayMs); | ||
| } | ||
|
|
||
| // the queue and this function are used to serialize operations that update the window contents view | ||
|
|
@@ -744,7 +715,7 @@ ipcMain.on("set-active-tab", async (event, tabId) => { | |
| await ww?.setActiveTab(tabId, true); | ||
| }); | ||
|
|
||
| ipcMain.on("create-tab", async (event, opts) => { | ||
| ipcMain.on("create-tab", async (event, _opts) => { | ||
| const senderWc = event.sender; | ||
| const ww = getWaveWindowByWebContentsId(senderWc.id); | ||
| if (ww != null) { | ||
|
|
@@ -818,7 +789,7 @@ ipcMain.on("delete-workspace", (event, workspaceId) => { | |
|
|
||
| const workspaceList = await WorkspaceService.ListWorkspaces(); | ||
|
|
||
| const workspaceHasWindow = !!workspaceList.find((wse) => wse.workspaceid === workspaceId)?.windowid; | ||
| const _workspaceHasWindow = !!workspaceList.find((wse) => wse.workspaceid === workspaceId)?.windowid; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Unused variable - |
||
|
|
||
| const choice = dialog.showMessageBoxSync(this, { | ||
| type: "question", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Check file size and structure wc -l emain/emain-window.tsRepository: wavetermdev/waveterm
Length of output: 89
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1801
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1805
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 338
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1898
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1568
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 3304
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 971
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 506
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 2124
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 160
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1277
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 4365
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 981
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 46
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 402
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 755
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 715
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 1349
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 591
🏁 Script executed:
Repository: wavetermdev/waveterm
Length of output: 121
Attach the new
WaveTabViewoff-screen until initialization completes.Lines 397–398 position the tab at full window bounds before
waveReadyPromiseresolves. SinceaddChildViewappends to the child list and Electron uses child order for z-layer ordering, this uninitialized tab becomes topmost and obscures the current tab during slow initialization or workspace switches. Move it off-screen here and letfinalizePositioning()bring it on-screen only after init succeeds.💡 Suggested change
📝 Committable suggestion
🤖 Prompt for AI Agents