fix(windows): one clean 12 px radius on the popover, with nothing square behind it

The card was drawn rounded but three square things sat behind it: the
acrylic backdrop, which the window effect paints edge to edge and which
DWM's corner preference does not clip; the DWM frame line; and the DWM
drop shadow, whose inner edge is the window rectangle, so it met itself
at a right angle exactly where the card curved away. The result was a
rounded card with square corners showing through, worst at the top left
and along the bottom.

The window now paints nothing at all. The acrylic effect is gone (at 94
percent surface opacity it was contributing a tint, not a blur, and the
surface is simply opaque now), DWM is told not to round and not to draw a
border, and the OS shadow is off. In its place the window is 12 px larger
than the card on every side and the page paints its own drop shadow into
that gutter, so the shadow follows the card radius. The gutter doubles as
the inset the card kept from the work-area edge, so the card lands where
it always did.

Verified at 10x on all four corners in both themes: one antialiased arc,
the desktop behind it, and the shadow curving with it.
This commit is contained in:
iamtoruk 2026-09-01 18:15:59 -07:00
parent 209248f0e7
commit 053ff8c6ce
3 changed files with 47 additions and 28 deletions

View file

@ -88,7 +88,7 @@ pub fn run() {
if let Some(window) = app.get_webview_window(POPOVER_LABEL) {
let _ = window.hide();
#[cfg(target_os = "windows")]
round_window_corners(&window);
strip_window_frame(&window);
}
if dock::is_enabled() {
@ -377,16 +377,22 @@ fn warn_if_window_station_hidden() {
}
}
/// Undecorated windows are square by default; ask DWM for the Windows 11 rounded corner so
/// the acrylic backdrop is clipped to the same shape as the popover card. Silently ignored
/// on Windows 10, where the corners stay square.
/// The popover window paints nothing of its own: it is transparent, and the rounded card
/// inside it is the whole visible shape. So DWM has to keep its hands off the frame. Its
/// own rounding clips at the system radius rather than the card radius, and the 1 px
/// frame it draws around a rounded window traces that wrong shape in grey just outside
/// the card.
#[cfg(target_os = "windows")]
fn round_window_corners(window: &tauri::WebviewWindow) {
fn strip_window_frame(window: &tauri::WebviewWindow) {
use windows_sys::Win32::Graphics::Dwm::{
DwmSetWindowAttribute, DWMWA_WINDOW_CORNER_PREFERENCE, DWMWCP_ROUND,
DwmSetWindowAttribute, DWMWA_BORDER_COLOR, DWMWA_WINDOW_CORNER_PREFERENCE,
DWMWCP_DONOTROUND,
};
/// DWMWA_COLOR_NONE: suppress the border rather than tint it.
const COLOR_NONE: u32 = 0xFFFF_FFFE;
let Ok(hwnd) = window.hwnd() else { return };
let preference: u32 = DWMWCP_ROUND as u32;
let preference: u32 = DWMWCP_DONOTROUND as u32;
// Both are no-ops before Windows 11 build 22000, where the frame is square anyway.
unsafe {
DwmSetWindowAttribute(
hwnd.0 as _,
@ -394,6 +400,12 @@ fn round_window_corners(window: &tauri::WebviewWindow) {
&preference as *const u32 as *const std::ffi::c_void,
std::mem::size_of::<u32>() as u32,
);
DwmSetWindowAttribute(
hwnd.0 as _,
DWMWA_BORDER_COLOR as u32,
&COLOR_NONE as *const u32 as *const std::ffi::c_void,
std::mem::size_of::<u32>() as u32,
);
}
}
@ -553,12 +565,18 @@ fn show_popover(app: &AppHandle, anchor: Option<(i32, i32)>) {
/// Places the popover against the taskbar / panel edge of the monitor that owns the click
/// (or the cursor, when the request came from a menu). The work area already excludes the
/// taskbar on Windows and panels on Linux, so we never need to guess their heights: the
/// popover sits `MARGIN` inside the work area, horizontally centred on the anchor and
/// card sits `GUTTER` inside the work area, horizontally centred on the anchor and
/// clamped to the screen.
fn position_popover(window: &tauri::WebviewWindow, anchor: Option<(i32, i32)>) {
const POPOVER_WIDTH_LOGICAL: f64 = 360.0;
const POPOVER_HEIGHT_LOGICAL: f64 = 660.0;
const MARGIN_LOGICAL: f64 = 8.0;
const CARD_WIDTH_LOGICAL: f64 = 360.0;
const CARD_HEIGHT_LOGICAL: f64 = 660.0;
/// Transparent margin the page paints the card shadow into, and the gap the card
/// keeps from the work-area edge. One value for both: the shadow needs the room and
/// the card needs the inset, so the window edge is exactly where the inset ends.
const GUTTER_LOGICAL: f64 = 12.0;
const POPOVER_WIDTH_LOGICAL: f64 = CARD_WIDTH_LOGICAL + 2.0 * GUTTER_LOGICAL;
const POPOVER_HEIGHT_LOGICAL: f64 = CARD_HEIGHT_LOGICAL + 2.0 * GUTTER_LOGICAL;
const MARGIN_LOGICAL: f64 = 0.0;
let point = anchor
.filter(|(x, y)| *x > 0 || *y > 0)

View file

@ -14,8 +14,8 @@
{
"label": "popover",
"title": "CodeBurn",
"width": 360,
"height": 660,
"width": 384,
"height": 684,
"decorations": false,
"transparent": true,
"resizable": false,
@ -23,11 +23,7 @@
"skipTaskbar": true,
"visible": false,
"focus": false,
"shadow": true,
"windowEffects": {
"effects": ["acrylic"],
"state": "active"
}
"shadow": false
}
],
"security": {

View file

@ -8,9 +8,10 @@
--ember-deep: #8B3E13;
--ember-glow: #F0A070;
/* Light: warm popover material over the desktop. */
--surface: rgba(250, 247, 243, 0.94);
--surface-solid: #FAF7F3;
/* The popover card. Opaque, because the window behind it is fully transparent: the
card is the only thing that paints, so its border-radius is the only shape there is
and nothing square can bleed at the corners. */
--surface: #FAF7F3;
--surface-window: #FFFFFF;
--label: rgba(0, 0, 0, 0.85);
--label-2: rgba(0, 0, 0, 0.50);
@ -61,7 +62,9 @@
--font-mono: 'Cascadia Mono', 'Cascadia Code', Consolas, 'SF Mono', Menlo, monospace;
--gutter: 14px;
--popover-radius: 10px;
--popover-radius: 12px;
--popover-gutter: 12px;
--popover-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.12);
--radius-bar: 2px;
--radius-util: 3px;
--radius-segment: 5px;
@ -75,8 +78,7 @@
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--surface: rgba(28, 24, 22, 0.92);
--surface-solid: #1C1816;
--surface: #1C1816;
--surface-window: #2A2320;
--label: rgba(255, 255, 255, 0.86);
--label-2: rgba(255, 255, 255, 0.55);
@ -117,8 +119,7 @@
}
:root[data-theme="dark"] {
--surface: rgba(28, 24, 22, 0.92);
--surface-solid: #1C1816;
--surface: #1C1816;
--surface-window: #2A2320;
--label: rgba(255, 255, 255, 0.86);
--label-2: rgba(255, 255, 255, 0.55);
@ -194,14 +195,18 @@ code { font-family: var(--font-mono); }
/* ---- shell ---------------------------------------------------------------------- */
/* The window is 12 px larger than the card on every side and paints nothing itself, so
this drop shadow follows the card radius instead of the square window frame. That is
why the window has no DWM shadow and no DWM rounding: both trace a rectangle. */
.popover {
display: flex;
flex-direction: column;
height: 100vh;
margin: var(--popover-gutter);
height: calc(100% - 2 * var(--popover-gutter));
overflow: hidden;
border-radius: var(--popover-radius);
background: var(--surface);
box-shadow: inset 0 0 0 0.5px var(--separator);
box-shadow: var(--popover-shadow), inset 0 0 0 0.5px var(--separator);
}
.header {