Skip to content

Commit

Permalink
fix: quick ask not show (janhq#2315)
Browse files Browse the repository at this point in the history
* fix: quick ask not show

* fix: window resize does not work on windows 11
  • Loading branch information
louis-jan authored Mar 11, 2024
1 parent c8ea16e commit bbfc686
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ app
} else {
app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (windowManager.mainWindow) {
if (windowManager.mainWindow.isMinimized())
windowManager.mainWindow.restore()
windowManager.mainWindow.focus()
}
windowManager.showMainWindow()
})
}
app.on('activate', () => {
Expand Down Expand Up @@ -107,7 +103,12 @@ function createMainWindow() {

function registerGlobalShortcuts() {
const ret = registerShortcut(quickAskHotKey, (selectedText: string) => {
windowManager.showMainWindow()
if (!windowManager.isQuickAskWindowVisible()) {
windowManager.showQuickAskWindow()
windowManager.sendQuickAskSelectedText(selectedText)
} else {
windowManager.hideQuickAskWindow()
}
})

if (!ret) {
Expand Down
1 change: 1 addition & 0 deletions electron/managers/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class WindowManager {
expandQuickAskWindow(heightOffset: number): void {
const width = quickAskWindowConfig.width!
const height = quickAskWindowConfig.height! + heightOffset
this._quickAskWindow?.setMinimumSize(width, height)
this._quickAskWindow?.setSize(width, height, true)
}

Expand Down

0 comments on commit bbfc686

Please sign in to comment.