mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Close a window automatically when the last tab is closed (#131)
This commit is contained in:
parent
1c99e1ed4c
commit
b2ee164b85
@ -217,6 +217,15 @@ async function handleWSEvent(evtMsg: WSEventType) {
|
|||||||
const newWin = createBrowserWindow(clientData.oid, windowData);
|
const newWin = createBrowserWindow(clientData.oid, windowData);
|
||||||
await newWin.readyPromise;
|
await newWin.readyPromise;
|
||||||
newWin.show();
|
newWin.show();
|
||||||
|
} else if (evtMsg.eventtype == "electron:closewindow") {
|
||||||
|
if (evtMsg.data === undefined) return;
|
||||||
|
const windows = electron.BrowserWindow.getAllWindows();
|
||||||
|
for (const window of windows) {
|
||||||
|
if ((window as any).waveWindowId === evtMsg.data) {
|
||||||
|
// Bypass the "Are you sure?" dialog, since this event is called when there's no more tabs for the window.
|
||||||
|
window.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("unhandled electron ws eventtype", evtMsg.eventtype);
|
console.log("unhandled electron ws eventtype", evtMsg.eventtype);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ const (
|
|||||||
WSEvent_BlockControllerStatus = "blockcontroller:status"
|
WSEvent_BlockControllerStatus = "blockcontroller:status"
|
||||||
WSEvent_LayoutAction = "layoutaction"
|
WSEvent_LayoutAction = "layoutaction"
|
||||||
WSEvent_ElectronNewWindow = "electron:newwindow"
|
WSEvent_ElectronNewWindow = "electron:newwindow"
|
||||||
|
WSEvent_ElectronCloseWindow = "electron:closewindow"
|
||||||
WSEvent_Rpc = "rpc"
|
WSEvent_Rpc = "rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,10 +67,13 @@ func (svc *WindowService) CloseTab(ctx context.Context, uiContext wstore.UIConte
|
|||||||
var newActiveTabId string
|
var newActiveTabId string
|
||||||
if len(ws.TabIds) > 0 {
|
if len(ws.TabIds) > 0 {
|
||||||
newActiveTabId = ws.TabIds[0]
|
newActiveTabId = ws.TabIds[0]
|
||||||
|
wstore.SetActiveTab(ctx, uiContext.WindowId, newActiveTabId)
|
||||||
} else {
|
} else {
|
||||||
newActiveTabId = ""
|
eventbus.SendEventToElectron(eventbus.WSEventType{
|
||||||
|
EventType: eventbus.WSEvent_ElectronCloseWindow,
|
||||||
|
Data: uiContext.WindowId,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
wstore.SetActiveTab(ctx, uiContext.WindowId, newActiveTabId)
|
|
||||||
}
|
}
|
||||||
return wstore.ContextGetUpdatesRtn(ctx), nil
|
return wstore.ContextGetUpdatesRtn(ctx), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user