diff options
Diffstat (limited to 'apps/wm.c')
-rw-r--r-- | apps/wm.c | 49 |
1 files changed, 27 insertions, 22 deletions
@@ -88,7 +88,7 @@ static void kill_focused() { if (!focused) return; - msg_send(focused->pid, GUI_KILL, NULL); + //msg_send(focused->pid, GUI_KILL, NULL); remove_context(focused); focused = context_at(mouse_x, mouse_y); } @@ -162,7 +162,7 @@ static void handle_keyboard(struct event_keyboard *event) msg->press = event->press; msg->scancode = event->scancode; - msg_send(focused->pid, GUI_KEYBOARD, msg); + //msg_send(focused->pid, GUI_KEYBOARD, msg); } static int mouse_skip = 0; @@ -237,7 +237,7 @@ static void handle_mouse(struct event_mouse *event) focused = resized; struct gui_event_resize *msg = malloc(sizeof(*msg)); msg->new_ctx = resized; - msg_send(resized->pid, GUI_RESIZE, msg); + //msg_send(resized->pid, GUI_RESIZE, msg); redraw_all(); } } @@ -255,7 +255,7 @@ static void handle_mouse(struct event_mouse *event) msg->but1 = event->but1; msg->but2 = event->but2; msg->but3 = event->but3; - msg_send(focused->pid, GUI_MOUSE, msg); + //msg_send(focused->pid, GUI_MOUSE, msg); } // TODO: Clean this god-function @@ -285,36 +285,47 @@ int main(int argc, char **argv) gfx_load_image(&cursor, "/res/cursor.png", 0, 0); redraw_all(); - event_register(EVENT_MOUSE); - event_register(EVENT_KEYBOARD); - - struct message *msg; + struct message msg = { 0 }; + struct event_keyboard kbd_event = { 0 }; + struct event_mouse mouse_event = { 0 }; while (1) { - if (!(msg = msg_receive())) { + if (read("/dev/kbd", &kbd_event, 0, sizeof(struct event_keyboard))) + handle_keyboard(&kbd_event); + /* else if (read("/dev/mouse", &mouse_event, 0, sizeof(struct event_mouse))) */ + /* handle_mouse(&mouse_event); */ + /* else if (msg_receive(&msg)) { */ + /* handle_message(&msg); */ + /* } */ + else { yield(); continue; } - switch (msg->type) { + //if (!msg_receive(&msg)) { + yield(); + continue; + //} + + switch (msg.type) { case GFX_NEW_CONTEXT: { - struct context *ctx = msg->data; + struct context *ctx = msg.data; int width = ctx->width; int height = ctx->height; int x = ctx->x; int y = ctx->y; - ctx->pid = msg->src; - new_context(ctx, msg->src, x, y, width, height, ctx->flags); + ctx->pid = msg.src; + new_context(ctx, msg.src, x, y, width, height, ctx->flags); list_add(contexts, ctx); if (!(ctx->flags & WF_RELATIVE)) focused = ctx; redraw_all(); - msg_send(msg->src, GFX_NEW_CONTEXT, ctx); + //msg_send(msg.src, GFX_NEW_CONTEXT, ctx); // Send mouse position - struct gui_event_mouse *mouse = malloc(sizeof(*msg)); + struct gui_event_mouse *mouse = malloc(sizeof(msg)); mouse->x = mouse_x - focused->x; mouse->y = mouse_y - focused->y; - msg_send(focused->pid, GUI_MOUSE, mouse); + //msg_send(focused->pid, GUI_MOUSE, mouse); break; } case GFX_REDRAW: @@ -323,12 +334,6 @@ int main(int argc, char **argv) case GFX_REDRAW_FOCUSED: redraw_focused(); break; - case EVENT_MOUSE: - handle_mouse(msg->data); - break; - case EVENT_KEYBOARD: - handle_keyboard(msg->data); - break; default: break; } |