bugfix: keep Viewport dimensions more up to date

Scenario:
  1. I connect to carousel.love
  2. I try to press C-n, nothing seems to happen
  3. I quit and restart and get this cryptic error:

    SDL error: window too large

      "width": 19103,
      "height": 9849.984375

I can manually edit config to adjust width and height and restart
driver.love.

I don't really understand all the details of how this comes about.

While investigating this, however, I noticed one thing: in step 2 the
new node is indeed being spawned, it's just happening out of viewport
because Viewport dimensions are much larger than the window.

Once I started looking for it, I noticed this stale information in many
apps.

Let's see if keeping viewport dimensions up to date causes the scenario
above to stop occurring.
This commit is contained in:
Kartik K. Agaram 2023-12-17 13:16:08 -08:00
parent f038fa1bcc
commit c3df57ce61
2 changed files with 8 additions and 1 deletions

View File

@ -9,6 +9,9 @@ on.initialize = function()
Settings[App_name].definitions = get_default_map()
end
Viewport = Settings[App_name].viewport
-- We might have resized the window since the last time we connected to this app, so don't trust viewport dimensions
Viewport.w = App.screen.width
Viewport.h = App.screen.height
Definitions = Settings[App_name].definitions
local names = {}
for name, _ in pairs(Definitions) do
@ -40,4 +43,4 @@ on.initialize = function()
else
survey_animation() -- calls A internally
end
end
end

4
0132-on.resize Normal file
View File

@ -0,0 +1,4 @@
on.resize = function(w, h)
Viewport.w = w
Viewort.h = h
end