Skip to content

Commit 982c2c9

Browse files
committed
fix(electron): remove center:true + ozone flag, use explicit position
Flickering on Hyprland is caused by Electron's center:true option which triggers a window reposition after the window is already mapped. Hyprland animates this reposition, creating a visible flicker as the window slides from its initial position to the center. Fix: calculate the center position upfront (using screen.workAreaSize) and pass x/y explicitly to BrowserWindow. The window opens at the correct position immediately, with no post-creation reposition. Also removes the unnecessary ozone-platform-hint flag that was a leftover from earlier experiments.
1 parent 00b3122 commit 982c2c9

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

apps/desktop-electron/src/main.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ipcMain,
55
shell,
66
dialog,
7+
screen,
78
} from "electron";
89
import * as path from "node:path";
910
import * as http from "node:http";
@@ -18,10 +19,6 @@ import {
1819
const isDev = process.argv.includes("--dev");
1920
const gotTheLock = app.requestSingleInstanceLock();
2021

21-
if (process.platform === "linux") {
22-
app.commandLine.appendSwitch("ozone-platform-hint", "auto");
23-
}
24-
2522
let mainWindow: BrowserWindow | null = null;
2623
let pendingAuthCallback: {
2724
success: boolean;
@@ -105,12 +102,18 @@ async function startStaticServer(): Promise<number> {
105102
}
106103

107104
function createWindow(url: string): BrowserWindow {
105+
const primary = screen.getPrimaryDisplay();
106+
const { width: sw, height: sh } = primary.workAreaSize;
107+
const ww = 1200;
108+
const wh = 800;
109+
108110
const win = new BrowserWindow({
109-
width: 1200,
110-
height: 800,
111+
x: Math.round((sw - ww) / 2),
112+
y: Math.round((sh - wh) / 2),
113+
width: ww,
114+
height: wh,
111115
minWidth: 800,
112116
minHeight: 500,
113-
center: true,
114117
show: false,
115118
backgroundColor: "#0a0a0a",
116119
frame: true,
@@ -122,7 +125,6 @@ function createWindow(url: string): BrowserWindow {
122125
sandbox: true,
123126
allowRunningInsecureContent: false,
124127
experimentalFeatures: false,
125-
offscreen: false,
126128
},
127129
});
128130

0 commit comments

Comments
 (0)