From b1062e701e22f8af803f69dbfd3514f45bc4cf59 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sat, 20 Jan 2024 18:06:58 +0100 Subject: [PATCH] make primary selection pasting work it is also bugged, as SDL misses large parts of selection sources (terminals etc) but browers work --- src/chat_gui4.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index a8531472..4a91c69e 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -17,6 +17,7 @@ #include "./media_meta_info_loader.hpp" #include "./sdl_clipboard_utils.hpp" +#include "SDL_clipboard.h" #include #include @@ -492,6 +493,18 @@ void ChatGui4::render(float time_delta) { _text_input_buffer.clear(); evil_enter_looses_focus_hack = true; } + + // welcome to linux + if (ImGui::IsMouseClicked(ImGuiMouseButton_Middle)) { + if (!ImGui::IsItemFocused()) { + ImGui::SetKeyboardFocusHere(-1); + } + char* primary_text = SDL_GetPrimarySelectionText(); + if (primary_text != nullptr) { + ImGui::GetIO().AddInputCharactersUTF8(primary_text); + SDL_free(primary_text); + } + } } ImGui::EndChild(); ImGui::SameLine();