LibGUI/WindowServer: Allow querying global cursor position
This commit is contained in:
@@ -40,6 +40,19 @@ BAN::ErrorOr<void> WindowServer::set_background_image(BAN::UniqPtr<LibImage::Ima
|
||||
return {};
|
||||
}
|
||||
|
||||
void WindowServer::on_query_pointer(int fd, const LibGUI::WindowPacket::QueryPointer&)
|
||||
{
|
||||
const LibGUI::EventPacket::QueryPointerEvent event_packet { .event = {
|
||||
.x = m_cursor.x,
|
||||
.y = m_cursor.y,
|
||||
}};
|
||||
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)
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
BAN::ErrorOr<void> set_background_image(BAN::UniqPtr<LibImage::Image>);
|
||||
|
||||
void on_query_pointer(int fd, const LibGUI::WindowPacket::QueryPointer&);
|
||||
|
||||
void on_window_create(int fd, const LibGUI::WindowPacket::WindowCreate&);
|
||||
void on_window_invalidate(int fd, const LibGUI::WindowPacket::WindowInvalidate&);
|
||||
void on_window_set_position(int fd, const LibGUI::WindowPacket::WindowSetPosition&);
|
||||
|
||||
@@ -472,6 +472,7 @@ int main()
|
||||
WINDOW_PACKET_CASE(WindowSetFullscreen, on_window_set_fullscreen);
|
||||
WINDOW_PACKET_CASE(WindowSetTitle, on_window_set_title);
|
||||
WINDOW_PACKET_CASE(WindowSetCursor, on_window_set_cursor);
|
||||
WINDOW_PACKET_CASE(QueryPointer, on_query_pointer);
|
||||
#undef WINDOW_PACKET_CASE
|
||||
default:
|
||||
dprintln("unhandled packet type: {}", static_cast<uint32_t>(header.type));
|
||||
|
||||
Reference in New Issue
Block a user