diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2022-10-27 14:30:23 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2022-10-27 22:51:54 +0100 |
| commit | fa58dd85b7ee06fed8d7a5ecc14fda8146f7521b (patch) | |
| tree | 5b96a2e0dfb80ff7c7db2440faa169f6b2786ade /emcc.c | |
| parent | 9783bbfbc01f2faff86daaa53e46bf68848b8b7c (diff) | |
| download | puzzles-fa58dd85b7ee06fed8d7a5ecc14fda8146f7521b.zip puzzles-fa58dd85b7ee06fed8d7a5ecc14fda8146f7521b.tar.gz puzzles-fa58dd85b7ee06fed8d7a5ecc14fda8146f7521b.tar.bz2 puzzles-fa58dd85b7ee06fed8d7a5ecc14fda8146f7521b.tar.xz | |
js: Distinguish manual resizes from device pixel ratio changes
This adds a new callback, rescale_puzzle(), that's called when the
device pixel ratio changes. This means that resize_puzzle() can safely
set the nominal canvas size, which means that manual resizing of the
puzzle now sticks.
Still missing: paying attention to the device pixel ratio when choosing
the initial (or reset) size.
Diffstat (limited to 'emcc.c')
| -rw-r--r-- | emcc.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -195,8 +195,8 @@ static void resize(void) canvas_h = h; } -/* Called from JS when the user uses the resize handle */ -void resize_puzzle(int w, int h) +/* Called from JS when the device pixel ratio changes */ +void rescale_puzzle(int w, int h) { midend_size(me, &w, &h, true); if (canvas_w != w || canvas_h != h) { @@ -207,6 +207,13 @@ void resize_puzzle(int w, int h) } } +/* Called from JS when the user uses the resize handle */ +void resize_puzzle(int w, int h) +{ + rescale_puzzle(w, h); + js_canvas_set_nominal_size(); +} + /* Called from JS when the user uses the restore button */ void restore_puzzle_size(int w, int h) { |