aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2021-03-28 14:01:53 +0200
committerMarvin Borner2021-03-28 14:01:53 +0200
commit60750501da4eb0c020e971b45ae3a964c903e12d (patch)
treefc95ff546a7acaa22327bd27dc098230f820c531 /apps
parentba2c07447ba1278d8ad38ca58a8ae94c82d2d008 (diff)
Fun with widgets
Diffstat (limited to 'apps')
-rw-r--r--apps/window.c14
-rw-r--r--apps/wm.c1
2 files changed, 15 insertions, 0 deletions
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 <libgui/gui.h>
#include <print.h>
+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));
}