bugfix: alt-tab shouldn't emit keypress events
Looks like this only happens on Linux: https://love2d.org/forums/viewtopic.php?p=249700
This commit is contained in:
parent
6c6a7aab07
commit
94b6d04e83
21
main.lua
21
main.lua
|
@ -19,8 +19,9 @@ function App.initialize_globals()
|
||||||
-- blinking cursor
|
-- blinking cursor
|
||||||
Cursor_time = 0
|
Cursor_time = 0
|
||||||
|
|
||||||
-- for hysteresis
|
-- for hysteresis in a few places
|
||||||
Last_resize_time = App.getTime()
|
Last_resize_time = App.getTime()
|
||||||
|
Last_focus_time = App.getTime() -- https://love2d.org/forums/viewtopic.php?p=249700
|
||||||
end
|
end
|
||||||
|
|
||||||
-- called only for real run
|
-- called only for real run
|
||||||
|
@ -174,17 +175,35 @@ function App.mousereleased(x,y, mouse_button)
|
||||||
return edit.mouse_released(Editor_state, x,y, mouse_button)
|
return edit.mouse_released(Editor_state, x,y, mouse_button)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function App.focus(in_focus)
|
||||||
|
if in_focus then
|
||||||
|
Last_focus_time = App.getTime()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function App.textinput(t)
|
function App.textinput(t)
|
||||||
|
-- ignore events for some time after window in focus
|
||||||
|
if App.getTime() < Last_focus_time + 0.01 then
|
||||||
|
return
|
||||||
|
end
|
||||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||||
return edit.textinput(Editor_state, t)
|
return edit.textinput(Editor_state, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
function App.keychord_pressed(chord, key)
|
function App.keychord_pressed(chord, key)
|
||||||
|
-- ignore events for some time after window in focus
|
||||||
|
if App.getTime() < Last_focus_time + 0.01 then
|
||||||
|
return
|
||||||
|
end
|
||||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||||
return edit.keychord_pressed(Editor_state, chord, key)
|
return edit.keychord_pressed(Editor_state, chord, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function App.keyreleased(key, scancode)
|
function App.keyreleased(key, scancode)
|
||||||
|
-- ignore events for some time after window in focus
|
||||||
|
if App.getTime() < Last_focus_time + 0.01 then
|
||||||
|
return
|
||||||
|
end
|
||||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||||
return edit.key_released(Editor_state, key, scancode)
|
return edit.key_released(Editor_state, key, scancode)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue