Skip to content

Commit 23e3883

Browse files
Use native dark theme titlebar on Windows
1 parent b574ba5 commit 23e3883

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+150
-963
lines changed

.storybook/preview.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React from 'react';
77

88
import 'sanitize.css';
99
import '../stylesheets/manifest.scss';
10-
import '../node_modules/@indutny/frameless-titlebar/dist/styles.css';
1110

1211
import * as styles from './styles.scss';
1312
import messages from '../_locales/en/messages.json';
@@ -97,7 +96,6 @@ window.SignalContext = {
9796
waitForChange: () => new Promise(noop),
9897
},
9998
OS: {
100-
hasCustomTitleBar: () => false,
10199
getClassName: () => '',
102100
platform: '',
103101
release: '',

ACKNOWLEDGMENTS.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,6 @@ Signal Desktop makes use of the following open source projects.
1313

1414
License: MIT
1515

16-
## @indutny/frameless-titlebar
17-
18-
MIT License
19-
20-
Copyright (c) 2019 Cristian Ponce
21-
22-
Permission is hereby granted, free of charge, to any person obtaining a copy
23-
of this software and associated documentation files (the "Software"), to deal
24-
in the Software without restriction, including without limitation the rights
25-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26-
copies of the Software, and to permit persons to whom the Software is
27-
furnished to do so, subject to the following conditions:
28-
29-
The above copyright notice and this permission notice shall be included in all
30-
copies or substantial portions of the Software.
31-
32-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38-
SOFTWARE.
39-
4016
## @indutny/sneequals
4117

4218
Copyright Fedor Indutny, 2022.

about.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
rel="stylesheet"
2121
type="text/css"
2222
/>
23-
<link
24-
href="node_modules/@indutny/frameless-titlebar/dist/styles.css"
25-
rel="stylesheet"
26-
type="text/css"
27-
/>
2823
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
2924
</head>
3025
<body>

app/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ if (getEnvironment() === Environment.Production) {
3535
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '';
3636
process.env.SIGNAL_ENABLE_HTTP = '';
3737
process.env.SIGNAL_CI_CONFIG = '';
38-
process.env.CUSTOM_TITLEBAR = '';
3938
}
4039

4140
// We load config after we've made our modifications to NODE_ENV

app/main.ts

Lines changed: 7 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
} from 'electron';
3232
import type {
3333
MenuItemConstructorOptions,
34-
TitleBarOverlayOptions,
3534
LoginItemSettingsOptions,
3635
} from 'electron';
3736
import { z } from 'zod';
@@ -95,7 +94,6 @@ import { MainSQL } from '../ts/sql/main';
9594
import * as sqlChannels from './sql_channel';
9695
import * as windowState from './window_state';
9796
import type { CreateTemplateOptionsType } from './menu';
98-
import type { MenuActionType } from '../ts/types/menu';
9997
import { createTemplate } from './menu';
10098
import { installFileHandler, installWebHandler } from './protocol_filter';
10199
import OS from '../ts/util/os/osMain';
@@ -541,10 +539,7 @@ async function handleUrl(rawTarget: string) {
541539
}
542540
}
543541

