Fix window title is not in synced with workspace (#308)

This commit is contained in:
Lin Onetwo 2020-07-15 22:21:53 +08:00
parent 51b43e83af
commit e6902df4f3
3 changed files with 12 additions and 6 deletions

View file

@ -389,6 +389,7 @@ const addView = (browserWindow, workspace) => {
if (workspaceObj.active) {
sendToAllWindows('update-title', title);
browserWindow.setTitle(title);
}
});
@ -694,6 +695,7 @@ const setActiveView = (browserWindow, id) => {
sendToAllWindows('update-address', view.webContents.getURL(), false);
sendToAllWindows('update-title', view.webContents.getTitle());
browserWindow.setTitle(view.webContents.getTitle());
}
};

View file

@ -1,4 +1,4 @@
const { session } = require('electron');
const { app, session } = require('electron');
const {
countWorkspaces,
@ -79,11 +79,15 @@ const setActiveWorkspaceView = (id) => {
};
const removeWorkspaceView = (id) => {
// if there's only one workspace left, clear all
if (countWorkspaces() === 1) {
mainWindow.get().setBrowserView(null);
}
if (getWorkspace(id).active && countWorkspaces() > 1) {
const win = mainWindow.get();
if (win) {
win.setBrowserView(null);
win.setTitle(app.name);
sendToAllWindows('update-title', '');
}
} else if (countWorkspaces() > 1 && getWorkspace(id).active) {
setActiveWorkspaceView(getPreviousWorkspace(id).id);
}

View file

@ -52,7 +52,7 @@ const FakeTitleBar = (props) => {
}
}}
>
{(window.mode === 'main' || window.mode === 'menubar') && title ? title : window.require('electron').remote.getCurrentWindow().getTitle()}
{(window.mode === 'main' || window.mode === 'menubar') && title ? title : window.require('electron').remote.app.name}
</div>
);
};