wind: Generate random windows on keypresses
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
ec256e058d
commit
4cbdea954a
@ -11,10 +11,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
Result<int> luna_main(int argc, char** argv)
|
Result<int> luna_main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
srand((unsigned)time(NULL));
|
||||||
|
|
||||||
StringView socket_path = "/tmp/wind.sock";
|
StringView socket_path = "/tmp/wind.sock";
|
||||||
StringView user;
|
StringView user;
|
||||||
|
|
||||||
@ -105,7 +108,14 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
moon::KeyboardPacket packet;
|
moon::KeyboardPacket packet;
|
||||||
TRY(keyboard->read_typed(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)
|
if (fds[2].revents & POLLIN)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user