experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

nicer app switcher behavior, the pref forces on, and default is off, which shows app in switcher only when there are persistent visible windows

+62 -25
+14
DEVELOPMENT.md
··· 119 119 120 120 See `notes/escape-navigation.md` for full design details. 121 121 122 + ## Dock / App Switcher Visibility (macOS) 123 + 124 + The dock icon visibility is dynamic based on window state and user preference: 125 + 126 + - **Windows visible**: Dock icon shown (regardless of preference) 127 + - **No windows visible**: Dock icon hidden (unless preference enabled) 128 + 129 + The `showInDockAndSwitcher` preference controls whether to *always* show the dock icon, even when no windows are open. When disabled (default), the dock icon only appears while Peek windows are visible. 130 + 131 + This is implemented via: 132 + - `getVisibleWindowCount()` - counts non-background visible windows 133 + - `updateDockVisibility()` - shows/hides dock based on window count + pref 134 + - Called from: window-open, window-show, maybeHideApp, prefs change 135 + 122 136 ## App Icon Generation 123 137 124 138 The macOS app icon is generated from a source PNG using ImageMagick. The process applies rounded corners and adds padding to match macOS icon guidelines.
+2 -2
app/config.js
··· 40 40 "default": true 41 41 }, 42 42 "showInDockAndSwitcher": { 43 - "description": "Whether to hide or show app in OS dock and app switcher", 43 + "description": "Always show in dock/app switcher, even when no windows are open. When disabled, dock icon only appears while windows are visible.", 44 44 "type": "boolean", 45 45 "default": false 46 46 }, ··· 117 117 width: 800, 118 118 startupFeature: 'peek://app/settings/settings.html', 119 119 showTrayIcon: true, 120 - showInTrayAndSwitcher: false 120 + showInDockAndSwitcher: false 121 121 }, 122 122 items: [ 123 123 { id: 'cee1225d-40ac-41e5-a34c-e2edba69d599',
+2
app/settings/settings.js
··· 104 104 const save = () => { 105 105 store.set(storageKeys.PREFS, prefs); 106 106 store.set(storageKeys.ITEMS, features); 107 + // Notify main process of prefs change for live updates (quit shortcut, dock visibility, etc.) 108 + api.publish('topic:core:prefs', { id, prefs }, api.scopes.SYSTEM); 107 109 }; 108 110 109 111 // Preferences
+44 -23
index.js
··· 473 473 console.log('onReady'); 474 474 475 475 // Hide dock early to prevent flash in app switcher 476 - // Will be shown later if showInDockAndSwitcher pref is true 477 - if (app.dock && !DEBUG) { 478 - console.log('hiding dock early (non-debug mode)'); 476 + // Will be shown/hidden properly once prefs are loaded 477 + if (app.dock) { 479 478 app.dock.hide(); 480 479 } 481 480 ··· 568 567 // cache all prefs 569 568 _prefs = msg.prefs; 570 569 571 - // show/hide in dock and tab switcher based on preference 572 - if (app.dock) { 573 - if (msg.prefs.showInDockAndSwitcher === true) { 574 - console.log('showing dock (pref enabled)'); 575 - app.dock.show(); 576 - } else { 577 - console.log('hiding dock (pref disabled)'); 578 - app.dock.hide(); 579 - } 580 - } 570 + // Update dock visibility based on pref and visible windows 571 + updateDockVisibility(); 581 572 582 573 // initialize system tray 583 574 if (msg.prefs.showTrayIcon == true) { ··· 951 942 }); 952 943 } 953 944 945 + // Show dock when window opens 946 + updateDockVisibility(); 947 + 954 948 return { success: true, id: win.id }; 955 949 } catch (error) { 956 950 console.error('Failed to open window:', error); ··· 1031 1025 } 1032 1026 1033 1027 win.show(); 1028 + updateDockVisibility(); 1034 1029 return { success: true }; 1035 1030 } catch (error) { 1036 1031 console.error('Failed to show window:', error); ··· 1951 1946 } 1952 1947 }; 1953 1948 1954 - // Only hide the app if there are no other visible windows (besides the one being closed/hidden) 1955 - const maybeHideApp = (excludeId) => { 1956 - if (process.platform !== 'darwin') return; 1957 - 1958 - // Check if there are any other visible windows 1959 - const visibleWindows = BrowserWindow.getAllWindows().filter(win => { 1960 - if (win.id === excludeId) return false; 1949 + /** 1950 + * Get count of visible user windows (excluding background window) 1951 + */ 1952 + const getVisibleWindowCount = (excludeId = null) => { 1953 + return BrowserWindow.getAllWindows().filter(win => { 1954 + if (excludeId && win.id === excludeId) return false; 1961 1955 if (win.isDestroyed()) return false; 1962 1956 if (!win.isVisible()) return false; 1963 1957 ··· 1966 1960 if (entry && entry.params.address === webCoreAddress) return false; 1967 1961 1968 1962 return true; 1969 - }); 1963 + }).length; 1964 + }; 1970 1965 1971 - console.log('maybeHideApp: visible windows (excluding', excludeId + '):', visibleWindows.length); 1966 + /** 1967 + * Update dock visibility based on visible windows and pref 1968 + * Show dock if: visible windows exist OR pref is enabled 1969 + * Hide dock if: no visible windows AND pref is disabled 1970 + */ 1971 + const updateDockVisibility = (excludeId = null) => { 1972 + if (process.platform !== 'darwin' || !app.dock) return; 1972 1973 1973 - if (visibleWindows.length === 0) { 1974 + const visibleCount = getVisibleWindowCount(excludeId); 1975 + const prefShowDock = _prefs?.showInDockAndSwitcher === true; 1976 + 1977 + if (visibleCount > 0 || prefShowDock) { 1978 + app.dock.show(); 1979 + } else { 1980 + app.dock.hide(); 1981 + } 1982 + }; 1983 + 1984 + // Only hide the app if there are no other visible windows (besides the one being closed/hidden) 1985 + const maybeHideApp = (excludeId) => { 1986 + if (process.platform !== 'darwin') return; 1987 + 1988 + const visibleCount = getVisibleWindowCount(excludeId); 1989 + console.log('maybeHideApp: visible windows (excluding', excludeId + '):', visibleCount); 1990 + 1991 + if (visibleCount === 0) { 1974 1992 console.log('No other visible windows, hiding app'); 1975 1993 app.hide(); 1976 1994 } else { 1977 1995 console.log('Other windows visible, not hiding app'); 1978 1996 } 1997 + 1998 + // Also update dock visibility 1999 + updateDockVisibility(excludeId); 1979 2000 }; 1980 2001 1981 2002 const closeOrHideWindow = id => {