Improve IME location updates (#1170)

* Avoid updating IME input rect if it hasn't changed
* Update the IME input rect even when the composition didn't change
* Apply IME input blocking workaround to non-Linux only
This commit is contained in:
Guldoman
2022-12-20 20:11:13 -04:00
committed by GitHub
parent 24179bbb23
commit c42f01ed1f
3 changed files with 30 additions and 7 deletions
+10 -1
View File
@@ -4,6 +4,7 @@ local ime = { }
function ime.reset()
ime.editing = false
ime.last_location = { x = 0, y = 0, w = 0, h = 0 }
end
---Convert from utf-8 offset and length (from SDL) to byte offsets
@@ -76,7 +77,15 @@ end
---@param w number
---@param h number
function ime.set_location(x, y, w, h)
system.set_text_input_rect(x, y, w, h)
if not ime.last_location or
ime.last_location.x ~= x or
ime.last_location.y ~= y or
ime.last_location.w ~= w or
ime.last_location.h ~= h
then
ime.last_location.x, ime.last_location.y, ime.last_location.w, ime.last_location.h = x, y, w, h
system.set_text_input_rect(x, y, w, h)
end
end
ime.reset()