diff --git a/emain/emain.ts b/emain/emain.ts index 94e5887b7..28cf342c6 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -297,11 +297,31 @@ function createBrowserWindow( waveWindow: WaveWindow, settings: SettingsConfigType ): WaveBrowserWindow { + let winWidth = waveWindow?.winsize?.width; + let winHeight = waveWindow?.winsize?.height; + let winPosX = waveWindow.pos.x; + let winPosY = waveWindow.pos.y; + if (winWidth == null || winWidth == 0) { + const primaryDisplay = electron.screen.getPrimaryDisplay(); + const { width } = primaryDisplay.workAreaSize; + winWidth = width - winPosX - 100; + if (winWidth > 2000) { + winWidth = 2000; + } + } + if (winHeight == null || winHeight == 0) { + const primaryDisplay = electron.screen.getPrimaryDisplay(); + const { height } = primaryDisplay.workAreaSize; + winHeight = height - winPosY - 100; + if (winHeight > 1200) { + winHeight = 1200; + } + } let winBounds = { - x: waveWindow.pos.x, - y: waveWindow.pos.y, - width: waveWindow.winsize.width, - height: waveWindow.winsize.height, + x: winPosX, + y: winPosY, + width: winWidth, + height: winHeight, }; winBounds = ensureBoundsAreVisible(winBounds); const winOpts: Electron.BrowserWindowConstructorOptions = { diff --git a/pkg/service/clientservice/clientservice.go b/pkg/service/clientservice/clientservice.go index c64f4e938..92a62b913 100644 --- a/pkg/service/clientservice/clientservice.go +++ b/pkg/service/clientservice/clientservice.go @@ -60,7 +60,7 @@ func (cs *ClientService) GetWindow(windowId string) (*wstore.Window, error) { } func (cs *ClientService) MakeWindow(ctx context.Context) (*wstore.Window, error) { - return wstore.CreateWindow(ctx) + return wstore.CreateWindow(ctx, nil) } // moves the window to the front of the windowId stack @@ -155,12 +155,12 @@ func (cs *ClientService) BootstrapStarterLayout(ctx context.Context) error { wstore.MetaKey_View: "waveai", }, }}, - {IndexArr: []int{2, 2}, BlockDef: &wstore.BlockDef{ - Meta: wstore.MetaMapType{ - wstore.MetaKey_View: "web", - wstore.MetaKey_Url: "https://www.youtube.com/embed/cKqsw_sAsU8", - }, - }}, + // {IndexArr: []int{2, 2}, BlockDef: &wstore.BlockDef{ + // Meta: wstore.MetaMapType{ + // wstore.MetaKey_View: "web", + // wstore.MetaKey_Url: "https://www.youtube.com/embed/cKqsw_sAsU8", + // }, + // }}, } objsvc := &objectservice.ObjectService{} diff --git a/pkg/service/windowservice/windowservice.go b/pkg/service/windowservice/windowservice.go index 3522175a4..b673f71c3 100644 --- a/pkg/service/windowservice/windowservice.go +++ b/pkg/service/windowservice/windowservice.go @@ -117,7 +117,7 @@ func (svc *WindowService) MoveBlockToNewWindow(ctx context.Context, currentTabId if !foundBlock { return nil, fmt.Errorf("block not found in current tab") } - newWindow, err := wstore.CreateWindow(ctx) + newWindow, err := wstore.CreateWindow(ctx, nil) if err != nil { return nil, fmt.Errorf("error creating window: %w", err) } diff --git a/pkg/wstore/wstore.go b/pkg/wstore/wstore.go index 3988fa7bd..7e3240354 100644 --- a/pkg/wstore/wstore.go +++ b/pkg/wstore/wstore.go @@ -317,11 +317,17 @@ func UpdateObjectMeta(ctx context.Context, oref waveobj.ORef, meta MetaMapType) }) } -func CreateWindow(ctx context.Context) (*Window, error) { +func CreateWindow(ctx context.Context, winSize *WinSize) (*Window, error) { windowId := uuid.NewString() workspaceId := uuid.NewString() tabId := uuid.NewString() layoutNodeId := uuid.NewString() + if winSize == nil { + winSize = &WinSize{ + Width: 1200, + Height: 800, + } + } window := &Window{ OID: windowId, WorkspaceId: workspaceId, @@ -331,10 +337,7 @@ func CreateWindow(ctx context.Context) (*Window, error) { X: 100, Y: 100, }, - WinSize: WinSize{ - Width: 1200, - Height: 800, - }, + WinSize: *winSize, } err := DBInsert(ctx, window) if err != nil { @@ -427,7 +430,7 @@ func EnsureInitialData() error { if len(client.WindowIds) > 0 { return nil } - _, err = CreateWindow(ctx) + _, err = CreateWindow(ctx, &WinSize{0, 0}) if err != nil { return fmt.Errorf("error creating window: %w", err) }