diff options
| -rwxr-xr-x | gtk/ScintillaGTK.cxx | 11 | ||||
| -rwxr-xr-x | gtk/ScintillaGTK.h | 1 |
2 files changed, 8 insertions, 4 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 5d5dc0475..66f865462 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1377,6 +1377,10 @@ void ScintillaGTK::ClaimSelection() { } } +bool ScintillaGTK::IsStringAtom(GdkAtom type) { + return (type == GDK_TARGET_STRING) || (type == atomUTF8) || (type == atomUTF8Mime); +} + static const guchar *DataOfGSD(GtkSelectionData *sd) noexcept { return gtk_selection_data_get_data(sd); } static gint LengthOfGSD(GtkSelectionData *sd) noexcept { return gtk_selection_data_get_length(sd); } static GdkAtom TypeOfGSD(GtkSelectionData *sd) noexcept { return gtk_selection_data_get_data_type(sd); } @@ -1389,7 +1393,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio GdkAtom selectionTypeData = TypeOfGSD(selectionData); // Return empty string if selection is not a string - if ((selectionTypeData != GDK_TARGET_STRING) && (selectionTypeData != atomUTF8) && (selectionTypeData != atomUTF8Mime)) { + if (!IsStringAtom(selectionTypeData)) { selText.Clear(); return; } @@ -1483,8 +1487,7 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) { atomSought = atomString; gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), SelectionOfGSD(selection_data), atomSought, GDK_CURRENT_TIME); - } else if ((LengthOfGSD(selection_data) > 0) && - ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8) || (TypeOfGSD(selection_data) == atomUTF8Mime))) { + } else if ((LengthOfGSD(selection_data) > 0) && IsStringAtom(TypeOfGSD(selection_data))) { GtkClipboard *clipBoard = gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), SelectionOfGSD(selection_data)); InsertSelection(clipBoard, selection_data); } @@ -1503,7 +1506,7 @@ void ScintillaGTK::ReceivedDrop(GtkSelectionData *selection_data) { std::vector<char> drop(data, data + LengthOfGSD(selection_data)); drop.push_back('\0'); NotifyURIDropped(&drop[0]); - } else if ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8) || (TypeOfGSD(selection_data) == atomUTF8Mime)) { + } else if (IsStringAtom(TypeOfGSD(selection_data))) { if (LengthOfGSD(selection_data) > 0) { SelectionText selText; GetGtkSelectionText(selection_data, selText); diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index 2d4b4830d..e8c61f85f 100755 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -134,6 +134,7 @@ private: void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override; bool OwnPrimarySelection(); void ClaimSelection() override; + static bool IsStringAtom(GdkAtom type); void GetGtkSelectionText(GtkSelectionData *selectionData, SelectionText &selText); void InsertSelection(GtkClipboard *clipBoard, GtkSelectionData *selectionData); public: // Public for SelectionReceiver |
