Skip to content

Commit 9ac17fb

Browse files
committed
fixed cursor stops blinking (#2714)
1 parent 0c16062 commit 9ac17fb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/ct/ct_main_win.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ct_main_win.cc
33
*
4-
* Copyright 2009-2024
4+
* Copyright 2009-2025
55
* Giuseppe Penone <giuspen@gmail.com>
66
* Evgenii Gurianov <https://github.com/txe>
77
*
@@ -341,9 +341,11 @@ void CtMainWin::config_apply()
341341
_ctTextview.set_pixels_inside_wrap(_pCtConfig->spaceAroundLines, _pCtConfig->relativeWrappedSpace);
342342
textView.set_wrap_mode(_pCtConfig->lineWrapping ? Gtk::WrapMode::WRAP_WORD_CHAR : Gtk::WrapMode::WRAP_NONE);
343343

344+
Glib::RefPtr<Gtk::Settings> pSettings = Gtk::Settings::get_default();
344345
if (2 != _pCtConfig->cursorBlink) {
345-
Gtk::Settings::get_default()->property_gtk_cursor_blink() = _pCtConfig->cursorBlink;
346+
pSettings->property_gtk_cursor_blink() = _pCtConfig->cursorBlink;
346347
}
348+
pSettings->property_gtk_cursor_blink_timeout() = INT_MAX; /*otherwise the cursor stops blinking after 10 sec of inactivity*/
347349
if (2 != _pCtConfig->overlayScroll) {
348350
// Gtk::Settings::get_default()->property_gtk_overlay_scrolling() = _pCtConfig->overlayScroll;
349351
_scrolledwindowText.set_overlay_scrolling(static_cast<bool>(_pCtConfig->overlayScroll));

src/ct/ct_main_win_events.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,18 @@ void CtMainWin::_on_textview_populate_popup(Gtk::Menu* menu)
336336
// Update the cursor image if the pointer moved
337337
bool CtMainWin::_on_textview_motion_notify_event(GdkEventMotion* event)
338338
{
339-
if (not _ctTextview.mm().get_cursor_visible())
340-
_ctTextview.mm().set_cursor_visible(true);
341-
if (curr_tree_iter().get_node_syntax_highlighting() != CtConst::RICH_TEXT_ID
342-
and curr_tree_iter().get_node_syntax_highlighting() != CtConst::PLAIN_TEXT_ID)
343-
{
344-
_ctTextview.mm().get_window(Gtk::TEXT_WINDOW_TEXT)->set_cursor(Gdk::Cursor::create(Gdk::XTERM));
339+
Gtk::TextView& textView = _ctTextview.mm();
340+
if (not textView.get_cursor_visible()) {
341+
textView.set_cursor_visible(true);
342+
}
343+
//textView.reset_cursor_blink();
344+
CtTreeIter ctTreeIter = curr_tree_iter();
345+
if (ctTreeIter.get_node_is_code()) {
346+
textView.get_window(Gtk::TEXT_WINDOW_TEXT)->set_cursor(Gdk::Cursor::create(Gdk::XTERM));
345347
return false;
346348
}
347349
int x, y;
348-
_ctTextview.mm().window_to_buffer_coords(Gtk::TEXT_WINDOW_TEXT, (int)event->x, (int)event->y, x, y);
350+
textView.window_to_buffer_coords(Gtk::TEXT_WINDOW_TEXT, (int)event->x, (int)event->y, x, y);
349351
_ctTextview.cursor_and_tooltips_handler(x, y);
350352
return false;
351353
}

0 commit comments

Comments
 (0)