diff options
Diffstat (limited to 'src/kernel/window.c')
-rw-r--r-- | src/kernel/window.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/kernel/window.c b/src/kernel/window.c index b1d5f92..4b01bc4 100644 --- a/src/kernel/window.c +++ b/src/kernel/window.c @@ -38,6 +38,7 @@ static struct window { struct window *below; struct task_state *from_task; + bool wants_mouse_movements; } windows[MAX_WINDOWS]; static struct window *bottom_window = 0; @@ -322,6 +323,7 @@ got_window: send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER}); w->from_task = active_task; + w->wants_mouse_movements = false; paint_and_above(w); return w; @@ -544,6 +546,16 @@ void move_mouse_by(int16_t y, int16_t x) { blit(old_x, old_x + MOUSE_WIDTH > VBE_MODE_INFO->width ? VBE_MODE_INFO->width : old_x + MOUSE_WIDTH, old_y, old_y + MOUSE_HEIGHT > VBE_MODE_INFO->height ? VBE_MODE_INFO->height : old_y + MOUSE_HEIGHT); blit_mouse(); + struct window *const moving_over = buffer[mouse_y * VBE_MODE_INFO->width + mouse_x].from_window; + if (moving_over && moving_over->wants_mouse_movements && + (mouse_y >= moving_over->ypos) && (mouse_y < moving_over->ypos + moving_over->height) && + (mouse_x >= moving_over->xpos) && (mouse_x < moving_over->xpos + moving_over->width)) + send_action(moving_over, (struct window_action){ + .action_type = MOUSE_MOVE, .moved_to = { + .x = mouse_x - moving_over->xpos, + .y = mouse_y - moving_over->ypos + } + }); } switch_to_task_cr3(); //logf(LOG_INFO, "new mouse coords: (%d, %d)", mouse_x, mouse_y); @@ -628,4 +640,8 @@ void mouse_button(enum mouse_button which, bool up) { } send_action(clicked_on, (struct window_action){.action_type = up ? MOUSE_UP : MOUSE_DOWN, .as_mouse = {.y = mouse_y - clicked_on->ypos, .x = mouse_x - clicked_on->xpos, .which = which}}); } +} + +void window_wants_mouse_movements(struct window *w) { + w->wants_mouse_movements = true; }
\ No newline at end of file |