Skip to content

Windows/Linux: keep Mochi whole after a monitor change - #892

Merged
Louis-CFM merged 1 commit into
Louis-CFM:mainfrom
ZouaouiB:fix/mochi-monitor-scale
Oct 23, 2026
Merged

Louis-CFM merged 1 commit into
Louis-CFM:mainfrom
ZouaouiB:fix/mochi-monitor-scale

Conversation

@ZouaouiB

@ZouaouiB ZouaouiB commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Moving the island (or the desktop Mochi) to a monitor with a different scale could leave Mochi drawn too big and cut off, until something made him change size.

Mochi cut off after a monitor change

How to reproduce: two monitors at different scales (say 100 % and 150 %), Island lives on: the screen under the cursor, move the cursor to the other monitor with the island open. Mochi comes out too big and cut (or too small going the other way); it heals only when he changes size (compact ↔ expanded).

Cause

  • The canvas bitmaps were sized once for the pixel ratio the window started with, but every frame was drawn at the current ratio. drawBot only resized the bitmap when Mochi's size changed, never when the ratio did.
  • The (resolution: Ndppx) media query in main.ts was created once for the first ratio: after one change it never fired again, so the zoom correction missed every later monitor change.

Changes

  • island.ts: Mochi's canvas resizes when the ratio changes, not only his size; the greeting canvas too.
  • desktop/main.ts, mochi/minibots.ts, views/wardrobe.ts: the desktop Mochi, the mini Mochis and the wardrobe icons follow the ratio the same way (the upload canvas, the pill and the Coucou window already did).
  • main.ts: the ratio watcher re-arms itself after every change, and wakes the island's frame loop so Mochi is redrawn at once even while idle (the loop stops when nothing moves). screen-changed wakes it too.

Validation

  • npm test: 466 passed. tsc --noEmit, vite build: passed. git diff --check: passed.
  • In the browser, with the device scale emulated at 1.25 → 2 → 1 → 1.5 → 1.75, Mochi's bitmap followed every ratio (101 → 162 → 81 → 122 → 142 px for an 81 px CSS box); before the change it stayed at 101 px.
  • The bug was seen on a two-monitor Windows 11 setup; the fix has not been re-checked by hand across the real monitors yet. Linux was not tried.

Emulated scale changes don't fire media-query change events in Chromium, so the watcher re-arming itself is covered by reading, not by that test; screen-changed waking the loop is the second path for the same redraw. #899 (island screen hop) wraps the same screen-changed handler: whichever lands second needs a one-line merge.

The canvas bitmaps were sized once for the pixel ratio of the monitor the
window started on, but drawn at the current one: moved to a monitor with
another scale, Mochi came out too big and cut (or too small). The island's
Mochi, the greeting, the mini Mochis, the desktop Mochi and the wardrobe
icons now resize their bitmap when the ratio changes.

The resolution media query was made once, for the first ratio: after one
change it never fired again, so the zoom correction missed the next
monitor. It now re-arms itself after every change, and wakes the island's
frame loop so Mochi is redrawn at once, even while idle.
@ZouaouiB

Copy link
Copy Markdown
Contributor Author

Hi Louis 👋 — this is the first of eight pull requests from the Windows work in my fork. Each one is a single topic, built on today's main (0.5.3) and tested on its own, so you can take any of them without the others:

Fixes and robustness

New feature

Look and feel — these change how existing views behave, which CLAUDE.md leaves to you, so they are proposals:

Two pairs touch the same lines (#892/#899, #894/#895): whichever lands second needs a trivial rebase, and I'll do it. I'd be glad if you'd consider them for Coucou, and happy to change anything you'd like done differently. Thanks for Coucou and Mochi!

@afpruivo

Copy link
Copy Markdown
Contributor

Tested on real hardware: Windows 11 Pro 26H2, RTX 3090, two monitors at different scales: a 3840×2160 at 150 % (main) and a 1440×2560 portrait at 100 % next to it. Debug build of 852df6f on top of current main; npm test: 466 passed.

  • Desktop Mochi (Ctrl+Alt+D), dragged back and forth between the two monitors: stays whole and the right size both ways ✅
  • Island, Island lives on: the screen under the cursor, moving between monitors with the island open: Mochi stays the right size, no cut-off, both ways ✅
  • Mini Mochis and wardrobe icons: sharp on both monitors ✅

So the "not re-checked by hand across the real monitors" part is covered now 🙂

This also fixes the same bug as my #809 (desktop Mochi cut off after a scale change, #344), and covers more (island Mochi, minis, wardrobe, the media query that only fired once). @Louis-CFM if you take this one, I'm happy to close #809 in its favour.

@Louis-CFM
Louis-CFM merged commit a8815f4 into Louis-CFM:main Oct 23, 2026
Louis-CFM pushed a commit that referenced this pull request Oct 23, 2026
umarjavaid4335 added a commit to umarjavaid4335/coucou that referenced this pull request Oct 24, 2026
…tatuses

Brings in keeping Mochi whole after a monitor change (Louis-CFM#892). The WhatsApp
fix (Louis-CFM#901) was written for the update's own WhatsApp, which this branch
leaves out; the same check is ported to this branch's WhatsApp instead:
Status updates, broadcast lists and channels no longer become chats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants