From 3736d9a24cbdc9768c78b409603e3bb93ff92360 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Thu, 19 Dec 2024 11:22:57 +0100 Subject: [PATCH] VNCConn: add UTF-8 cuttext receiving re #252 --- src/VNCConn.cpp | 15 ++++++++++++++- src/VNCConn.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/VNCConn.cpp b/src/VNCConn.cpp index 1d3e1cbb..afd5f7b0 100644 --- a/src/VNCConn.cpp +++ b/src/VNCConn.cpp @@ -961,7 +961,7 @@ void VNCConn::thread_got_cuttext(rfbClient *cl, const char *text, int len) { VNCConn* conn = (VNCConn*) rfbClientGetClientData(cl, VNCCONN_OBJ_ID); - wxLogDebug(wxT("VNCConn %p: got cuttext: '%s'"), conn, wxString(text, wxCSConv(wxT("iso-8859-1"))).c_str()); + wxLogDebug(wxT("VNCConn %p: got Latin1 cuttext: '%s'"), conn, wxString(text, wxCSConv(wxT("iso-8859-1"))).c_str()); wxCriticalSectionLocker lock(conn->mutex_cuttext); // since cuttext can also be set from the main thread conn->cuttext = wxString(text, wxCSConv(wxT("iso-8859-1"))); @@ -969,6 +969,18 @@ void VNCConn::thread_got_cuttext(rfbClient *cl, const char *text, int len) } +void VNCConn::thread_got_cuttext_utf8(rfbClient *cl, const char *text, int len) +{ + VNCConn* conn = (VNCConn*) rfbClientGetClientData(cl, VNCCONN_OBJ_ID); + + wxLogDebug(wxT("VNCConn %p: got UTF-8 cuttext: '%s'"), conn, wxString(text, wxConvUTF8).c_str()); + + wxCriticalSectionLocker lock(conn->mutex_cuttext); // since cuttext can also be set from the main thread + conn->cuttext = wxString(text, wxConvUTF8); + conn->thread_post_cuttext_notify(); +} + + void VNCConn::thread_bell(rfbClient *cl) { VNCConn* conn = (VNCConn*) rfbClientGetClientData(cl, VNCCONN_OBJ_ID); @@ -1087,6 +1099,7 @@ bool VNCConn::setupClient() cl->HandleKeyboardLedState = thread_kbd_leds; cl->HandleTextChat = thread_textchat; cl->GotXCutText = thread_got_cuttext; + cl->GotXCutTextUTF8 = thread_got_cuttext_utf8; cl->Bell = thread_bell; cl->HandleXvpMsg = thread_handle_xvp; diff --git a/src/VNCConn.h b/src/VNCConn.h index 0a4e3fe7..606c1126 100644 --- a/src/VNCConn.h +++ b/src/VNCConn.h @@ -315,6 +315,7 @@ class VNCConn: public wxEvtHandler, public wxThreadHelper static void thread_kbd_leds(rfbClient* cl, int value, int pad); static void thread_textchat(rfbClient* cl, int value, char *text); static void thread_got_cuttext(rfbClient *cl, const char *text, int len); + static void thread_got_cuttext_utf8(rfbClient *cl, const char *text, int len); static void thread_bell(rfbClient *cl); static void thread_handle_xvp(rfbClient *cl, uint8_t ver, uint8_t code); static void thread_logger(const char *format, ...);