experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(page): preserve window size during drag-out-of-maximize

When a drag is initiated from the maximized state, startDrag() restores
the window to the exact preMaximizeWindowBounds width and height (bypassing
computeWindowBounds margin math so headless/test runs match non-headless
byte-for-byte). However, the subsequent mousemove handler for that same
drag was re-calling setWindowBounds(computeWindowBounds(screenBounds)),
which re-added MARGIN*2 on top of screenBounds.width -- causing a ~16px
width growth on every drag-out-of-maximize (visible as 800 then 816 in the
page-layout.spec.ts:672 assertion under headless Playwright, where the
ipc.ts canvas margin adjustment is skipped).

Fix: capture the restored window size in dragOutOfMaximizeWindowSize at
the moment startDrag exits maximize; during the ongoing drag, the
mousemove handler overrides computed width/height with this captured
value so the window only pans (x/y) and does not resize. Cleared on
mouseup.

+26 -2
+26 -2
app/page/page.js
··· 844 844 let dragStartBoundsX = 0; 845 845 let dragStartBoundsY = 0; 846 846 let pageMouseButtonDown = false; 847 + // When a drag was initiated from a maximized state, the window width/height 848 + // were restored to the exact pre-maximize WINDOW bounds (bypassing 849 + // computeWindowBounds margin math). Subsequent mousemove updates during this 850 + // same drag must preserve those exact dimensions — otherwise computeWindowBounds 851 + // re-adds MARGIN*2 and grows the window (visible as a ~16px jump on platforms 852 + // where the canvas margin adjustment is skipped, e.g. headless tests). 853 + let dragOutOfMaximizeWindowSize = null; // { width, height } or null 847 854 848 855 // Hold-to-drag state (configurable, read from prefs at init) 849 856 const JITTER_TOLERANCE = 3; // px of movement allowed during hold without cancelling ··· 893 900 width: savedWindowBounds.width, 894 901 height: savedWindowBounds.height, 895 902 }); 903 + // Remember the exact window size so mousemove updates during this 904 + // drag preserve it (see dragOutOfMaximizeWindowSize declaration). 905 + dragOutOfMaximizeWindowSize = { 906 + width: savedWindowBounds.width, 907 + height: savedWindowBounds.height, 908 + }; 896 909 } else { 897 910 api.window.setBounds(computeWindowBounds(screenBounds)); 911 + dragOutOfMaximizeWindowSize = null; 898 912 } 899 913 } 900 914 isDragging = true; ··· 1297 1311 const dy = e.screenY - dragStartScreenY; 1298 1312 screenBounds.x = dragStartBoundsX + dx; 1299 1313 screenBounds.y = dragStartBoundsY + dy; 1300 - // Move the window — element positions within the window stay the same 1301 - setWindowBounds(computeWindowBounds(screenBounds)); 1314 + // Move the window — element positions within the window stay the same. 1315 + // If this drag started by exiting maximize, preserve the exact window 1316 + // size captured at that moment (computeWindowBounds would otherwise add 1317 + // MARGIN*2 on top, causing a ~16px growth per mousemove). 1318 + const computed = computeWindowBounds(screenBounds); 1319 + if (dragOutOfMaximizeWindowSize) { 1320 + computed.width = dragOutOfMaximizeWindowSize.width; 1321 + computed.height = dragOutOfMaximizeWindowSize.height; 1322 + } 1323 + setWindowBounds(computed); 1302 1324 } 1303 1325 }); 1304 1326 ··· 1310 1332 navbar.style.cursor = 'grab'; 1311 1333 updateUrlParams(); 1312 1334 } 1335 + // Clear the drag-out-of-maximize override once the drag ends. 1336 + dragOutOfMaximizeWindowSize = null; 1313 1337 }); 1314 1338 1315 1339 // --- State display ---