diff options
| -rw-r--r-- | conf.lua | 1 | ||||
| -rw-r--r-- | src/im.lua | 12 | ||||
| -rw-r--r-- | src/utils.lua | 6 |
3 files changed, 8 insertions, 11 deletions
@@ -2,4 +2,5 @@ function love.conf(t) t.window.title = "Gutshot" t.window.width = 320 * 3 t.window.height = 180 * 3 + t.window.vsync = 0 end @@ -315,11 +315,13 @@ function im.begin_window(title, x, y, w, h, opts) end if mouse_down and focused_win == win then - local last = pop(wins) - wins[win.idx] = last - last.idx = win.idx - table.insert(wins, win) - win.idx = #wins + if wins[#wins] ~= win then + local last = table.remove(wins) + wins[win.idx] = last + last.idx = win.idx + table.insert(wins, win) + win.idx = #wins + end end end diff --git a/src/utils.lua b/src/utils.lua index 33ca7e8..ec5d16e 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -18,12 +18,6 @@ function min(a, b) return b end -function pop(tbl) - local last = tbl[#tbl] - tbl[#tbl] = nil - return last -end - function normalize(x, y) if x == 0 and y == 0 then return 0, 0 |
