diff options
| author | Neil <nyamatongwe@gmail.com> | 2019-04-11 16:05:01 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2019-04-11 16:05:01 +1000 |
| commit | e536b61148c007c306bdedbea55000f8eb152884 (patch) | |
| tree | b214afba5241f1f4f29f3f06c545e9bdba1903e8 /gtk/ScintillaGTK.cxx | |
| parent | 18b0e610929260475c81baab1c0a52d88f5dc11a (diff) | |
| download | scintilla-mirror-e536b61148c007c306bdedbea55000f8eb152884.tar.gz | |
Bug [#2087]. Fix flickering when inserting primary selection on GTK between
SciTE tabs.
This does not allow primary selection to work between tabs as the tabs are
sharing a single Scintilla and the old primary selection is unclaimed when the
file is changed.
This fix adds a new ReceivedClipboard method which does not try to convert the
selection if received in a different format than asked for. It was the call to
gtk_selection_convert that seemed to cause the flickering. ReceivedClipboard is
only called from SelectionReceiver::ClipboardReceived so only occurs due to a
call to RequestSelection and can not occur because of a selection_received
signal.
ReceivedSelection is left with its complexity in case it is needed for some
other issue although it doesn't appear to be called for drag&drop, for example.
Diffstat (limited to 'gtk/ScintillaGTK.cxx')
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 5ee3b865a..524a8bb57 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1282,7 +1282,7 @@ public: static void ClipboardReceived(GtkClipboard *, GtkSelectionData *selection_data, gpointer data) { SelectionReceiver *self = static_cast<SelectionReceiver *>(data); if (self->sci) { - self->sci->ReceivedSelection(selection_data); + self->sci->ReceivedClipboard(selection_data); } delete self; } @@ -1433,10 +1433,37 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio } } +void ScintillaGTK::InsertSelection(GtkSelectionData *selectionData) { + const gint length = gtk_selection_data_get_length(selectionData); + if (length >= 0) { + GdkAtom selection = gtk_selection_data_get_selection(selectionData); + SelectionText selText; + GetGtkSelectionText(selectionData, selText); + + UndoGroup ug(pdoc); + if (selection == GDK_SELECTION_CLIPBOARD) { + ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); + } + + InsertPasteShape(selText.Data(), selText.Length(), + selText.rectangular ? pasteRectangular : pasteStream); + EnsureCaretVisible(); + } + Redraw(); +} + GObject *ScintillaGTK::MainObject() const noexcept { return G_OBJECT(PWidget(wMain)); } +void ScintillaGTK::ReceivedClipboard(GtkSelectionData *selection_data) noexcept { + try { + InsertSelection(selection_data); + } catch (...) { + errorStatus = SC_STATUS_FAILURE; + } +} + void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) { try { if ((SelectionOfGSD(selection_data) == GDK_SELECTION_CLIPBOARD) || @@ -1447,22 +1474,11 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) { SelectionOfGSD(selection_data), atomSought, GDK_CURRENT_TIME); } else if ((LengthOfGSD(selection_data) > 0) && ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8))) { - SelectionText selText; - GetGtkSelectionText(selection_data, selText); - - UndoGroup ug(pdoc); - if (SelectionOfGSD(selection_data) != GDK_SELECTION_PRIMARY) { - ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); - } - - InsertPasteShape(selText.Data(), selText.Length(), - selText.rectangular ? pasteRectangular : pasteStream); - EnsureCaretVisible(); + InsertSelection(selection_data); } } // else fprintf(stderr, "Target non string %d %d\n", (int)(selection_data->type), // (int)(atomUTF8)); - Redraw(); } catch (...) { errorStatus = SC_STATUS_FAILURE; } |
