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 3ceab67e6..a67bd14ec 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -1373,6 +1373,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); } @@ -1385,7 +1389,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; } @@ -1479,8 +1483,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); } @@ -1499,7 +1502,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 2d948d71e..d83082517 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 |