Skip to content

Commit 2eb6ab8

Browse files
committed
fix(app): support desktop titlebar double-click maximize
1 parent 9b20679 commit 2eb6ab8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/app/src/components/titlebar.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ export function Titlebar() {
8787

8888
const tauri = (
8989
window as unknown as {
90-
__TAURI__?: { window?: { getCurrentWindow?: () => { startDragging?: () => Promise<void> } } }
90+
__TAURI__?: {
91+
window?: {
92+
getCurrentWindow?: () => {
93+
startDragging?: () => Promise<void>
94+
toggleMaximize?: () => Promise<void>
95+
}
96+
}
97+
}
9198
}
9299
).__TAURI__
93100
if (!tauri?.window?.getCurrentWindow) return
@@ -133,10 +140,23 @@ export function Titlebar() {
133140
void win.startDragging().catch(() => undefined)
134141
}
135142

143+
const maximize = (e: MouseEvent) => {
144+
if (platform.platform !== "desktop") return
145+
if (interactive(e.target)) return
146+
if (e.target instanceof Element && e.target.closest("[data-tauri-decorum-tb]")) return
147+
148+
const win = getWin()
149+
if (!win?.toggleMaximize) return
150+
151+
e.preventDefault()
152+
void win.toggleMaximize().catch(() => undefined)
153+
}
154+
136155
return (
137156
<header
138157
class="h-10 shrink-0 bg-background-base relative grid grid-cols-[auto_minmax(0,1fr)_auto] items-center"
139158
style={{ "min-height": minHeight() }}
159+
onDblClick={maximize}
140160
>
141161
<div
142162
classList={{

0 commit comments

Comments
 (0)