feat(macos): adapt frontend for native title bar

- Add macOS platform detection (html.macos class)
- Prevent pinch-to-zoom gestures in WKWebView
- Hide custom title bar on macOS (uses native overlay title bar)
- Add 32px top padding to sidebar for traffic light buttons
- Add drag region for window movement
This commit is contained in:
Afonso Jorge Ramos committed 2026-03-20 00:45:16 +01:00
1 parent caffd7b56c
commit 00147dc7fb
4 files changed
+39

No files matched your search

+16
View File
@@ -22,6 +22,22 @@
/* Hide custom title bar before Svelte hydrates when setting is active */
html[data-no-titlebar] .titlebar { display: none !important; }
</style>
<script>
// Detect macOS for platform-specific CSS and behavior
if (/Mac/.test(navigator.platform)) {
document.documentElement.classList.add('macos');
}
// Prevent macOS trackpad pinch-to-zoom and Cmd+scroll zoom in WKWebView.
// This is a desktop app, not a web page — accidental zoom breaks the UI.
if (/Mac/.test(navigator.platform)) {
document.addEventListener('gesturestart', function(e) { e.preventDefault(); });
document.addEventListener('gesturechange', function(e) { e.preventDefault(); });
document.addEventListener('gestureend', function(e) { e.preventDefault(); });
document.addEventListener('wheel', function(e) {
if (e.ctrlKey) e.preventDefault();
}, { passive: false });
}
</script>
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
+5
View File
@@ -2090,6 +2090,11 @@
height: calc(100vh - 104px); /* Only 104px NowPlayingBar, no title bar */
}
/* macOS: pad top of sidebar to clear native traffic light buttons */
:global(html.macos) .sidebar.no-titlebar {
padding-top: 32px;
}
.content {
flex: 1;
overflow: hidden;
+3
View File
@@ -87,6 +87,8 @@ export function getUseSystemTitleBar(): boolean {
* Hidden when either system title bar is active or hide mode is on
*/
export function shouldShowTitleBar(): boolean {
// macOS always uses native decorations — no custom title bar
if (document.documentElement.classList.contains('macos')) return false;
return !hideTitleBar && !useSystemTitleBar;
}
@@ -95,6 +97,7 @@ export function shouldShowTitleBar(): boolean {
* Returns 0 if title bar is hidden or system title bar is active, 40 otherwise
*/
export function getTitleBarHeight(): number {
if (document.documentElement.classList.contains('macos')) return 0;
return (hideTitleBar || useSystemTitleBar) ? 0 : 40;
}
+15
View File
@@ -4759,6 +4759,10 @@
<LoginView onLoginSuccess={handleLoginSuccess} onStartOffline={handleStartOffline} />
{:else}
<div class="app" class:no-titlebar={!showTitleBar} class:floating={isWindowFloating}>
<!-- macOS: drag region for window movement (overlay title bar has no native drag area) -->
{#if !showTitleBar}
<div class="macos-drag-region" data-tauri-drag-region></div>
{/if}
<!-- Custom Title Bar (CSD) -->
{#if showTitleBar}
<TitleBar
@@ -5885,6 +5889,17 @@
height: calc(100vh - 104px); /* Only 104px NowPlayingBar, no title bar */
}
/* macOS: invisible drag region for window movement (overlay title bar) */
:global(html.macos) .macos-drag-region {
height: 28px;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 9999;
-webkit-app-region: drag;
}
.view-error {
display: flex;
flex-direction: column;