Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow XIM XNArea for client preedit area in OnTheSpot mode. #1163

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/frontend/xim/xim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,28 @@ 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_);
}
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(
Expand Down
14 changes: 10 additions & 4 deletions test/testxim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ class XIMTest {
1, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen_->root_visual, 0, NULL);
uint32_t input_style = XCB_IM_PreeditPosition | XCB_IM_StatusArea;
xcb_point_t spot;
spot.x = 0;
spot.y = 0;
xcb_xim_nested_list nested = xcb_xim_create_nested_list(
im.get(), XCB_XIM_XNSpotLocation, &spot, NULL);
spot.x = 5;
spot.y = 10;
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,
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,
Expand Down
Loading