From 60750501da4eb0c020e971b45ae3a964c903e12d Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 28 Mar 2021 14:01:53 +0200 Subject: Fun with widgets --- apps/window.c | 14 ++++++++++++++ apps/wm.c | 1 + 2 files changed, 15 insertions(+) (limited to 'apps') diff --git a/apps/window.c b/apps/window.c index 4dbf9dc..de397a9 100644 --- a/apps/window.c +++ b/apps/window.c @@ -4,10 +4,24 @@ #include #include +static void mousemove(vec2 pos) +{ + log("%d %d\n", pos.x, pos.y); +} + int main(void) { u32 win; assert((win = gui_new_window()) > 0); + + u32 main; + assert((main = gui_new_widget(win, gui_window_size(win), vec2(0, 0))) > 0); + + assert(gui_fill(win, main, COLOR_BLACK) == EOK); + assert(gui_redraw_widget(win, main) == EOK); + + assert(gui_listen_widget(win, main, GUI_LISTEN_MOUSEMOVE, (u32)mousemove) == EOK); + gui_loop(); return 0; } diff --git a/apps/wm.c b/apps/wm.c index e522fc2..52c5932 100644 --- a/apps/wm.c +++ b/apps/wm.c @@ -367,6 +367,7 @@ static void handle_event_mouse(struct event_mouse *event) struct message_mouse msg = { 0 }; msg.header.state = MSG_GO_ON; + msg.id = win->id; msg.pos = vec2_sub(mouse.pos, win->pos); msg_send(win->client.pid, GUI_MOUSE, &msg, sizeof(msg)); } -- cgit v1.2.3