Skip to content

Commit

Permalink
VNCConn: add UTF-8 cuttext receiving
Browse files Browse the repository at this point in the history
re #252
  • Loading branch information
bk138 committed Dec 19, 2024
1 parent 9f88dde commit 3736d9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/VNCConn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,26 @@ 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")));
conn->thread_post_cuttext_notify();
}


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);
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/VNCConn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...);
Expand Down

0 comments on commit 3736d9a

Please sign in to comment.