Skip to content

Commit

Permalink
gui2/ttext_: Disable blinking cursor
Browse files Browse the repository at this point in the history
There's an issue with textboxes across separate window instances (e.g.
when firing up the New Folder dialog in the file dialog) each getting a
blinking cursor simultaneously displayed on the screen due to timer
events persisting even when a GUI2 window isn't running. This may cause
repaint issues since the whole textbox may need to be redrawn each time
the timer fires, so it's best to disable it until I figure out a better
way to implement a unique global blinking cursor.
  • Loading branch information
irydacea committed Oct 14, 2016
1 parent 1d820b2 commit 6e56339
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion data/gui/widget/text_box_default.cfg
Expand Up @@ -66,7 +66,8 @@
x2 = "(cursor_offset + {X_OFFSET})"
y2 = "(text_y_offset + text_font_height - 2)"
color = "255, 255, 255, 255"
alpha = "(cursor_alpha)"
# TODO: disabled until there's a way to deal with textboxes on multiple windows
#alpha = "(cursor_alpha)"
thickness = 1
[/line]
#enddef
Expand Down
10 changes: 9 additions & 1 deletion src/gui/widgets/text.cpp
Expand Up @@ -40,7 +40,7 @@ ttext_::ttext_()
, selection_length_(0)
, cursor_timer_(0)
, cursor_alpha_(0)
, cursor_blink_rate_ms_(750)
, cursor_blink_rate_ms_(0) // TODO: disabled until there's a way to deal with textboxes on multiple windows
, text_changed_callback_()
{
#ifdef __unix__
Expand Down Expand Up @@ -254,6 +254,10 @@ void ttext_::set_state(const tstate state)

void ttext_::toggle_cursor_timer(bool enable)
{
if(!cursor_blink_rate_ms_) {
return;
}

if(cursor_timer_) {
remove_timer(cursor_timer_);
}
Expand Down Expand Up @@ -285,6 +289,10 @@ void ttext_::cursor_timer_callback()

void ttext_::reset_cursor_state()
{
if(!cursor_blink_rate_ms_) {
return;
}

cursor_alpha_ = 255;

for(auto& tmp : canvas()) {
Expand Down

0 comments on commit 6e56339

Please sign in to comment.