diff --git a/src/frontend/xim/xim.cpp b/src/frontend/xim/xim.cpp index c9b81a0b1..753d7c4ef 100644 --- a/src/frontend/xim/xim.cpp +++ b/src/frontend/xim/xim.cpp @@ -303,10 +303,7 @@ class XIMInputContext final : public InputContext { void updateCursorLocation() { // kinds of like notification for position moving - bool hasSpotLocation = - xcb_im_input_context_get_preedit_attr_mask(xic_) & - XCB_XIM_XNSpotLocation_MASK; - auto p = xcb_im_input_context_get_preedit_attr(xic_)->spot_location; + auto mask = xcb_im_input_context_get_preedit_attr_mask(xic_); auto w = xcb_im_input_context_get_focus_window(xic_); if (!w) { w = xcb_im_input_context_get_client_window(xic_); @@ -314,7 +311,19 @@ class XIMInputContext final : public InputContext { if (!w) { return; } - if (hasSpotLocation) { + if (mask & XCB_XIM_XNArea_MASK) { + auto a = xcb_im_input_context_get_preedit_attr(xic_)->area; + auto trans_cookie = xcb_translate_coordinates( + server_->conn(), w, server_->root(), a.x, a.y); + auto reply = makeUniqueCPtr(xcb_translate_coordinates_reply( + server_->conn(), trans_cookie, nullptr)); + if (!reply) { + return; + } + setCursorRect( + Rect().setPosition(reply->dst_x, reply->dst_y).setSize(a.width, a.height)); + } else if (mask & XCB_XIM_XNSpotLocation_MASK) { + auto p = xcb_im_input_context_get_preedit_attr(xic_)->spot_location; auto trans_cookie = xcb_translate_coordinates( server_->conn(), w, server_->root(), p.x, p.y); auto reply = makeUniqueCPtr(xcb_translate_coordinates_reply( diff --git a/test/testxim.cpp b/test/testxim.cpp index 64e0210b0..c1fa44513 100644 --- a/test/testxim.cpp +++ b/test/testxim.cpp @@ -54,8 +54,13 @@ class XIMTest { xcb_point_t spot; spot.x = 0; spot.y = 0; + xcb_rectangle_t area; + area.x = 0; + area.y = 0; + area.width = 5; + area.height = 10; xcb_xim_nested_list nested = xcb_xim_create_nested_list( - im.get(), XCB_XIM_XNSpotLocation, &spot, NULL); + im.get(), XCB_XIM_XNSpotLocation, &spot, XCB_XIM_XNArea, &area, NULL); xcb_xim_create_ic(im.get(), create_ic_callback, this, XCB_XIM_XNInputStyle, &input_style, XCB_XIM_XNClientWindow, &w_, XCB_XIM_XNFocusWindow,