More robust blink control based on window focus state

This commit is contained in:
Kovid Goyal 2017-01-14 18:01:03 +05:30
parent 8300fb31e5
commit 217cc2f40e
2 changed files with 2 additions and 9 deletions

View File

@ -293,10 +293,6 @@ class Boss(Thread):
if w is not None: if w is not None:
yield w yield w
w.focus_changed(focused) w.focus_changed(focused)
if focused:
self.start_cursor_blink()
else:
self.stop_cursor_blinking()
def display_scrollback(self, data): def display_scrollback(self, data):
if self.opts.scrollback_in_new_tab: if self.opts.scrollback_in_new_tab:
@ -405,7 +401,7 @@ class Boss(Thread):
rd = render_data.get(active) rd = render_data.get(active)
if rd is not None: if rd is not None:
draw_cursor = True draw_cursor = True
if self.cursor_blinking and self.opts.cursor_blink_interval > 0: if self.cursor_blinking and self.opts.cursor_blink_interval > 0 and self.window_is_focused:
now = monotonic() - self.cursor_blink_zero_time now = monotonic() - self.cursor_blink_zero_time
t = int(now * 1000) t = int(now * 1000)
d = int(self.opts.cursor_blink_interval * 1000) d = int(self.opts.cursor_blink_interval * 1000)

View File

@ -481,8 +481,5 @@ class CharGrid:
glUniform4f(ul('color'), col[0], col[1], col[2], alpha) glUniform4f(ul('color'), col[0], col[1], col[2], alpha)
glUniform2f(ul('xpos'), left, right) glUniform2f(ul('xpos'), left, right)
glUniform2f(ul('ypos'), top, bottom) glUniform2f(ul('ypos'), top, bottom)
if is_focused: glDrawArrays(GL_TRIANGLE_FAN if is_focused else GL_LINE_LOOP, 0, 4)
glDrawArrays(GL_TRIANGLE_FAN, 0, 4)
else:
glDrawArrays(GL_LINE_LOOP, 0, 4)
glDisable(GL_BLEND) glDisable(GL_BLEND)