Fix QueryPointer

QueryPointer is supposed to return first child of the window containing
the pointer, not the deepest child. This fixes gtk getting into an
invalid state when pressing a mouse button
This commit is contained in:
2026-06-01 04:26:34 +03:00
parent 82edc9c76b
commit 504eb2716b

View File

@@ -1940,12 +1940,15 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
const auto& window = TRY_REF(get_window(client_info, wid, opcode)); const auto& window = TRY_REF(get_window(client_info, wid, opcode));
int32_t root_x, root_y; WINDOW child_wid { None };
int32_t event_x, event_y; for (auto wid_ : window.children)
root_x = event_x = window.cursor_x; {
root_y = event_y = window.cursor_y; const auto& child_window = g_objects[wid_]->object.get<Object::Window>();
if (!child_window.hovered)
const auto child_wid = find_child_window(wid, event_x, event_y); continue;
child_wid = wid_;
break;
}
xQueryPointerReply reply { xQueryPointerReply reply {
.type = X_Reply, .type = X_Reply,
@@ -1953,11 +1956,11 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
.sequenceNumber = client_info.sequence, .sequenceNumber = client_info.sequence,
.length = 0, .length = 0,
.root = g_root.windowId, .root = g_root.windowId,
.child = static_cast<CARD32>(child_wid == wid ? None : child_wid), .child = static_cast<CARD32>(child_wid),
.rootX = static_cast<INT16>(root_x), .rootX = static_cast<INT16>(window.cursor_x), // FIXME
.rootY = static_cast<INT16>(root_y), .rootY = static_cast<INT16>(window.cursor_y), // FIXME
.winX = static_cast<INT16>(event_x), .winX = static_cast<INT16>(window.cursor_x),
.winY = static_cast<INT16>(event_y), .winY = static_cast<INT16>(window.cursor_y),
.mask = static_cast<KeyButMask>(g_keymask | g_butmask), .mask = static_cast<KeyButMask>(g_keymask | g_butmask),
}; };
TRY(encode(client_info.output_buffer, reply)); TRY(encode(client_info.output_buffer, reply));