about summary refs log tree commit diff stats
path: root/run.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-07-10 16:08:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-07-10 16:08:18 -0700
commitb42f08cb791dcd1c2dc1c6dc442d375a89976e75 (patch)
treebe1af828ee42337c3000eab4d78325b5ff59d879 /run.lua
parente68261d7a346d45eab4c0d606b5c5010823badd7 (diff)
downloadlines.love-b42f08cb791dcd1c2dc1c6dc442d375a89976e75.tar.gz
bugfix: preserve window position
I just noticed we hadn't got this bugfix for Linux on the main app. How
had we not noticed this issue before? Answer: lines.love windows tend to
be tall and skinny, and resize must keep the window entirely within the
screen. So the window was staying in place just because it happened to
be running up against the bottom.
Diffstat (limited to 'run.lua')
-rw-r--r--run.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/run.lua b/run.lua
index f0482e0..378279c 100644
--- a/run.lua
+++ b/run.lua
@@ -63,13 +63,23 @@ function run.load_settings()
   App.screen.flags.minheight = math.min(App.screen.height, 200)
   App.screen.width, App.screen.height = Settings.width, Settings.height
   App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
-  App.screen.move(Settings.x, Settings.y, Settings.displayindex)
+  run.set_window_position_from_settings(Settings)
   Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right, Settings.font_height, math.floor(Settings.font_height*1.3))
   Editor_state.filename = Settings.filename
   Editor_state.screen_top1 = Settings.screen_top
   Editor_state.cursor1 = Settings.cursor
 end
 
+function run.set_window_position_from_settings(settings)
+  local os = love.system.getOS()
+  if os == 'Linux' then
+    -- love.window.setPosition doesn't quite seem to do what is asked of it on Linux.
+    App.screen.move(settings.x, settings.y-37, settings.displayindex)
+  else
+    App.screen.move(settings.x, settings.y, settings.displayindex)
+  end
+end
+
 function run.initialize_default_settings()
   local font_height = 20
   love.graphics.setFont(love.graphics.newFont(font_height))