about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-11-03 21:08:11 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-11-03 21:08:11 -0700
commitfd71bc7d945d991b00369eba716f1313d5806ac3 (patch)
tree1bf4cf9285ed469fd8c13106158de1e4aca00838 /main.lua
parenta68647ae223357455274d163eb927528399df05e (diff)
parent0e0f36f8b4a57bd9a13925c9f7e92f7bd8c59a81 (diff)
downloadtext.love-fd71bc7d945d991b00369eba716f1313d5806ac3.tar.gz
Merge lines.love
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua18
1 files changed, 10 insertions, 8 deletions
diff --git a/main.lua b/main.lua
index 87b867f..e9a7da5 100644
--- a/main.lua
+++ b/main.lua
@@ -79,8 +79,9 @@ function App.initialize_globals()
   end
 
   -- for hysteresis in a few places
-  Last_focus_time = App.getTime()  -- https://love2d.org/forums/viewtopic.php?p=249700
-  Last_resize_time = App.getTime()
+  Current_time = 0
+  Last_focus_time = 0  -- https://love2d.org/forums/viewtopic.php?p=249700
+  Last_resize_time = 0
 end
 
 function App.initialize(arg)
@@ -101,7 +102,7 @@ function App.resize(w,h)
   else
     assert(false, 'unknown app "'..Current_app..'"')
   end
-  Last_resize_time = App.getTime()
+  Last_resize_time = Current_time
 end
 
 function App.filedropped(file)
@@ -116,7 +117,7 @@ end
 
 function App.focus(in_focus)
   if in_focus then
-    Last_focus_time = App.getTime()
+    Last_focus_time = Current_time
   end
   if Current_app == 'run' then
     if run.focus then run.focus(in_focus) end
@@ -138,8 +139,9 @@ function App.draw()
 end
 
 function App.update(dt)
+  Current_time = Current_time + dt
   -- some hysteresis while resizing
-  if App.getTime() < Last_resize_time + 0.1 then
+  if Current_time < Last_resize_time + 0.1 then
     return
   end
   --
@@ -154,7 +156,7 @@ end
 
 function App.keychord_pressed(chord, key)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --
@@ -192,7 +194,7 @@ end
 
 function App.textinput(t)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --
@@ -207,7 +209,7 @@ end
 
 function App.keyreleased(chord, key)
   -- ignore events for some time after window in focus (mostly alt-tab)
-  if App.getTime() < Last_focus_time + 0.01 then
+  if Current_time < Last_focus_time + 0.01 then
     return
   end
   --