diff -Nru xcb-imdkit-1.0.2/CMakeLists.txt xcb-imdkit-1.0.3/CMakeLists.txt --- xcb-imdkit-1.0.2/CMakeLists.txt 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/CMakeLists.txt 2021-08-24 17:57:19.000000000 +0000 @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(xcb-imdkit VERSION 1.0.2) +project(xcb-imdkit VERSION 1.0.3) find_package(ECM 0.0.11 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) diff -Nru xcb-imdkit-1.0.2/debian/changelog xcb-imdkit-1.0.3/debian/changelog --- xcb-imdkit-1.0.2/debian/changelog 2021-01-12 00:10:03.000000000 +0000 +++ xcb-imdkit-1.0.3/debian/changelog 2021-08-24 18:00:00.000000000 +0000 @@ -1,3 +1,12 @@ +xcb-imdkit (1.0.3-1) unstable; urgency=medium + + * Team upload. + * New upstream release. + * Update Standards-Version to 4.6.0 (no changes) + * Update symbols + + -- Shengjing Zhu Wed, 25 Aug 2021 02:00:00 +0800 + xcb-imdkit (1.0.2-1) unstable; urgency=medium * New upstream release. diff -Nru xcb-imdkit-1.0.2/debian/control xcb-imdkit-1.0.3/debian/control --- xcb-imdkit-1.0.2/debian/control 2020-12-08 21:03:15.000000000 +0000 +++ xcb-imdkit-1.0.3/debian/control 2021-08-24 18:00:00.000000000 +0000 @@ -12,7 +12,7 @@ libxcb-util0-dev, libxcb1-dev, uthash-dev, -Standards-Version: 4.5.1 +Standards-Version: 4.6.0 Rules-Requires-Root: no Homepage: https://github.com/fcitx/xcb-imdkit Vcs-Git: https://salsa.debian.org/input-method-team/xcb-imdkit.git diff -Nru xcb-imdkit-1.0.2/debian/libxcb-imdkit1.symbols xcb-imdkit-1.0.3/debian/libxcb-imdkit1.symbols --- xcb-imdkit-1.0.2/debian/libxcb-imdkit1.symbols 2020-12-08 21:08:07.000000000 +0000 +++ xcb-imdkit-1.0.3/debian/libxcb-imdkit1.symbols 2021-08-24 18:00:00.000000000 +0000 @@ -47,6 +47,7 @@ xcb_xim_ext_move@Base 1.0.1 xcb_xim_filter_event@Base 1.0.1 xcb_xim_forward_event@Base 1.0.1 + xcb_xim_get_encoding@Base 1.0.3 xcb_xim_get_ic_values@Base 1.0.1 xcb_xim_get_im_values@Base 1.0.1 xcb_xim_open@Base 1.0.1 @@ -55,6 +56,8 @@ xcb_xim_set_ic_values@Base 1.0.1 xcb_xim_set_im_callback@Base 1.0.1 xcb_xim_set_log_handler@Base 1.0.1 + xcb_xim_set_use_compound_text@Base 1.0.3 + xcb_xim_set_use_utf8_string@Base 1.0.3 xcb_xim_support_extension@Base 1.0.1 xcb_xim_trigger_notify@Base 1.0.1 xcb_xim_unset_ic_focus@Base 1.0.1 diff -Nru xcb-imdkit-1.0.2/src/clientprotocolhandler.c xcb-imdkit-1.0.3/src/clientprotocolhandler.c --- xcb-imdkit-1.0.2/src/clientprotocolhandler.c 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/src/clientprotocolhandler.c 2021-08-24 17:57:19.000000000 +0000 @@ -37,12 +37,23 @@ bool _xcb_xim_send_encoding_negotiation(xcb_xim_t *im) { xcb_im_encoding_negotiation_fr_t frame; - xcb_im_str_fr_t compound; - compound.length_of_string = strlen("COMPOUND_TEXT"); - compound.string = (uint8_t *)"COMPOUND_TEXT"; + xcb_im_str_fr_t encodings[2]; + + int idx = 0; + if (im->use_compound_text) { + encodings[idx].length_of_string = strlen("COMPOUND_TEXT"); + encodings[idx].string = (uint8_t *)"COMPOUND_TEXT"; + idx++; + } + if (im->use_utf8_string) { + encodings[idx].length_of_string = strlen("UTF8_STRING"); + encodings[idx].string = (uint8_t *)"UTF8_STRING"; + idx++; + } + frame.input_method_ID = im->connect_id; - frame.supported_list_of_encoding_in_IM_library.size = 1; - frame.supported_list_of_encoding_in_IM_library.items = &compound; + frame.supported_list_of_encoding_in_IM_library.size = idx; + frame.supported_list_of_encoding_in_IM_library.items = encodings; frame.list_of_encodings_supported_in_th.size = 0; frame.list_of_encodings_supported_in_th.items = 0; @@ -185,13 +196,23 @@ } do { + xcb_xim_encoding_t encodings[2] = {XCB_XIM_COMPOUND_TEXT, + XCB_XIM_COMPOUND_TEXT}; + size_t nEncodings = 0; + if (im->use_compound_text) { + encodings[nEncodings++] = XCB_XIM_COMPOUND_TEXT; + } + if (im->use_utf8_string) { + encodings[nEncodings++] = XCB_XIM_UTF8_STRING; + } // we only send compound if (frame.input_method_ID != im->connect_id && - frame.index_of_the_encoding_determined != 0) { + frame.index_of_the_encoding_determined >= nEncodings) { break; } im->open_state = XIM_OPEN_DONE; + im->encoding = encodings[frame.index_of_the_encoding_determined]; if (im->connect_state.callback) { im->connect_state.callback(im, im->connect_state.user_data); diff -Nru xcb-imdkit-1.0.2/src/imclient.c xcb-imdkit-1.0.3/src/imclient.c --- xcb-imdkit-1.0.2/src/imclient.c 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/src/imclient.c 2021-08-24 17:57:19.000000000 +0000 @@ -497,7 +497,6 @@ if (!imname) { imname = getenv("XMODIFIERS"); } - im->conn = conn; im->server_name = _xcb_xim_make_im_name(imname); im->screen_id = screen_id; @@ -509,6 +508,10 @@ } else { im->byte_order = 'B'; } + + im->use_compound_text = true; + im->use_utf8_string = false; + im->encoding = XCB_XIM_COMPOUND_TEXT; return im; } @@ -516,6 +519,16 @@ im->logger = logger; } +void xcb_xim_set_use_compound_text(xcb_xim_t *im, bool enable) { + im->use_compound_text = enable; +} + +void xcb_xim_set_use_utf8_string(xcb_xim_t *im, bool enable) { + im->use_utf8_string = enable; +} + +xcb_xim_encoding_t xcb_xim_get_encoding(xcb_xim_t *im) { return im->encoding; } + bool _xcb_xim_open(xcb_xim_t *im) { im->connect_state.phase = XIM_CONNECT_FAIL; im->open_state = XIM_OPEN_INVALID; diff -Nru xcb-imdkit-1.0.2/src/imclient.h xcb-imdkit-1.0.3/src/imclient.h --- xcb-imdkit-1.0.2/src/imclient.h 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/src/imclient.h 2021-08-24 17:57:19.000000000 +0000 @@ -86,6 +86,11 @@ XCB_XIM_TRIGGER_OFF_KEY, } xcb_xim_trigger_key_type_t; +typedef enum _xcb_xim_encoding_t { + XCB_XIM_COMPOUND_TEXT, + XCB_XIM_UTF8_STRING, +} xcb_xim_encoding_t; + typedef void (*xcb_xim_open_callback)(xcb_xim_t *im, void *user_data); typedef void (*xcb_xim_create_ic_callback)(xcb_xim_t *im, xcb_xic_t ic, void *user_data); @@ -106,6 +111,10 @@ int screen_id, const char *imname); XCBIMDKIT_EXPORT void xcb_xim_set_log_handler(xcb_xim_t *im, void (*logger)(const char *, ...)); +XCBIMDKIT_EXPORT void xcb_xim_set_use_compound_text(xcb_xim_t *im, bool enable); +XCBIMDKIT_EXPORT void xcb_xim_set_use_utf8_string(xcb_xim_t *im, bool enable); +XCBIMDKIT_EXPORT +xcb_xim_encoding_t xcb_xim_get_encoding(xcb_xim_t *im); XCBIMDKIT_EXPORT void xcb_xim_destroy(xcb_xim_t *im); XCBIMDKIT_EXPORT bool xcb_xim_open(xcb_xim_t *im, xcb_xim_open_callback callback, @@ -113,6 +122,9 @@ XCBIMDKIT_EXPORT void xcb_xim_set_im_callback(xcb_xim_t *im, const xcb_xim_im_callback *callbacks, void *user_data); +XCBIMDKIT_EXPORT void +xcb_xim_set_im_callback(xcb_xim_t *im, const xcb_xim_im_callback *callbacks, + void *user_data); XCBIMDKIT_EXPORT bool xcb_xim_filter_event(xcb_xim_t *im, xcb_generic_event_t *event); diff -Nru xcb-imdkit-1.0.2/src/imclient_p.h xcb-imdkit-1.0.3/src/imclient_p.h --- xcb-imdkit-1.0.2/src/imclient_p.h 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/src/imclient_p.h 2021-08-24 17:57:19.000000000 +0000 @@ -165,6 +165,10 @@ xcb_window_t focus_window; void (*logger)(const char *, ...); + + bool use_compound_text; + bool use_utf8_string; + xcb_xim_encoding_t encoding; }; #define _xcb_xim_read_frame(FRAME, DATA, LEN, FAIL) \ diff -Nru xcb-imdkit-1.0.2/src/protocolhandler.c xcb-imdkit-1.0.3/src/protocolhandler.c --- xcb-imdkit-1.0.2/src/protocolhandler.c 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/src/protocolhandler.c 2021-08-24 17:57:19.000000000 +0000 @@ -161,6 +161,7 @@ // no match then we use 0. if (i == frame.supported_list_of_encoding_in_IM_library.size) { i = 0; + j = 0; } xcb_im_encoding_negotiation_fr_free(&frame); @@ -169,10 +170,10 @@ reply_frame.index_of_the_encoding_determined = i; reply_frame.category_of_the_encoding_determined = 0; + uint16_t index = j; + if (im->callback) { - im->callback(im, client, NULL, hdr, &frame, - &reply_frame.index_of_the_encoding_determined, - im->user_data); + im->callback(im, client, NULL, hdr, &frame, &index, im->user_data); } _xcb_im_send_frame(im, client, reply_frame, true); diff -Nru xcb-imdkit-1.0.2/test/client_demo.c xcb-imdkit-1.0.3/test/client_demo.c --- xcb-imdkit-1.0.2/test/client_demo.c 2020-12-30 04:43:21.000000000 +0000 +++ xcb-imdkit-1.0.3/test/client_demo.c 2021-08-24 17:57:19.000000000 +0000 @@ -31,11 +31,15 @@ void commit_string(xcb_xim_t *im, xcb_xic_t ic, uint32_t flag, char *str, uint32_t length, uint32_t *keysym, size_t nKeySym, void *user_data) { - size_t newLength = 0; - char *utf8 = xcb_compound_text_to_utf8(str, length, &newLength); - if (utf8) { - int l = newLength; - fprintf(stderr, "key commit: %.*s\n", l, utf8); + if (xcb_xim_get_encoding(im) == XCB_XIM_UTF8_STRING) { + fprintf(stderr, "key commit utf8: %.*s\n", length, str); + } else if (xcb_xim_get_encoding(im) == XCB_XIM_COMPOUND_TEXT) { + size_t newLength = 0; + char *utf8 = xcb_compound_text_to_utf8(str, length, &newLength); + if (utf8) { + int l = newLength; + fprintf(stderr, "key commit: %.*s\n", l, utf8); + } } } @@ -88,6 +92,8 @@ xcb_xim_set_im_callback(im, &callback, NULL); xcb_xim_set_log_handler(im, logger); + xcb_xim_set_use_compound_text(im, true); + xcb_xim_set_use_utf8_string(im, true); // Open connection to XIM server. xcb_xim_open(im, open_callback, true, NULL);