diff --git a/src/base/components/titlebar.html b/src/base/components/titlebar.html
deleted file mode 100644
index 485b5af..0000000
--- a/src/base/components/titlebar.html
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/base/index.html b/src/base/index.html
index d58926a..ada2164 100644
--- a/src/base/index.html
+++ b/src/base/index.html
@@ -18,10 +18,6 @@
id="include-controls"
src="./components/controls.html"
>
-
{
- mainWindow.webContents.executeJavaScript(
- `document.querySelector(".linux-titlebar").style.display = 'block'`,
- );
- }, 1500);
- }
-
- if (process.platform === "win32") {
- setTimeout(() => {
- mainWindow.webContents.executeJavaScript(
- `document.querySelector(".titlebar").style.right = '145px'`,
- );
- }, 1500);
- }
}
diff --git a/src/process/tsconfig.json b/src/process/tsconfig.json
index 9e98b30..1e47e66 100644
--- a/src/process/tsconfig.json
+++ b/src/process/tsconfig.json
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
- "include": ["**/*", "../types"]
+ "include": ["**/*", "../tools", "../types"]
}
diff --git a/src/process/window.js b/src/process/window.js
index 340cf84..344eb46 100644
--- a/src/process/window.js
+++ b/src/process/window.js
@@ -4,6 +4,21 @@ import path from "path";
import { setAppMenu, getTabMenu } from "./menu.js";
import { applyDirectStyling } from "./platform.js";
+import { deepFreeze } from "../tools/object.js";
+
+const TITLEBAR_OVERLAY = deepFreeze({
+ BASE: {
+ height: 42,
+ },
+ DARK: {
+ color: "#18181a",
+ symbolColor: "#ffffff",
+ },
+ LIGHT: {
+ color: "#ffffff",
+ symbolColor: "#000000",
+ },
+});
/** @type {import("electron").BrowserWindow} */
let mainWindow;
@@ -34,12 +49,7 @@ export const MainWindow = {
// Titlebar
titleBarStyle: "hidden",
trafficLightPosition: { x: 16, y: 12 }, // for macOS
- titleBarOverlay: {
- // For Windows
- color: "#1f1f1f",
- symbolColor: "white",
- height: 40,
- },
+ titleBarOverlay: TITLEBAR_OVERLAY.BASE,
// Other Options
autoHideMenuBar: true,
frame: false,
@@ -81,6 +91,13 @@ export const MainWindow = {
});
ipcMain.on("set-theme", (_event, themeId) => {
nativeTheme.themeSource = themeId;
+
+ mainWindow.setTitleBarOverlay?.({
+ ...TITLEBAR_OVERLAY.BASE,
+ ...(nativeTheme.shouldUseDarkColors
+ ? TITLEBAR_OVERLAY.DARK
+ : TITLEBAR_OVERLAY.LIGHT),
+ });
});
if (process.platform === "darwin") {
diff --git a/src/tools/object.js b/src/tools/object.js
new file mode 100644
index 0000000..58f3df2
--- /dev/null
+++ b/src/tools/object.js
@@ -0,0 +1,23 @@
+/**
+ * Deep freeze an object.
+ *
+ * @template {object} T
+ *
+ * @param {T} obj
+ *
+ * @returns {Readonly}
+ */
+export function deepFreeze(obj) {
+ const isObject = typeof obj === "object";
+ const isNull = obj === null;
+ const isFrozen = Object.isFrozen(obj);
+
+ if (isObject && !isNull && !isFrozen) {
+ for (const key of Object.getOwnPropertyNames(obj)) {
+ deepFreeze(obj[/** @type {keyof T}*/ (key)]);
+ }
+ Object.freeze(obj);
+ }
+
+ return obj;
+}