You are browsing as a guest. Sign up (or log in) to start making projects!

2h 20m 41s logged

Devlog 3 - Window Manager Upgrade


Came back to the window manager because it was bugging me. Windows could be dragged anywhere including straight off the edge of the screen with no way to get them back short of refreshing. No resizing at all. No snapping. All the stuff that makes an OS feel like an OS instead of a box you can shove around. So this was the sprint where I tried to fix that and it took way longer than I thought, mostly because of bugs I caused myself.


First up was resize handles, eight invisible strips around each window’s edges and corners so you can grab any side and resize from there. First try did nothing. Not an error, just nothing. Turned out my windows have overflow: hidden for the rounded corners and I’d put the handles slightly outside the window’s box so the browser was just clipping them out of existence along with their mouse events. Moved them inside the edge instead and they worked.


Then, while retyping some of it by hand, I wrote .querySelectorAll(".resize-handle".forEach(...)) instead of .querySelectorAll(".resize-handle").forEach(...). One parenthesis in the wrong spot and I was calling .forEach on a plain string instead of on the actual list of elements. Broke resizing AND window-opening at the same time since the error happened before the window even got added to the page.


Bounds clamping was a smaller fix but it’s the one I’m most relieved about. Windows can hang halfway off an edge now but they physically can’t disappear off-screen anymore, there’s always a grabbable strip of titlebar left no matter how far you drag. And then snapping, the one I was most excited for. Drag a window to the left or right edge and a ghost preview shows up where it’ll land, let go and it snaps into half the screen. Drag to the top and it maximizes. I almost skipped the detail where dragging a snapped window away from the edge pops it back to its old size first instead of just dragging the half-screen shape around looking weird but glad I didn’t, that’s the part that actually sells it.


Then dragging itself went completely haywire right after snapping started working, windows flying way faster than my mouse was moving, snapping in the wrong spots, clamping not holding. Assumed snapping broke it. It hadn’t. Found a line where I was adding the drag delta twice, once to calculate the clamped position and then again by accident when actually setting it.


Double-clicking a titlebar now maximizes/restores too, it felt wrong not having that once snapping existed. Window manager finally feels solid instead of held together with tape. Small wins matter! even the ones that take an embarrassingly long time to find.

0
13

Comments 0

No comments yet. Be the first!