diff --git a/frontend/app/store/global.ts b/frontend/app/store/global.ts index 24bbdd57..1d67119f 100644 --- a/frontend/app/store/global.ts +++ b/frontend/app/store/global.ts @@ -433,6 +433,7 @@ async function createBlock(blockDef: BlockDef, magnified = false): Promise { - console.log("setting inner rect", nodeInnerRect); setInnerRect(nodeInnerRect); setDebounceTimeout(null); }, nodeModel.animationTimeS * 1000) diff --git a/frontend/layout/lib/layoutTree.ts b/frontend/layout/lib/layoutTree.ts index dccab4cc..11f61f0e 100644 --- a/frontend/layout/lib/layoutTree.ts +++ b/frontend/layout/lib/layoutTree.ts @@ -268,7 +268,10 @@ export function insertNode(layoutState: LayoutTreeState, action: LayoutTreeInser addChildAt(insertLoc.node, insertLoc.index, action.node); if (action.magnified) { layoutState.magnifiedNodeId = action.node.id; + layoutState.focusedNodeId = action.node.id; } + } + if (action.focused) { layoutState.focusedNodeId = action.node.id; } layoutState.generation++; @@ -290,7 +293,10 @@ export function insertNodeAtIndex(layoutState: LayoutTreeState, action: LayoutTr addChildAt(insertLoc.node, insertLoc.index + 1, action.node); if (action.magnified) { layoutState.magnifiedNodeId = action.node.id; + layoutState.focusedNodeId = action.node.id; } + } + if (action.focused) { layoutState.focusedNodeId = action.node.id; } layoutState.generation++; diff --git a/frontend/layout/lib/types.ts b/frontend/layout/lib/types.ts index 83c58bf7..e9ea9c13 100644 --- a/frontend/layout/lib/types.ts +++ b/frontend/layout/lib/types.ts @@ -125,7 +125,11 @@ interface InsertNodeOperation { /** * Whether the inserted node should be magnified. */ - magnified?: boolean; + magnified: boolean; + /** + * Whether the inserted node should be focused. + */ + focused: boolean; } /** diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 4e618eab..5c117120 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -209,7 +209,8 @@ declare global { blockid: string; nodesize?: number; indexarr?: number[]; - magnified?: boolean; + focused: boolean; + magnified: boolean; }; // waveobj.LayoutState diff --git a/pkg/service/windowservice/windowservice.go b/pkg/service/windowservice/windowservice.go index 42976839..2d644cfa 100644 --- a/pkg/service/windowservice/windowservice.go +++ b/pkg/service/windowservice/windowservice.go @@ -139,6 +139,7 @@ func (svc *WindowService) MoveBlockToNewWindow(ctx context.Context, currentTabId wlayout.QueueLayoutActionForTab(ctx, newWindow.ActiveTabId, waveobj.LayoutActionData{ ActionType: wlayout.LayoutActionDataType_Insert, BlockId: blockId, + Focused: true, }) return waveobj.ContextGetUpdatesRtn(ctx), nil } diff --git a/pkg/waveobj/wtype.go b/pkg/waveobj/wtype.go index f18466e9..88135929 100644 --- a/pkg/waveobj/wtype.go +++ b/pkg/waveobj/wtype.go @@ -178,7 +178,8 @@ type LayoutActionData struct { BlockId string `json:"blockid"` NodeSize *uint `json:"nodesize,omitempty"` IndexArr *[]int `json:"indexarr,omitempty"` - Magnified *bool `json:"magnified,omitempty"` + Focused bool `json:"focused"` + Magnified bool `json:"magnified"` } type LayoutState struct { diff --git a/pkg/wlayout/wlayout.go b/pkg/wlayout/wlayout.go index f2ab889c..b68e8187 100644 --- a/pkg/wlayout/wlayout.go +++ b/pkg/wlayout/wlayout.go @@ -24,6 +24,7 @@ type PortableLayout []struct { IndexArr []int `json:"indexarr"` Size *uint `json:"size,omitempty"` BlockDef *waveobj.BlockDef `json:"blockdef"` + Focused bool `json:"focused"` } func GetStarterLayout() PortableLayout { @@ -33,7 +34,7 @@ func GetStarterLayout() PortableLayout { waveobj.MetaKey_View: "term", waveobj.MetaKey_Controller: "shell", }, - }}, + }, Focused: true}, {IndexArr: []int{1}, BlockDef: &waveobj.BlockDef{ Meta: waveobj.MetaMapType{ waveobj.MetaKey_View: "cpuplot", @@ -77,7 +78,7 @@ func GetNewTabLayout() PortableLayout { waveobj.MetaKey_View: "term", waveobj.MetaKey_Controller: "shell", }, - }}, + }, Focused: true}, } } @@ -132,6 +133,7 @@ func ApplyPortableLayout(ctx context.Context, tabId string, layout PortableLayou BlockId: blockData.OID, IndexArr: &layoutAction.IndexArr, NodeSize: layoutAction.Size, + Focused: layoutAction.Focused, } } diff --git a/pkg/wshrpc/wshserver/wshserver.go b/pkg/wshrpc/wshserver/wshserver.go index 41d409e4..be4f1f16 100644 --- a/pkg/wshrpc/wshserver/wshserver.go +++ b/pkg/wshrpc/wshserver/wshserver.go @@ -281,7 +281,8 @@ func (ws *WshServer) CreateBlockCommand(ctx context.Context, data wshrpc.Command wlayout.QueueLayoutActionForTab(ctx, tabId, waveobj.LayoutActionData{ ActionType: wlayout.LayoutActionDataType_Insert, BlockId: blockRef.OID, - Magnified: &data.Magnified, + Magnified: data.Magnified, + Focused: true, }) return &waveobj.ORef{OType: waveobj.OType_Block, OID: blockRef.OID}, nil }