wind: Generate random windows on keypresses
This commit is contained in:
parent
11e0025a5b
commit
3fefb74710
@ -11,10 +11,13 @@
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/poll.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Result<int> luna_main(int argc, char** argv)
|
||||
{
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
StringView socket_path = "/tmp/wind.sock";
|
||||
StringView user;
|
||||
|
||||
@ -105,7 +108,14 @@ Result<int> 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<Window>(ui::Rect { rand() % screen.canvas().width, rand() % screen.canvas().height,
|
||||
rand() % screen.canvas().width, rand() % screen.canvas().height },
|
||||
ui::Color::from_rgb(static_cast<u8>(rand() % 256), static_cast<u8>(rand() % 256),
|
||||
static_cast<u8>(rand() % 256)),
|
||||
strerror(packet.key)));
|
||||
}
|
||||
}
|
||||
if (fds[2].revents & POLLIN)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user