Skip to content

Commit f250fb9

Browse files
committed
update emain-window to do repositioning in a simpler way (the old way doesn't buy us anything)
1 parent 4ee003a commit f250fb9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

electron.vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default defineConfig({
161161
"**/*.md",
162162
"**/*.mdx",
163163
"**/*.json",
164-
"emain/**",
164+
"**/emain/**",
165165
"**/*.txt",
166166
"**/*.log",
167167
],

emain/emain-window.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function calculateWindowBounds(
4040
): { x: number; y: number; width: number; height: number } {
4141
let winWidth = winSize?.width;
4242
let winHeight = winSize?.height;
43-
let winPosX = pos?.x ?? 100;
44-
let winPosY = pos?.y ?? 100;
43+
const winPosX = pos?.x ?? 100;
44+
const winPosY = pos?.y ?? 100;
4545

4646
if (
4747
(winWidth == null || winWidth === 0 || winHeight == null || winHeight === 0) &&
@@ -86,7 +86,7 @@ export function calculateWindowBounds(
8686
winWidth = Math.max(winWidth, MinWindowWidth);
8787
winHeight = Math.max(winHeight, MinWindowHeight);
8888

89-
let winBounds = {
89+
const winBounds = {
9090
x: winPosX,
9191
y: winPosY,
9292
width: winWidth,
@@ -393,6 +393,8 @@ export class WaveBrowserWindow extends BaseWindow {
393393
private async initializeTab(tabView: WaveTabView, primaryStartupTab: boolean) {
394394
const clientId = await getClientId();
395395
await this.awaitWithDevTimeout(tabView.initPromise, "initPromise", tabView.waveTabId);
396+
const winBounds = this.getContentBounds();
397+
tabView.setBounds({ x: 0, y: 0, width: winBounds.width, height: winBounds.height });
396398
this.contentView.addChildView(tabView);
397399
const initOpts: WaveInitOpts = {
398400
tabId: tabView.waveTabId,
@@ -406,7 +408,7 @@ export class WaveBrowserWindow extends BaseWindow {
406408
tabView.savedInitOpts = { ...initOpts };
407409
tabView.savedInitOpts.activate = false;
408410
delete tabView.savedInitOpts.primaryTabStartup;
409-
let startTime = Date.now();
411+
const startTime = Date.now();
410412
console.log(
411413
"before wave ready, init tab, sending wave-init",
412414
tabView.waveTabId,
@@ -456,14 +458,12 @@ export class WaveBrowserWindow extends BaseWindow {
456458
this.allLoadedTabViews.set(tabView.waveTabId, tabView);
457459
if (!tabInitialized) {
458460
console.log("initializing a new tab", primaryStartupTab ? "(primary startup)" : "");
459-
const p1 = this.initializeTab(tabView, primaryStartupTab);
460-
const p2 = this.repositionTabsSlowly(100);
461-
await Promise.all([p1, p2]);
461+
await this.initializeTab(tabView, primaryStartupTab);
462+
this.finalizePositioning();
462463
} else {
463464
console.log("reusing an existing tab, calling wave-init", tabView.waveTabId);
464-
const p1 = this.repositionTabsSlowly(35);
465-
const p2 = tabView.webContents.send("wave-init", tabView.savedInitOpts); // reinit
466-
await Promise.all([p1, p2]);
465+
await tabView.webContents.send("wave-init", tabView.savedInitOpts); // reinit
466+
this.finalizePositioning();
467467
}
468468

469469
// something is causing the new tab to lose focus so it requires manual refocusing
@@ -543,7 +543,7 @@ export class WaveBrowserWindow extends BaseWindow {
543543
}
544544
}
545545

546-
private removeTabViewLater(tabId: string, delayMs: number) {
546+
private removeTabViewLater(tabId: string, _delayMs: number) {
547547
setTimeout(() => {
548548
this.removeTabView(tabId, false);
549549
}, 1000);
@@ -744,7 +744,7 @@ ipcMain.on("set-active-tab", async (event, tabId) => {
744744
await ww?.setActiveTab(tabId, true);
745745
});
746746

747-
ipcMain.on("create-tab", async (event, opts) => {
747+
ipcMain.on("create-tab", async (event, _opts) => {
748748
const senderWc = event.sender;
749749
const ww = getWaveWindowByWebContentsId(senderWc.id);
750750
if (ww != null) {
@@ -818,7 +818,7 @@ ipcMain.on("delete-workspace", (event, workspaceId) => {
818818

819819
const workspaceList = await WorkspaceService.ListWorkspaces();
820820

821-
const workspaceHasWindow = !!workspaceList.find((wse) => wse.workspaceid === workspaceId)?.windowid;
821+
const _workspaceHasWindow = !!workspaceList.find((wse) => wse.workspaceid === workspaceId)?.windowid;
822822

823823
const choice = dialog.showMessageBoxSync(this, {
824824
type: "question",

0 commit comments

Comments
 (0)