make primary selection pasting work

it is also bugged, as SDL misses large parts of selection sources (terminals etc) but browers work
This commit is contained in:
Green Sky 2024-01-20 18:06:58 +01:00
parent e72aebc043
commit b1062e701e
No known key found for this signature in database

View File

@ -17,6 +17,7 @@
#include "./media_meta_info_loader.hpp"
#include "./sdl_clipboard_utils.hpp"
#include "SDL_clipboard.h"
#include <cctype>
#include <cstdint>
@ -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();