544-
async function handleCommonWindowEvents(
545-
window: BrowserWindow,
546-
titleBarOverlay: TitleBarOverlayOptions | false = false
547-
) {
542+
async function handleCommonWindowEvents(window: BrowserWindow) {
548543
window.webContents.on('will-navigate', (event, rawTarget) => {
549544
event.preventDefault();
550545

@@ -578,23 +573,6 @@ async function handleCommonWindowEvents(
578573
await zoomFactorService.syncWindow(window);
579574

580575
nativeThemeNotifier.addWindow(window);
581-
582-
if (titleBarOverlay) {
583-
const onThemeChange = async () => {
584-
try {
585-
const newOverlay = await getTitleBarOverlay();
586-
if (!newOverlay) {
587-
return;
588-
}
589-
window.setTitleBarOverlay(newOverlay);
590-
} catch (error) {
591-
console.error('onThemeChange error', error);
592-
}
593-
};
594-
595-
nativeTheme.on('updated', onThemeChange);
596-
settingsChannel?.on('change:themeSetting', onThemeChange);
597-
}
598576
}
599577

600578
const DEFAULT_WIDTH = ciMode ? 1024 : 800;
@@ -654,45 +632,11 @@ if (OS.isWindows()) {
654632
// - Windows < 10 (7, 8)
655633
// - macOS (but no custom titlebar is displayed, see
656634
// `--title-bar-drag-area-height` in `stylesheets/_titlebar.scss`
657-
const mainTitleBarStyle =
658-
(OS.isMacOS() || OS.hasCustomTitleBar()) &&
659-
!isTestEnvironment(getEnvironment())
660-
? ('hidden' as const)
661-
: ('default' as const);
662-
663-
const nonMainTitleBarStyle = OS.hasCustomTitleBar()
635+
const mainTitleBarStyle = OS.isMacOS()
664636
? ('hidden' as const)
665637
: ('default' as const);
666638

667-
async function getTitleBarOverlay(): Promise<TitleBarOverlayOptions | false> {
668-
if (!OS.hasCustomTitleBar()) {
669-
return false;
670-
}
671-
672-
const theme = await getResolvedThemeSetting();
673-
674-
let color: string;
675-
let symbolColor: string;
676-
if (theme === 'light') {
677-
color = '#e8e8e8';
678-
symbolColor = '#1b1b1b';
679-
} else if (theme === 'dark') {
680-
// $color-gray-80
681-
color = '#2e2e2e';
682-
// $color-gray-05
683-
symbolColor = '#e9e9e9';
684-
} else {
685-
throw missingCaseError(theme);
686-
}
687-
688-
return {
689-
color,
690-
symbolColor,
691-
692-
// Should match `--titlebar-height` in stylesheets/_titlebar.scss
693-
height: 28 - 1,
694-
};
695-
}
639+
const nonMainTitleBarStyle = 'default' as const;
696640

697641
async function safeLoadURL(window: BrowserWindow, url: string): Promise<void> {
698642
let wasDestroyed = false;
@@ -731,8 +675,6 @@ async function createWindow() {
731675
const usePreloadBundle =
732676
!isTestEnvironment(getEnvironment()) || forcePreloadBundle;
733677

734-
const titleBarOverlay = await getTitleBarOverlay();
735-
736678
const windowOptions: Electron.BrowserWindowConstructorOptions = {
737679
show: false,
738680
width: DEFAULT_WIDTH,
@@ -741,7 +683,6 @@ async function createWindow() {
741683
minHeight: MIN_HEIGHT,
742684
autoHideMenuBar: false,
743685
titleBarStyle: mainTitleBarStyle,
744-
titleBarOverlay,
745686
backgroundColor: isTestEnvironment(getEnvironment())
746687
? '#ffffff' // Tests should always be rendered on a white background
747688
: await getBackgroundColor(),
@@ -887,7 +828,7 @@ async function createWindow() {
887828
mainWindow.webContents.openDevTools();
888829
}
889830

890-
await handleCommonWindowEvents(mainWindow, titleBarOverlay);
831+
await handleCommonWindowEvents(mainWindow);
891832

892833
// App dock icon bounce
893834
bounce.init(mainWindow);
@@ -1288,15 +1229,12 @@ async function showAbout() {
12881229
return;
12891230
}
12901231

1291-
const titleBarOverlay = await getTitleBarOverlay();
1292-
12931232
const options = {
12941233
width: 500,
12951234
height: 500,
12961235
resizable: false,
12971236
title: getResolvedMessagesLocale().i18n('icu:aboutSignalDesktop'),
12981237
titleBarStyle: nonMainTitleBarStyle,
1299-
titleBarOverlay,
13001238
autoHideMenuBar: true,
13011239
backgroundColor: await getBackgroundColor(),
13021240
show: false,
@@ -1313,7 +1251,7 @@ async function showAbout() {
13131251

13141252
aboutWindow = new BrowserWindow(options);
13151253

1316-
await handleCommonWindowEvents(aboutWindow, titleBarOverlay);
1254+
await handleCommonWindowEvents(aboutWindow);
13171255

13181256
aboutWindow.on('closed', () => {
13191257
aboutWindow = undefined;
@@ -1338,16 +1276,13 @@ async function showSettingsWindow() {
13381276
return;
13391277
}
13401278

1341-
const titleBarOverlay = await getTitleBarOverlay();
1342-
13431279
const options = {
13441280
width: 700,
13451281
height: 700,
13461282
frame: true,
13471283
resizable: false,
13481284
title: getResolvedMessagesLocale().i18n('icu:signalDesktopPreferences'),
13491285
titleBarStyle: mainTitleBarStyle,
1350-
titleBarOverlay,
13511286
autoHideMenuBar: true,
13521287
backgroundColor: await getBackgroundColor(),
13531288
show: false,
@@ -1364,7 +1299,7 @@ async function showSettingsWindow() {
13641299

13651300
settingsWindow = new BrowserWindow(options);
13661301

1367-
await handleCommonWindowEvents(settingsWindow, titleBarOverlay);
1302+
await handleCommonWindowEvents(settingsWindow);
13681303

13691304
settingsWindow.on('closed', () => {
13701305
settingsWindow = undefined;
@@ -1434,15 +1369,12 @@ async function showDebugLogWindow() {
14341369
}
14351370
}
14361371

1437-
const titleBarOverlay = await getTitleBarOverlay();
1438-
14391372
const options: Electron.BrowserWindowConstructorOptions = {
14401373
width: 700,
14411374
height: 500,
14421375
resizable: false,
14431376
title: getResolvedMessagesLocale().i18n('icu:debugLog'),
14441377
titleBarStyle: nonMainTitleBarStyle,
1445-
titleBarOverlay,
14461378
autoHideMenuBar: true,
14471379
backgroundColor: await getBackgroundColor(),
14481380
show: false,
@@ -1459,7 +1391,7 @@ async function showDebugLogWindow() {
14591391

14601392
debugLogWindow = new BrowserWindow(options);
14611393

1462-
await handleCommonWindowEvents(debugLogWindow, titleBarOverlay);
1394+
await handleCommonWindowEvents(debugLogWindow);
14631395

14641396
debugLogWindow.on('closed', () => {
14651397
debugLogWindow = undefined;
@@ -2504,12 +2436,6 @@ ipc.on('locale-display-names', event => {
25042436
event.returnValue = getResolvedMessagesLocale().localeDisplayNames;
25052437
});
25062438

2507-
// TODO DESKTOP-5241
2508-
ipc.on('OS.getHasCustomTitleBar', event => {
2509-
// eslint-disable-next-line no-param-reassign
2510-
event.returnValue = OS.hasCustomTitleBar();
2511-
});
2512-
25132439
// TODO DESKTOP-5241
25142440
ipc.on('OS.getClassName', event => {
25152441
// eslint-disable-next-line no-param-reassign
@@ -2836,46 +2762,6 @@ async function zoomReset() {
28362762
await zoomFactorService.zoomReset();
28372763
}
28382764

2839-
ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => {
2840-
if (action === 'forceUpdate') {
2841-
drop(forceUpdate());
2842-
} else if (action === 'openArtCreator') {
2843-
drop(openArtCreator());
2844-
} else if (action === 'openContactUs') {
2845-
openContactUs();
2846-
} else if (action === 'openForums') {
2847-
openForums();
2848-
} else if (action === 'openJoinTheBeta') {
2849-
openJoinTheBeta();
2850-
} else if (action === 'openReleaseNotes') {
2851-
openReleaseNotes();
2852-
} else if (action === 'openSupportPage') {
2853-
openSupportPage();
2854-
} else if (action === 'setupAsNewDevice') {
2855-
setupAsNewDevice();
2856-
} else if (action === 'setupAsStandalone') {
2857-
setupAsStandalone();
2858-
} else if (action === 'showAbout') {
2859-
drop(showAbout());
2860-
} else if (action === 'showDebugLog') {
2861-
drop(showDebugLogWindow());
2862-
} else if (action === 'showKeyboardShortcuts') {
2863-
showKeyboardShortcuts();
2864-
} else if (action === 'showSettings') {
2865-
drop(showSettingsWindow());
2866-
} else if (action === 'showWindow') {
2867-
showWindow();
2868-
} else if (action === 'zoomIn') {
2869-
drop(zoomIn());
2870-
} else if (action === 'zoomOut') {
2871-
drop(zoomOut());
2872-
} else if (action === 'zoomReset') {
2873-
drop(zoomReset());
2874-
} else {
2875-
throw missingCaseError(action);
2876-
}
2877-
});
2878-
28792765
ipc.handle(
28802766
'net.resolveHost',
28812767
(_event, hostname: string, queryType?: 'A' | 'AAAA') => {

background.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@
8888
rel="stylesheet"
8989
type="text/css"
9090
/>
91-
<link
92-
href="node_modules/@indutny/frameless-titlebar/dist/styles.css"
93-
rel="stylesheet"
94-
type="text/css"
95-
/>
9691
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
9792
</head>
9893
<body class="overflow-hidden">

debug_log.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
rel="stylesheet"
2121
type="text/css"
2222
/>
23-
<link
24-
href="node_modules/@indutny/frameless-titlebar/dist/styles.css"
25-
rel="stylesheet"
26-
type="text/css"
27-
/>
2823
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
2924
</head>
3025
<body>

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"dependencies": {
8989
"@formatjs/fast-memoize": "1.2.6",
9090
"@formatjs/intl-localematcher": "0.2.32",
91-
"@indutny/frameless-titlebar": "2.3.5",
9291
"@indutny/sneequals": "4.0.0",
9392
"@nodert-win10-rs4/windows.data.xml.dom": "0.4.4",
9493
"@nodert-win10-rs4/windows.ui.notifications": "0.4.4",

settings.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
rel="stylesheet"
2121
type="text/css"
2222
/>
23-
<link
24-
href="node_modules/@indutny/frameless-titlebar/dist/styles.css"
25-
rel="stylesheet"
26-
type="text/css"
27-
/>
2823
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
2924
</head>
3025
<body>

stylesheets/_mixins.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ $rtl-icon-map: (
784784
@mixin install-screen {
785785
align-items: center;
786786
display: flex;
787-
width: var(--window-width);
788-
height: var(--window-height);
787+
width: 100vw;
788+
height: 100vh;
789789
justify-content: center;
790790
line-height: 30px;
791791
user-select: none;

0 commit comments

Comments
 (0)