From ed826069e09454776cecfc88de27afdb7fd96c5c Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 16 Aug 2023 16:48:55 +0200 Subject: [PATCH] wind: Add debug keybind --- wind/main.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/wind/main.cpp b/wind/main.cpp index 0dd625dc..419feb1e 100644 --- a/wind/main.cpp +++ b/wind/main.cpp @@ -18,6 +18,34 @@ #include #include +static void debug(const Vector& clients) +{ + os::println("--- wind: DEBUG OUTPUT ---"); + + os::println("-- wind: Listing clients --"); + + for (const auto& client : clients) + { + os::println("Client with fd %d, owns %zu windows", client.conn.fd(), client.windows.size()); + } + + os::println("-- wind: Listing windows --"); + + for (const auto& window : g_windows) + { + os::println("Window of client (fd %d), id %d, %sdecorated, %sdirty (\"%s\") (%d,%d,%d,%d)", + window->client->conn.fd(), window->id, window->decorated ? "" : "not ", window->dirty ? "" : "not ", + window->name.chars(), window->surface.pos.x, window->surface.pos.y, window->surface.width, + window->surface.height); + } + + os::println("-- wind: Listing processes --"); + + system("ps"); + + os::println("--- wind: END DEBUG OUTPUT ---"); +} + Result luna_main(int argc, char** argv) { srand((unsigned)time(NULL)); @@ -91,7 +119,7 @@ Result luna_main(int argc, char** argv) TRY(fds.try_append({ .fd = keyboard->fd(), .events = POLLIN, .revents = 0 })); TRY(fds.try_append({ .fd = server->fd(), .events = POLLIN, .revents = 0 })); - TRY(os::Security::pledge("stdio rpath wpath cpath unix signal proc", NULL)); + TRY(os::Security::pledge("stdio rpath wpath cpath unix signal proc exec", NULL)); while (1) { @@ -117,6 +145,7 @@ Result luna_main(int argc, char** argv) moon::KeyboardPacket packet; TRY(keyboard->read_typed(packet)); os::println("%s key %d", packet.released ? "Released" : "Pressed", packet.key); + if (!packet.released && packet.key == moon::K_Tab) debug(clients); } for (usize i = 0; i < clients.size(); i++) {