Last active
September 14, 2026 09:14
-
-
Save DeJeune/6f71a14df8cfd9d8cd16438c1a0d9359 to your computer and use it in GitHub Desktop.
Electron Fiddle testcase: framed vs frameless window corners on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | |
| <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"> | |
| <link href="./styles.css" rel="stylesheet"> | |
| <title>Window corners</title> | |
| </head> | |
| <body> | |
| <div id="label"></div> | |
| <!-- You can also require other files to run in this process --> | |
| <script src="./renderer.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Compare the window corners of a framed vs a frameless window on Linux. | |
| // | |
| // On Linux (Wayland), the framed window (frame: true) renders rounded top | |
| // corners and square bottom corners, while the frameless window (frame: false) | |
| // is rounded on all four corners. | |
| const { app, BrowserWindow, screen } = require('electron') | |
| const path = require('node:path') | |
| function createWindow(x, y, width, height, frame) { | |
| const win = new BrowserWindow({ | |
| x, | |
| y, | |
| width, | |
| height, | |
| frame, | |
| webPreferences: { | |
| preload: path.join(__dirname, 'preload.js') | |
| } | |
| }) | |
| win.setTitle('frame: ' + frame) | |
| win.loadFile('index.html', { query: { frame: String(frame) } }) | |
| } | |
| app.whenReady().then(() => { | |
| const { width, height } = screen.getPrimaryDisplay().workAreaSize | |
| const w = Math.floor(width / 2) - 30 | |
| const h = Math.floor(height / 2) - 30 | |
| createWindow(20, 20, w, h, true) | |
| createWindow(w + 40, 20, w, h, false) | |
| app.on('activate', function () { | |
| if (BrowserWindow.getAllWindows().length === 0) createWindow(20, 20, w, h, true) | |
| }) | |
| }) | |
| app.on('window-all-closed', function () { | |
| if (process.platform !== 'darwin') app.quit() | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "framed-window-corners-linux", | |
| "productName": "framed-window-corners-linux", | |
| "description": "Compare the window corners of a framed vs a frameless window on Linux", | |
| "keywords": [], | |
| "main": "./main.js", | |
| "version": "1.0.0", | |
| "author": "DeJeune", | |
| "scripts": { | |
| "start": "electron ." | |
| }, | |
| "dependencies": {}, | |
| "devDependencies": { | |
| "electron": "44.2.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // All of the Node.js APIs are available in the preload process. | |
| // It has the same sandbox as a Chrome extension. | |
| window.addEventListener('DOMContentLoaded', () => { | |
| const replaceText = (selector, text) => { | |
| const element = document.getElementById(selector) | |
| if (element) element.innerText = text | |
| } | |
| for (const type of ['chrome', 'node', 'electron']) { | |
| replaceText(`${type}-version`, process.versions[type]) | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Label each window so the framed and frameless ones are easy to tell apart. | |
| const frame = new URLSearchParams(window.location.search).get('frame') | |
| document.getElementById('label').innerHTML = | |
| 'This window: <b>frame: ' + frame + '</b><br>' + | |
| 'Compare the four corners: <b>top vs bottom</b>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html, | |
| body { | |
| margin: 0; | |
| height: 100%; | |
| -webkit-app-region: drag; | |
| } | |
| body { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| box-sizing: border-box; | |
| background: #181818; | |
| /* A visible border makes the window edges, and therefore the corners, easy to judge. */ | |
| border: 2px solid #7dd3fc; | |
| color: #eee; | |
| font: 14px / 1.6 system-ui, sans-serif; | |
| text-align: center; | |
| } | |
| b { | |
| color: #7dd3fc; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment