From 4cbdea954a9f39ec21171fba13da3a65f12c3f1e Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 6 Aug 2023 12:45:13 +0200 Subject: [PATCH] wind: Generate random windows on keypresses --- wind/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wind/main.cpp b/wind/main.cpp index c095332d..cecb4a22 100644 --- a/wind/main.cpp +++ b/wind/main.cpp @@ -11,10 +11,13 @@ #include #include #include +#include #include Result luna_main(int argc, char** argv) { + srand((unsigned)time(NULL)); + StringView socket_path = "/tmp/wind.sock"; StringView user; @@ -105,7 +108,14 @@ Result luna_main(int argc, char** argv) { moon::KeyboardPacket packet; TRY(keyboard->read_typed(packet)); - background = ui::Color::from_rgb(0x00, 0x00, packet.key * 2); + if (!packet.released) + { + TRY(make(ui::Rect { rand() % screen.canvas().width, rand() % screen.canvas().height, + rand() % screen.canvas().width, rand() % screen.canvas().height }, + ui::Color::from_rgb(static_cast(rand() % 256), static_cast(rand() % 256), + static_cast(rand() % 256)), + strerror(packet.key))); + } } if (fds[2].revents & POLLIN) {