Compare commits
No commits in common. "8b1632f443b164709d78290683239b2e1f8c8e08" and "b95d495815fe18177c60feb796f096da25fea00d" have entirely different histories.
8b1632f443
...
b95d495815
@ -1,24 +1,15 @@
|
||||
#include <os/Process.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <ui/App.h>
|
||||
#include <ui/Button.h>
|
||||
#include <ui/Container.h>
|
||||
#include <ui/Image.h>
|
||||
#include <ui/Layout.h>
|
||||
|
||||
void sigchld_handler(int)
|
||||
{
|
||||
wait(nullptr);
|
||||
}
|
||||
|
||||
Result<int> luna_main(int argc, char** argv)
|
||||
{
|
||||
ui::App app;
|
||||
TRY(app.init(argc, argv));
|
||||
|
||||
signal(SIGCHLD, sigchld_handler);
|
||||
|
||||
ui::Rect screen = app.screen_rect();
|
||||
|
||||
ui::Rect bar = ui::Rect { ui::Point { 0, screen.height - 50 }, screen.width, 50 };
|
||||
|
@ -102,7 +102,7 @@ namespace os
|
||||
{
|
||||
u8 response_id;
|
||||
auto rc = client.recv_typed(response_id);
|
||||
if (rc.has_error() && (rc.error() == EAGAIN || rc.error() == EINTR)) continue;
|
||||
if (rc.has_error() && rc.error() == EAGAIN) continue;
|
||||
|
||||
if (response_id == 0) // Error result
|
||||
{
|
||||
@ -110,7 +110,7 @@ namespace os
|
||||
{
|
||||
int code;
|
||||
rc = client.recv_typed(code);
|
||||
if (rc.has_error() && (rc.error() == EAGAIN || rc.error() == EINTR)) continue;
|
||||
if (rc.has_error() && rc.error() == EAGAIN) continue;
|
||||
return err(code);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ namespace os
|
||||
{
|
||||
ResponseType response;
|
||||
rc = client.recv_typed(response);
|
||||
if (rc.has_error() && (rc.error() == EAGAIN || rc.error() == EINTR)) continue;
|
||||
if (rc.has_error() && rc.error() == EAGAIN) continue;
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ namespace os::IPC
|
||||
if (rc.has_error())
|
||||
{
|
||||
if (rc.error() == EAGAIN) return {}; // No messages, and the caller does not want us to block.
|
||||
if (rc.error() == EINTR)
|
||||
return {}; // Let the caller check for anything having happened because a signal handler ran.
|
||||
return rc.release_error();
|
||||
}
|
||||
|
||||
@ -33,8 +31,6 @@ namespace os::IPC
|
||||
if (rc.has_error())
|
||||
{
|
||||
if (rc.error() == EAGAIN) return {}; // No messages, and the caller does not want us to block.
|
||||
if (rc.error() == EINTR)
|
||||
return {}; // Let the caller check for anything having happened because a signal handler ran.
|
||||
return rc.release_error();
|
||||
}
|
||||
|
||||
|
@ -88,26 +88,13 @@ namespace ui
|
||||
return window->ptr();
|
||||
}
|
||||
|
||||
#define READ_MESSAGE(request) \
|
||||
do { \
|
||||
auto rc = m_client->recv_typed(request); \
|
||||
if (rc.has_error()) \
|
||||
{ \
|
||||
if (rc.error() == EAGAIN) { continue; } \
|
||||
if (rc.error() == EINTR) { continue; } \
|
||||
else \
|
||||
return rc.release_error(); \
|
||||
} \
|
||||
break; \
|
||||
} while (true)
|
||||
|
||||
Result<void> App::handle_ipc_event(u8 id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case WINDOW_CLOSE_REQUEST_ID: {
|
||||
WindowCloseRequest request;
|
||||
READ_MESSAGE(request);
|
||||
TRY(m_client->recv_typed(request));
|
||||
os::eprintln("ui: Window close request from server! Shall comply.");
|
||||
auto* window = find_window(request.window);
|
||||
window->close();
|
||||
@ -115,7 +102,7 @@ namespace ui
|
||||
}
|
||||
case MOUSE_EVENT_REQUEST_ID: {
|
||||
MouseEventRequest request;
|
||||
READ_MESSAGE(request);
|
||||
TRY(m_client->recv_typed(request));
|
||||
auto* window = find_window(request.window);
|
||||
window->handle_mouse_move(request.position);
|
||||
window->handle_mouse_buttons(request.position, request.buttons);
|
||||
|
@ -68,12 +68,6 @@ static Result<u32*> create_shm_region(const char* path, int* outfd, ui::Rect rec
|
||||
client.rpc_id = decltype(request)::ID; \
|
||||
return {}; \
|
||||
} \
|
||||
if (rc.error() == EINTR) \
|
||||
{ \
|
||||
client.rpc_in_progress = true; \
|
||||
client.rpc_id = decltype(request)::ID; \
|
||||
return {}; \
|
||||
} \
|
||||
else \
|
||||
return rc.release_error(); \
|
||||
} \
|
||||
@ -208,7 +202,6 @@ namespace wind
|
||||
if (rc.has_error())
|
||||
{
|
||||
if (rc.error() == EAGAIN) { return {}; }
|
||||
if (rc.error() == EINTR) { return {}; }
|
||||
else
|
||||
return rc.release_error();
|
||||
}
|
||||
|
@ -18,34 +18,6 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void debug(const Vector<Client>& 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<int> luna_main(int argc, char** argv)
|
||||
{
|
||||
srand((unsigned)time(NULL));
|
||||
@ -119,7 +91,7 @@ Result<int> 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 exec", NULL));
|
||||
TRY(os::Security::pledge("stdio rpath wpath cpath unix signal proc", NULL));
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -145,7 +117,6 @@ Result<int> 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++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user