Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(desktop): add quick CSS window, wire engine and title IPC

Hampus7d6e3f77bd97
diff --git a/fluxer_desktop/src/common/Types.ts b/fluxer_desktop/src/common/Types.ts
index 90c09c404..3d69b9415 100644
--- a/fluxer_desktop/src/common/Types.ts
+++ b/fluxer_desktop/src/common/Types.ts
@@ -55,6 +55,7 @@ export type * from '@fluxer/desktop_ipc/src/DesktopBridgeTypes';
import type {BuildChannel} from '@electron/common/BuildChannel';
import type {DesktopAccountStorageAPI} from '@fluxer/desktop_ipc/src/AccountContract';
+import type {AccountEngineRendererAPI} from '@fluxer/desktop_ipc/src/AccountEngineContract';
import type {DesktopHandoffAPI} from '@fluxer/desktop_ipc/src/BrowserHandoffContract';
import type {DesktopCapabilityManifest} from '@fluxer/desktop_ipc/src/CapabilityManifest';
import type {NativeGatewayTransportAPI} from '@fluxer/desktop_ipc/src/GatewayTransportContract';
@@ -172,7 +173,7 @@ export interface VirtmicAvailability {
backend?: VirtmicBackend;
}
-export interface VirtmicApi {
+interface VirtmicApi {
getAvailability: () => Promise<VirtmicAvailability>;
listTargets: (options?: {granular?: boolean}) => Promise<{
ok: boolean;
@@ -182,7 +183,7 @@ export interface VirtmicApi {
stop: () => Promise<void>;
}
-export interface NativeAudioApi {
+interface NativeAudioApi {
getAvailability: () => Promise<NativeAudioAvailability>;
listAudibleApplications: () => Promise<Array<NativeAudioApplication>>;
resolveAudioRootPidForSource: (sourceId: string) => Promise<number | null>;
@@ -195,7 +196,7 @@ export interface NativeAudioApi {
onEnd: (callback: (message: NativeAudioEndMessage) => void) => () => void;
}
-export interface NativeScreenCaptureApi {
+interface NativeScreenCaptureApi {
onLifecycleEvent: (callback: (message: NativeScreenCaptureLifecycleMessage) => void) => () => void;
}
@@ -212,6 +213,7 @@ export interface NotificationOptions {
body: string;
icon?: string;
url?: string;
+ accountKey?: string;
}
export interface NotificationResult {
@@ -234,6 +236,13 @@ export type TrayActionPayload =
}
| {
action: 'check-for-updates';
+ }
+ | {
+ action: 'switch-account';
+ accountKey: string;
+ }
+ | {
+ action: 'open-account-switcher';
};
export interface ElectronAPI {
@@ -272,10 +281,10 @@ export interface ElectronAPI {
windowMaximize: () => void;
windowClose: () => void;
windowIsMaximized: () => Promise<boolean>;
- focusThemeStudioPopout: () => Promise<boolean>;
popoutSetAlwaysOnTop: (key: string, flag: boolean) => Promise<boolean>;
popoutFocus: (key: string) => Promise<boolean>;
+ cssEditorWindow: true;
openVoiceDebugEventSinkPopout: (entries: Array<DesktopVoiceDebugEventSinkEntry>) => Promise<void>;
appendVoiceDebugEventSinkEntries: (entries: Array<DesktopVoiceDebugEventSinkEntry>) => void;
setVoiceDebugEventSinkStatsHtml: (html: string) => void;
@@ -307,7 +316,7 @@ export interface ElectronAPI {
getStreamerModeCaptureAppStatus: () => Promise<StreamerModeCaptureAppStatus>;
closeNotification: (id: string) => void;
closeNotifications: (ids: Array<string>) => void;
- onNotificationClick: (callback: (id: string, url?: string) => void) => () => void;
+ onNotificationClick: (callback: (id: string, url: string | null, accountKey: string | null) => void) => () => void;
setBadgeCount: (count: number) => void;
setUnreadBadge: (badge: number) => void;
setNativeLocale: (locale: string, strings: Record<string, string>) => void;
@@ -319,12 +328,14 @@ export interface ElectronAPI {
getAccessibilitySupportEnabled: () => Promise<boolean>;
onAccessibilitySupportChanged: (callback: (enabled: boolean) => void) => () => void;
getLinuxAppearance: () => Promise<LinuxAppearanceSnapshot>;
+ setPrebootTheme: (theme: string) => void;
onLinuxAppearanceChanged: (callback: (snapshot: LinuxAppearanceSnapshot) => void) => () => void;
onZoomIn: (callback: () => void) => () => void;
onZoomOut: (callback: () => void) => () => void;
onZoomReset: (callback: () => void) => () => void;
onOpenSettings: (callback: () => void) => () => void;
setTrayRuntimeState: (state: Partial<TrayRuntimeStatePayload>) => void;
+ setDirectMessagesAvailable: (available: boolean) => void;
acquireStreamingPriority: () => void;
releaseStreamingPriority: () => void;
getStreamingPriorityDiagnostics: () => Promise<StreamingPriorityDiagnostics>;
@@ -386,12 +397,14 @@ export interface ElectronAPI {
desktopModules: DesktopModuleAPI;
desktopUpdate: DesktopUpdateAPI;
reportLastRoute: (routePath: string) => void;
+ reportInstanceProductName: (instanceKey: string, productName: string) => void;
notifyFirstContentPainted: () => void;
desktopAccounts: DesktopAccountStorageAPI;
desktopStorage: DesktopStorageAPI;
desktopKnownInstances: DesktopKnownInstanceStorageAPI;
desktopHandoff: DesktopHandoffAPI;
nativeGatewayTransport: NativeGatewayTransportAPI;
+ accountEngine: AccountEngineRendererAPI;
otherPlatformTemplate: OtherPlatformTemplateAPI;
}
@@ -410,7 +423,7 @@ export type LinuxSessionType = 'wayland' | 'x11' | 'unknown';
export type LinuxDesktopKind = 'kde' | 'gnome' | 'hyprland' | 'other';
-export interface GlobalShortcutsLinuxStatus {
+interface GlobalShortcutsLinuxStatus {
session: LinuxSessionType;
sandbox: 'flatpak' | 'none';
desktop: LinuxDesktopKind;
@@ -428,7 +441,7 @@ export interface GlobalShortcutsStatus {
supportsModifierOnly: boolean;
}
-export interface GlobalShortcutsApi {
+interface GlobalShortcutsApi {
sync: (payload: GlobalShortcutsSyncPayload) => Promise<void>;
setPaused: (paused: boolean) => Promise<void>;
getStatus: () => Promise<GlobalShortcutsStatus>;
diff --git a/fluxer_desktop/src/main/IpcHandlers.ts b/fluxer_desktop/src/main/IpcHandlers.ts
index 189c8a6d8..964bf1738 100644
--- a/fluxer_desktop/src/main/IpcHandlers.ts
+++ b/fluxer_desktop/src/main/IpcHandlers.ts
@@ -1,4 +1,3 @@
-import {isObjectLike as isRecord} from '@fluxer/record_utils/src/RecordGuards';
// SPDX-License-Identifier: AGPL-3.0-or-later
import {APP_PROTOCOL, DESKTOP_APP_ORIGIN, DESKTOP_PREBOOT_THEME_CHANNEL} from '@electron/common/Constants';
@@ -6,6 +5,7 @@ import {
type DesktopTroubleshootingSettings,
type DesktopWindowBehaviorSettings,
getDesktopWindowBehaviorSettings,
+ rememberInstanceProductName,
setDesktopWindowBehaviorSettings,
setPrebootTheme,
} from '@electron/common/DesktopConfig';
@@ -33,6 +33,7 @@ import {getDesktopUpdateState, observeDesktopUpdateState, startDesktopUpdate} fr
import {DownloadChecksumError, downloadFile} from '@electron/main/FileDownloads';
import {getGatewayOriginRegistry} from '@electron/main/GatewayOriginRegistry';
import {retryBlockedGlobalShortcutHooks} from '@electron/main/GlobalShortcutsIpc';
+import {setDirectMessagesAvailable} from '@electron/main/JumpList';
import {
type LinuxAppearanceSnapshot,
type LinuxAppearanceSubscription,
@@ -87,22 +88,25 @@ import {
clearSavedWindowBounds,
desktopTransparencyPendingRestart,
desktopUseNativeTitleBarPendingRestart,
- focusThemeStudioPopoutWindow,
+ focusQuickCssEditorWindow,
focusVoicePopoutWindow,
getActiveAllowTransparency,
getActiveUseNativeTitleBar,
getMainWindow,
- setThemeStudioPopoutAlwaysOnTop,
+ QUICK_CSS_EDITOR_WINDOW_KEY,
+ setQuickCssEditorAlwaysOnTop,
setVoicePopoutAlwaysOnTop,
showWindow,
- THEME_STUDIO_POPOUT_KEY,
} from '@electron/main/Window';
import {refreshWindowsBadgeOverlay, setWindowsBadgeOverlay} from '@electron/main/WindowsBadge';
+import {DESKTOP_DIRECT_MESSAGES_AVAILABLE_CHANNEL} from '@fluxer/desktop_ipc/src/DirectMessagesContract';
+import {DESKTOP_INSTANCE_PRODUCT_NAME_CHANNEL} from '@fluxer/desktop_ipc/src/InstanceProductNameContract';
import {
DESKTOP_MODULE_CHANNELS,
DESKTOP_UPDATE_CHANNELS,
DESKTOP_UPDATE_EVENTS,
} from '@fluxer/desktop_ipc/src/ModuleContract';
+import {isObjectLike as isRecord} from '@fluxer/record_utils/src/RecordGuards';
import {app, BrowserWindow, clipboard, dialog, ipcMain, powerMonitor, shell, systemPreferences} from 'electron';
import log from 'electron-log';
@@ -266,6 +270,10 @@ export function registerIpcHandlers(): void {
const update = state as TrayRuntimeStateUpdate;
updateTrayRuntimeState(update, event.sender.id);
});
+ ipcMain.on(DESKTOP_DIRECT_MESSAGES_AVAILABLE_CHANNEL, (event, available: unknown) => {
+ if (typeof available !== 'boolean' || !isPrivilegedRendererDocumentSender(event)) return;
+ setDirectMessagesAvailable(available);
+ });
ipcMain.on('native-locale-set', (_event, payload: unknown) => {
if (!payload || typeof payload !== 'object') return;
const {locale, strings} = payload as {
@@ -306,6 +314,11 @@ export function registerIpcHandlers(): void {
setPrebootTheme(theme);
}
});
+ ipcMain.on(DESKTOP_INSTANCE_PRODUCT_NAME_CHANNEL, (event, report: unknown) => {
+ if (event.senderFrame?.origin === DESKTOP_APP_ORIGIN) {
+ rememberInstanceProductName(report);
+ }
+ });
ipcMain.handle('desktop-window-behavior-pending-restart', (): boolean => {
return (
desktopTrayChangePendingRestart() ||
@@ -364,16 +377,13 @@ export function registerIpcHandlers(): void {
ipcMain.handle('window-is-maximized', (event): boolean => {
return BrowserWindow.fromWebContents(event.sender)?.isMaximized() ?? false;
});
- ipcMain.handle('theme-studio-popout-focus', (): boolean => {
- return focusThemeStudioPopoutWindow();
- });
ipcMain.handle('popout:set-always-on-top', (_event, key: unknown, flag: unknown): boolean => {
if (typeof key !== 'string' || typeof flag !== 'boolean') {
return false;
}
- if (key === THEME_STUDIO_POPOUT_KEY) {
- return setThemeStudioPopoutAlwaysOnTop(flag);
+ if (key === QUICK_CSS_EDITOR_WINDOW_KEY) {
+ return setQuickCssEditorAlwaysOnTop(flag);
}
if (key === VOICE_DEBUG_EVENT_SINK_POPOUT_KEY) {
return setVoiceDebugEventSinkAlwaysOnTop(flag);
@@ -384,8 +394,8 @@ export function registerIpcHandlers(): void {
if (typeof key !== 'string') {
return false;
}
- if (key === THEME_STUDIO_POPOUT_KEY) {
- return focusThemeStudioPopoutWindow();
+ if (key === QUICK_CSS_EDITOR_WINDOW_KEY) {
+ return focusQuickCssEditorWindow();
}
if (key === VOICE_DEBUG_EVENT_SINK_POPOUT_KEY) {
return focusVoiceDebugEventSinkPopout();
diff --git a/fluxer_desktop/src/main/Window.ts b/fluxer_desktop/src/main/Window.ts
index a689e16b6..726a84ef7 100644
--- a/fluxer_desktop/src/main/Window.ts
+++ b/fluxer_desktop/src/main/Window.ts
@@ -9,9 +9,10 @@ import {
MIN_WINDOW_HEIGHT,
MIN_WINDOW_WIDTH,
} from '@electron/common/Constants';
-import {getDesktopWindowBehaviorSettings, getPrebootTheme} from '@electron/common/DesktopConfig';
+import {getDesktopWindowBehaviorSettings, getLaunchProductName, getPrebootTheme} from '@electron/common/DesktopConfig';
import {createChildLogger} from '@electron/common/Logger';
import type {DesktopWindowBehaviorSettings} from '@electron/common/Types';
+import {isAccountEngineAvailable} from '@electron/main/AccountEngineHost';
import {createAppLoadRetry} from '@electron/main/AppLoadRetry';
import {
shouldForwardRendererConsoleToMainLog,
@@ -37,6 +38,7 @@ import {registerSpellcheck} from '@electron/main/Spellcheck';
import {resetStreamingPriority} from '@electron/main/StreamingPriority';
import {getMainWindowRendererGoneAction} from '@electron/main/WindowRendererLifecycle';
import {refreshWindowsBadgeOverlay} from '@electron/main/WindowsBadge';
+import {ACCOUNT_ENGINE_AVAILABLE_RENDERER_ARG} from '@fluxer/desktop_ipc/src/AccountEngineContract';
import {NATIVE_GATEWAY_TRANSPORT_AVAILABLE_RENDERER_ARG} from '@fluxer/desktop_ipc/src/GatewayTransportContract';
import {app, BrowserWindow, dialog, ipcMain, screen} from 'electron';
import log from 'electron-log';
@@ -62,12 +64,10 @@ const TRANSPARENT_WINDOW_BACKGROUND_COLOR = '#00000000';
const MEDIA_DEVICE_BLINK_FEATURES = 'EnumerateDevices,AudioOutputDevices';
const ACTIVE_ALLOW_TRANSPARENCY_RENDERER_ARG = '--fluxer-active-allow-transparency=1';
const ACTIVE_USE_NATIVE_TITLEBAR_RENDERER_ARG = '--fluxer-active-use-native-titlebar=1';
-const THEME_STUDIO_POPOUT_WINDOW_NAME = 'fluxer_theme_studio';
-const THEME_STUDIO_POPOUT_PATHNAME = '/theme-studio';
-const THEME_STUDIO_POPOUT_TITLE = 'Fluxer | Theme Studio';
-const THEME_STUDIO_POPOUT_MIN_WIDTH = 900;
-const THEME_STUDIO_POPOUT_MIN_HEIGHT = 620;
-export const THEME_STUDIO_POPOUT_KEY = THEME_STUDIO_POPOUT_WINDOW_NAME;
+export const QUICK_CSS_EDITOR_WINDOW_KEY = 'fluxer_quick_css_editor';
+const QUICK_CSS_EDITOR_WINDOW_TITLE = 'Fluxer | Quick CSS';
+const QUICK_CSS_EDITOR_MIN_WIDTH = 900;
+const QUICK_CSS_EDITOR_MIN_HEIGHT = 620;
const VOICE_POPOUT_WINDOW_NAME_PREFIX = 'fluxer-voice-popout:';
const VOICE_POPOUT_WINDOW_NAME_LENGTH_MAX = 256;
const VOICE_POPOUT_MIN_WIDTH = 360;
@@ -90,21 +90,11 @@ const trustedRendererPermissionTypes = new Set([
'speaker-selection',
'clipboard-sanitized-write',
]);
-const POPOUT_NAMESPACE = 'fluxer_';
export function isTrustedOrigin(url?: string): boolean {
return isLocalAppRendererDocumentURL(url ?? null);
}
-function getSanitizedPath(rawUrl: string): string | null {
- try {
- return new URL(rawUrl).pathname;
- } catch (error) {
- log.warn('Invalid URL for path check', {rawUrl, error});
- return null;
- }
-}
-
function preventUntrustedNavigation(event: Electron.Event, url: string, isMainFrame: boolean): void {
if (isLocalAppURL(url) && !isLocalAppRendererDocumentURL(url)) {
logger.warn('Blocked a navigation to a reserved local app path', {url, isMainFrame});
@@ -154,7 +144,7 @@ let windowStateFile: string;
let isQuitting = false;
let initialUseNativeTitleBar: boolean | null = null;
let initialAllowTransparency: boolean | null = null;
-let themeStudioPopoutWindow: BrowserWindow | null = null;
+let quickCssEditorWindow: BrowserWindow | null = null;
let lastRestorableMainWindowMaximized = false;
let mainWindowRendererGone = false;
let closingMainWindowForUpdate = false;
@@ -373,23 +363,14 @@ function recoverMainWindowRendererBeforeShow(reason: string): void {
}
export function isAppDocumentWindowContents(contents: Electron.WebContents): boolean {
- return [mainWindow, themeStudioPopoutWindow].some(
- (window) => isAliveWindow(window) && window.webContents === contents,
- );
+ return isAliveWindow(mainWindow) && mainWindow.webContents === contents;
}
-function getThemeStudioPopoutWindow(): BrowserWindow | null {
- if (isAliveWindow(themeStudioPopoutWindow)) {
- return themeStudioPopoutWindow;
- }
- themeStudioPopoutWindow = null;
- for (const window of BrowserWindow.getAllWindows()) {
- if (window === mainWindow || window.isDestroyed()) continue;
- if (getSanitizedPath(window.webContents.getURL()) === THEME_STUDIO_POPOUT_PATHNAME) {
- trackThemeStudioPopoutWindow(window);
- return window;
- }
+function getQuickCssEditorWindow(): BrowserWindow | null {
+ if (isAliveWindow(quickCssEditorWindow)) {
+ return quickCssEditorWindow;
}
+ quickCssEditorWindow = null;
return null;
}
@@ -408,8 +389,8 @@ export function focusWindow(window: BrowserWindow): void {
window.focus();
}
-export function focusThemeStudioPopoutWindow(): boolean {
- const window = getThemeStudioPopoutWindow();
+export function focusQuickCssEditorWindow(): boolean {
+ const window = getQuickCssEditorWindow();
if (!window) {
return false;
}
@@ -471,8 +452,8 @@ export function setVoicePopoutAlwaysOnTop(key: string, flag: boolean): boolean {
return true;
}
-export function setThemeStudioPopoutAlwaysOnTop(flag: boolean): boolean {
- const window = getThemeStudioPopoutWindow();
+export function setQuickCssEditorAlwaysOnTop(flag: boolean): boolean {
+ const window = getQuickCssEditorWindow();
if (!window) {
return false;
}
@@ -501,6 +482,11 @@ function getWindowBackgroundColor(allowTransparency: boolean): string {
return THEME_WINDOW_BACKGROUND_COLORS[getPrebootTheme() ?? ''] ?? DEFAULT_WINDOW_BACKGROUND_COLOR;
}
+function getLaunchTitleWindowOptions(): Pick<Electron.BrowserWindowConstructorOptions, 'title'> {
+ const title = getLaunchProductName();
+ return title === null ? {} : {title};
+}
+
function getWindowShadowOptions(
allowTransparency: boolean,
): Pick<Electron.BrowserWindowConstructorOptions, 'hasShadow'> {
@@ -568,6 +554,7 @@ function getRendererAdditionalArguments(
if (allowTransparency) args.push(ACTIVE_ALLOW_TRANSPARENCY_RENDERER_ARG);
if (useNativeTitleBar) args.push(ACTIVE_USE_NATIVE_TITLEBAR_RENDERER_ARG);
if (allowNativeGateway && isNativeGatewayAvailable()) args.push(NATIVE_GATEWAY_TRANSPORT_AVAILABLE_RENDERER_ARG);
+ if (allowNativeGateway && isAccountEngineAvailable()) args.push(ACCOUNT_ENGINE_AVAILABLE_RENDERER_ARG);
return args;
}
@@ -600,15 +587,18 @@ function forwardMaximizeChanges(window: BrowserWindow): void {
});
}
-function trackThemeStudioPopoutWindow(window: BrowserWindow): void {
- themeStudioPopoutWindow = window;
+function trackQuickCssEditorWindow(window: BrowserWindow): void {
+ const existing = getQuickCssEditorWindow();
+ if (existing && existing !== window) {
+ existing.close();
+ }
+ quickCssEditorWindow = window;
window.setAlwaysOnTop(true);
- window.setTitle(THEME_STUDIO_POPOUT_TITLE);
- window.setMinimumSize(THEME_STUDIO_POPOUT_MIN_WIDTH, THEME_STUDIO_POPOUT_MIN_HEIGHT);
+ window.setTitle(QUICK_CSS_EDITOR_WINDOW_TITLE);
forwardMaximizeChanges(window);
window.once('closed', () => {
- if (themeStudioPopoutWindow === window) {
- themeStudioPopoutWindow = null;
+ if (quickCssEditorWindow === window) {
+ quickCssEditorWindow = null;
}
});
}
@@ -639,13 +629,13 @@ function getLinuxWindowIconPath(): string | null {
return null;
}
-function getVoicePopoutWindowOptions(): Electron.BrowserWindowConstructorOptions {
+function getPopoutWindowOptions(minWidth: number, minHeight: number): Electron.BrowserWindowConstructorOptions {
const isMac = process.platform === 'darwin';
const isLinux = process.platform === 'linux';
const options: Electron.BrowserWindowConstructorOptions = {
...getTitleBarWindowOptions(getActiveUseNativeTitleBar()),
- minWidth: VOICE_POPOUT_MIN_WIDTH,
- minHeight: VOICE_POPOUT_MIN_HEIGHT,
+ minWidth,
+ minHeight,
...(isMac ? {trafficLightPosition: CUSTOM_TITLEBAR_TRAFFIC_LIGHT_POSITION} : {}),
backgroundColor: getWindowBackgroundColor(false),
transparent: false,
@@ -721,6 +711,7 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
minWidth: MIN_WINDOW_WIDTH,
minHeight: MIN_WINDOW_HEIGHT,
show: false,
+ ...getLaunchTitleWindowOptions(),
backgroundColor: getWindowBackgroundColor(allowTransparency),
transparent: allowTransparency,
...getWindowShadowOptions(allowTransparency),
@@ -1075,11 +1066,8 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
preventUntrustedNavigation(event, event.url, event.isMainFrame);
});
webContents.on('did-create-window', (window, details) => {
- if (
- details.frameName === THEME_STUDIO_POPOUT_WINDOW_NAME &&
- getSanitizedPath(details.url) === THEME_STUDIO_POPOUT_PATHNAME
- ) {
- trackThemeStudioPopoutWindow(window);
+ if (details.frameName === QUICK_CSS_EDITOR_WINDOW_KEY) {
+ trackQuickCssEditorWindow(window);
}
if (isVoicePopoutWindowName(details.frameName)) {
trackVoicePopoutWindow(details.frameName, window);
@@ -1092,31 +1080,19 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
logger.warn('Denied voice popout window: capacity reached', {frameName});
return {action: 'deny'};
}
- return {action: 'allow', overrideBrowserWindowOptions: getVoicePopoutWindowOptions()};
+ return {
+ action: 'allow',
+ overrideBrowserWindowOptions: getPopoutWindowOptions(VOICE_POPOUT_MIN_WIDTH, VOICE_POPOUT_MIN_HEIGHT),
+ };
}
- const pathname = getSanitizedPath(url);
- if (
- frameName?.startsWith(POPOUT_NAMESPACE) &&
- (pathname === '/popout' || pathname === '/quick-css-editor' || pathname === THEME_STUDIO_POPOUT_PATHNAME) &&
- isTrustedOrigin(url)
- ) {
- const isThemeStudioPopout =
- frameName === THEME_STUDIO_POPOUT_WINDOW_NAME && pathname === THEME_STUDIO_POPOUT_PATHNAME;
- const isOpaqueChromePopout = pathname === '/quick-css-editor' || pathname === THEME_STUDIO_POPOUT_PATHNAME;
- const allowPopoutTransparency = allowTransparency && !isOpaqueChromePopout;
- const overrideBrowserWindowOptions: Electron.BrowserWindowConstructorOptions = {
- ...getTitleBarWindowOptions(getActiveUseNativeTitleBar()),
- title: isThemeStudioPopout ? THEME_STUDIO_POPOUT_TITLE : undefined,
- minWidth: isThemeStudioPopout ? THEME_STUDIO_POPOUT_MIN_WIDTH : undefined,
- minHeight: isThemeStudioPopout ? THEME_STUDIO_POPOUT_MIN_HEIGHT : undefined,
- ...(isMac ? {trafficLightPosition: CUSTOM_TITLEBAR_TRAFFIC_LIGHT_POSITION} : {}),
- backgroundColor: getWindowBackgroundColor(allowPopoutTransparency),
- transparent: allowPopoutTransparency,
- ...getWindowShadowOptions(allowPopoutTransparency),
- show: true,
- webPreferences: getSharedWebPreferences(allowPopoutTransparency, getActiveUseNativeTitleBar()),
+ if (frameName === QUICK_CSS_EDITOR_WINDOW_KEY && url === 'about:blank') {
+ return {
+ action: 'allow',
+ overrideBrowserWindowOptions: {
+ ...getPopoutWindowOptions(QUICK_CSS_EDITOR_MIN_WIDTH, QUICK_CSS_EDITOR_MIN_HEIGHT),
+ title: QUICK_CSS_EDITOR_WINDOW_TITLE,
+ },
};
- return {action: 'allow', overrideBrowserWindowOptions};
}
openExternalDeduped(url).catch((error) => {
log.warn('Failed to open external URL from window-open:', error);
diff --git a/fluxer_desktop/src/preload/index.ts b/fluxer_desktop/src/preload/index.ts
index 17cee0911..01d5d7579 100644
--- a/fluxer_desktop/src/preload/index.ts
+++ b/fluxer_desktop/src/preload/index.ts
@@ -60,6 +60,7 @@ import type {
VirtmicAvailability,
VirtmicNode,
} from '@electron/common/Types';
+import {createAccountEnginePreloadAPI} from '@electron/preload/AccountEnginePreload';
import {createBrowserHandoffPreloadAPI} from '@electron/preload/BrowserHandoffPreload';
import {createDesktopStoragePreloadAPI} from '@electron/preload/DesktopStoragePreload';
import {createFirstContentPaintSignal} from '@electron/preload/FirstContentPaint';
@@ -69,6 +70,11 @@ import {createNativeGatewayPreloadAPI} from '@electron/preload/NativeGatewayPrel
import {createOtherPlatformTemplatePreloadAPI} from '@electron/preload/OtherPlatformTemplatePreload';
import type {DesktopCapabilityManifest} from '@fluxer/desktop_ipc/src/CapabilityManifest';
import {DESKTOP_CAPABILITY_MANIFEST_CHANNEL} from '@fluxer/desktop_ipc/src/CapabilityManifest';
+import {DESKTOP_DIRECT_MESSAGES_AVAILABLE_CHANNEL} from '@fluxer/desktop_ipc/src/DirectMessagesContract';
+import {
+ DESKTOP_INSTANCE_PRODUCT_NAME_CHANNEL,
+ readInstanceProductName,
+} from '@fluxer/desktop_ipc/src/InstanceProductNameContract';
import {DESKTOP_LAST_ROUTE_CHANNEL} from '@fluxer/desktop_ipc/src/LastRouteContract';
import {
buildNativeTitlebarStartupHtml,
@@ -96,7 +102,7 @@ const ACTIVE_USE_NATIVE_TITLEBAR_RENDERER_ARG = '--fluxer-active-use-native-titl
const CUSTOM_TITLEBAR_HEIGHT = '32px';
const NATIVE_TITLEBAR_HEIGHT = '0px';
const STARTUP_NATIVE_TITLEBAR_ID = 'fluxer-startup-native-titlebar';
-const THEME_STUDIO_STANDALONE_PATHNAME = '/theme-studio';
+const SERVED_PRODUCT_NAME_SELECTOR = 'meta[name="apple-mobile-web-app-title"]:not([data-fluxer-branding])';
const DESKTOP_CAPABILITY_MANIFEST_KEYS = Object.freeze(['appStore', 'gatewaySocket'] as const);
class DesktopCapabilityManifestContractError extends TypeError {
@@ -285,12 +291,13 @@ function wireStartupNativeTitlebarControls(titlebar: HTMLElement): void {
});
}
+function readServedProductName(): string | null {
+ const content = document.head?.querySelector<HTMLMetaElement>(SERVED_PRODUCT_NAME_SELECTOR)?.getAttribute('content');
+ return readInstanceProductName(content);
+}
+
function installStartupNativeTitlebar(activeUseNativeTitleBar: boolean): void {
- if (
- activeUseNativeTitleBar ||
- window.location.protocol === 'data:' ||
- window.location.pathname === THEME_STUDIO_STANDALONE_PATHNAME
- ) {
+ if (activeUseNativeTitleBar || window.location.protocol === 'data:') {
return;
}
const layout = startupNativeTitlebarLayout();
@@ -303,7 +310,7 @@ function installStartupNativeTitlebar(activeUseNativeTitleBar: boolean): void {
titlebar.setAttribute('aria-hidden', 'true');
titlebar.setAttribute('data-native-titlebar', '');
titlebar.setAttribute('data-platform', getStartupPlatform());
- titlebar.innerHTML = buildNativeTitlebarStartupHtml(layout);
+ titlebar.innerHTML = buildNativeTitlebarStartupHtml(layout, readServedProductName());
if (layout === 'controls') {
wireStartupNativeTitlebarControls(titlebar);
}
@@ -405,10 +412,14 @@ const api: ElectronAPI = {
...createLocalAppPreloadAPI(ipcRenderer),
...createBrowserHandoffPreloadAPI(ipcRenderer),
...createNativeGatewayPreloadAPI(ipcRenderer),
+ ...createAccountEnginePreloadAPI(ipcRenderer),
...createOtherPlatformTemplatePreloadAPI(ipcRenderer),
reportLastRoute: (routePath: string): void => {
ipcRenderer.send(DESKTOP_LAST_ROUTE_CHANNEL, routePath);
},
+ reportInstanceProductName: (instanceKey: string, productName: string): void => {
+ ipcRenderer.send(DESKTOP_INSTANCE_PRODUCT_NAME_CHANNEL, {instanceKey, productName});
+ },
notifyFirstContentPainted: createFirstContentPaintSignal(ipcRenderer, (callback) =>
window.requestAnimationFrame(callback),
),
@@ -464,11 +475,11 @@ const api: ElectronAPI = {
ipcRenderer.send('window-close');
},
windowIsMaximized: (): Promise<boolean> => ipcRenderer.invoke('window-is-maximized'),
- focusThemeStudioPopout: (): Promise<boolean> => ipcRenderer.invoke('theme-studio-popout-focus'),
popoutSetAlwaysOnTop: (key: string, flag: boolean): Promise<boolean> =>
ipcRenderer.invoke('popout:set-always-on-top', key, flag),
popoutFocus: (key: string): Promise<boolean> => ipcRenderer.invoke('popout:focus', key),
+ cssEditorWindow: true,
openVoiceDebugEventSinkPopout: (entries: Array<DesktopVoiceDebugEventSinkEntry>): Promise<void> =>
ipcRenderer.invoke('voice-debug-event-sink:open', entries),
appendVoiceDebugEventSinkEntries: (entries: Array<DesktopVoiceDebugEventSinkEntry>): void => {
@@ -580,9 +591,12 @@ const api: ElectronAPI = {
closeNotifications: (ids: Array<string>): void => {
ipcRenderer.send('close-notifications', ids);
},
- onNotificationClick: (callback: (id: string, url?: string) => void): (() => void) => {
- const handler = (_event: Electron.IpcRendererEvent, id: string, url?: string): void => {
- callback(id, url);
+ onNotificationClick: (
+ callback: (id: string, url: string | null, accountKey: string | null) => void,
+ ): (() => void) => {
+ const handler = (_event: Electron.IpcRendererEvent, id: unknown, url: unknown, accountKey: unknown): void => {
+ if (typeof id !== 'string') return;
+ callback(id, typeof url === 'string' ? url : null, typeof accountKey === 'string' ? accountKey : null);
};
ipcRenderer.on('notification-click', handler);
return () => {
@@ -622,6 +636,9 @@ const api: ElectronAPI = {
return () => ipcRenderer.removeListener('accessibility-support-changed', handler);
},
getLinuxAppearance: (): Promise<LinuxAppearanceSnapshot> => ipcRenderer.invoke('linux-appearance-get'),
+ setPrebootTheme: (theme: string): void => {
+ ipcRenderer.send(DESKTOP_PREBOOT_THEME_CHANNEL, theme);
+ },
onLinuxAppearanceChanged: (callback: (snapshot: LinuxAppearanceSnapshot) => void): (() => void) => {
const handler = (_event: Electron.IpcRendererEvent, snapshot: LinuxAppearanceSnapshot): void => callback(snapshot);
ipcRenderer.on('linux-appearance-changed', handler);
@@ -650,6 +667,9 @@ const api: ElectronAPI = {
setTrayRuntimeState: (state: Partial<TrayRuntimeStatePayload>): void => {
ipcRenderer.send('tray-runtime-state-update', state);
},
+ setDirectMessagesAvailable: (available: boolean): void => {
+ ipcRenderer.send(DESKTOP_DIRECT_MESSAGES_AVAILABLE_CHANNEL, available);
+ },
acquireStreamingPriority: (): void => {
ipcRenderer.send('streaming-priority-acquire');
},