Allow the user to disable cursor blinking. (#2170)

This uses the same setting which is also used by the built-in text entry
widget.
upstream-master
Gabriel Ebner 5 years ago committed by GitHub
parent c7428cf9f3
commit 65c9c1173b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      src/gui/TextEditor.cpp
  2. 1
      src/gui/TextEditor.h

@ -31,6 +31,7 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own
gtk_text_buffer_place_cursor(this->buffer, &first);
GtkSettings* settings = gtk_widget_get_settings(this->widget);
g_object_get(settings, "gtk-cursor-blink", &this->cursorBlink, nullptr);
g_object_get(settings, "gtk-cursor-blink-time", &this->cursorBlinkTime, nullptr);
g_object_get(settings, "gtk-cursor-blink-timeout", &this->cursorBlinkTimeout, nullptr);
@ -42,7 +43,11 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own
g_signal_connect(this->imContext, "retrieve-surrounding", G_CALLBACK(iMRetrieveSurroundingCallback), this);
g_signal_connect(this->imContext, "delete-surrounding", G_CALLBACK(imDeleteSurroundingCallback), this);
blinkCallback(this);
if (this->cursorBlink) {
blinkCallback(this);
} else {
this->cursorVisible = true;
}
}
TextEditor::~TextEditor() {
@ -523,11 +528,15 @@ void TextEditor::moveCursor(GtkMovementStep step, int count, bool extendSelectio
gtk_widget_error_bell(this->widget);
}
this->cursorVisible = false;
if (this->blinkTimeout) {
g_source_remove(this->blinkTimeout);
if (this->cursorBlink) {
this->cursorVisible = false;
if (this->blinkTimeout) {
g_source_remove(this->blinkTimeout);
}
blinkCallback(this);
} else {
repaintCursor();
}
blinkCallback(this);
}
void TextEditor::findPos(GtkTextIter* iter, double xPos, double yPos) {
@ -854,7 +863,11 @@ void TextEditor::resetImContext() {
}
}
void TextEditor::repaintCursor() { repaintEditor(); }
void TextEditor::repaintCursor() {
double x = this->text->getX();
double y = this->text->getY();
this->gui->repaintArea(x, y, x + this->text->getElementWidth(), y + this->text->getElementHeight());
}
#define CURSOR_ON_MULTIPLIER 2
#define CURSOR_OFF_MULTIPLIER 1

@ -105,6 +105,7 @@ private:
double markPosX = 0;
double markPosY = 0;
bool cursorBlink = true;
int cursorBlinkTime = 0;
int cursorBlinkTimeout = 0;
int blinkTimeout = 0; // handler id

Loading…
Cancel
Save