Fix cursor blinking too fast sometimes

This commit is contained in:
Ksaper 2023-03-16 04:56:08 +02:00
parent 0c6a1ca4f5
commit 070150e902
1 changed files with 17 additions and 10 deletions

View File

@ -724,19 +724,25 @@ function text_input:focus()
run_keygrabber(self) run_keygrabber(self)
if wp.cursor_blink then if wp.cursor_blink then
gtimer.start_new(wp.cursor_blink_rate, function() if wp.cursor_blink_timer == nil then
if self:get_focused() == true then wp.cursor_blink_timer = gtimer {
if self._private.cursor_opacity == 1 then timeout = wp.cursor_blink_rate,
self:hide_cursor() autostart = false,
elseif self:get_mode() == "insert" then call_now = false,
self:show_cursor() single_shot = false,
callback = function()
if self._private.cursor_opacity == 1 then
self:hide_cursor()
elseif self:get_mode() == "insert" then
self:show_cursor()
end
end end
return true }
end end
return false wp.cursor_blink_timer:start()
end)
end end
wp.focused = true wp.focused = true
self:emit_signal("focus") self:emit_signal("focus")
end end
@ -749,6 +755,7 @@ function text_input:unfocus(context)
set_mouse_cursor("left_ptr") set_mouse_cursor("left_ptr")
self:hide_cursor() self:hide_cursor()
wp.cursor_blink_timer:stop()
self:hide_selection() self:hide_selection()
if self.reset_on_unfocus == true then if self.reset_on_unfocus == true then
self:set_text("") self:set_text("")