LibGUI: Add query keymap request

This commit is contained in:
2026-07-04 19:12:56 +03:00
parent 6aa2329267
commit a41a3eeb66
6 changed files with 61 additions and 0 deletions

View File

@@ -53,6 +53,37 @@ void WindowServer::on_query_pointer(int fd, const LibGUI::WindowPacket::QueryPoi
}
}
void WindowServer::on_query_keymap(int fd, const LibGUI::WindowPacket::QueryKeymap&)
{
LibGUI::EventPacket::QueryKeymapEvent event_packet {};
const uint16_t modifiers[4] {
0,
LibInput::KeyEvent::LShift,
LibInput::KeyEvent::RAlt,
LibInput::KeyEvent::LShift | LibInput::KeyEvent::RAlt,
};
const auto& layout = LibInput::KeyboardLayout::get();
for (size_t i = 0; i < 4; i++)
{
event_packet.event.modifiers[i] = modifiers[i];
for (size_t keycode = 0; keycode < 0x100; keycode++)
{
event_packet.event.keymap[i][keycode] = static_cast<uint32_t>(layout.key_event_from_raw({
.modifier = modifiers[i],
.keycode = static_cast<uint8_t>(keycode),
}).key);
}
}
if (auto ret = append_serialized_packet(event_packet, fd); ret.is_error())
{
dwarnln("could not respond to query pointer request: {}", ret.error());
return;
}
}
void WindowServer::on_window_create(int fd, const LibGUI::WindowPacket::WindowCreate& packet)
{
for (auto& window : m_client_windows)

View File

@@ -32,6 +32,7 @@ public:
BAN::ErrorOr<void> set_background_image(BAN::UniqPtr<LibImage::Image>);
void on_query_pointer(int fd, const LibGUI::WindowPacket::QueryPointer&);
void on_query_keymap(int fd, const LibGUI::WindowPacket::QueryKeymap&);
void on_window_create(int fd, const LibGUI::WindowPacket::WindowCreate&);
void on_window_invalidate(int fd, const LibGUI::WindowPacket::WindowInvalidate&);

View File

@@ -474,6 +474,7 @@ int main()
WINDOW_PACKET_CASE(WindowSetTitle, on_window_set_title);
WINDOW_PACKET_CASE(WindowSetCursor, on_window_set_cursor);
WINDOW_PACKET_CASE(QueryPointer, on_query_pointer);
WINDOW_PACKET_CASE(QueryKeymap, on_query_keymap);
#undef WINDOW_PACKET_CASE
default:
dprintln("unhandled packet type: {}", static_cast<uint32_t>(header.type));