Skip to content

Commit

Permalink
fix: Adjust the game launch window behavior. Fix #708 and #707
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Jul 30, 2024
1 parent f88cf1d commit 07217a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions xmcl-electron-app/main/controllers/gameLaunch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ export const gameLaunch: ControllerPlugin = function (this: ElectronController)
this.app.once('engine-ready', () => {
this.app.registry.get(LaunchService).then((service) => {
service.on('minecraft-window-ready', ({ hideLauncher }) => {
if (this.mainWin && this.mainWin.isVisible()) {
if (this.mainWin && (this.mainWin.isVisible() || this.mainWin.isMinimized())) {
this.mainWin.webContents.send('minecraft-window-ready')

if (hideLauncher) {
this.mainWin.hide()
}
}
}).on('minecraft-start', ({ showLog }) => {
this.parking = true
if (!this.getLoggerWindow() && showLog) {
this.createMonitorWindow()
}
}).on('minecraft-exit', (status) => {
if (status.hideLauncher) {
if (this.mainWin) {
this.mainWin.show()
}
this.parking = false
if (this.mainWin && !this.mainWin.isVisible()) {
this.mainWin.show()
}
this.app.controller.broadcast('minecraft-exit', status)
const loggerWin = this.getLoggerWindow()
Expand Down
2 changes: 1 addition & 1 deletion xmcl-electron-app/main/controllers/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const trayPlugin: ControllerPlugin = function (this: ElectronController)
},
},
]
if (app.platform.os === 'osx') {
if (app.platform.os === 'osx' || app.platform.os === 'linux') {
const show = () => {
const window = this.mainWin
if ((!window || window.isDestroyed()) && this.activatedManifest) {
Expand Down
6 changes: 5 additions & 1 deletion xmcl-electron-app/main/controllers/windowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export const windowController: ControllerPlugin = function (this: ElectronContro
}
return false
case Operation.Close:
window.close()
if (this.parking) {
window.hide()
} else {
window.close()
}
return true
}
}
Expand Down

0 comments on commit 07217a3

Please sign in to comment.