summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/idt.c3
-rw-r--r--src/kernel/isrs.asm2
-rw-r--r--src/kernel/window.c16
-rw-r--r--src/kernel/window.h2
4 files changed, 21 insertions, 2 deletions
diff --git a/src/kernel/idt.c b/src/kernel/idt.c
index f07ef1d..8de5448 100644
--- a/src/kernel/idt.c
+++ b/src/kernel/idt.c
@@ -208,7 +208,8 @@ void const *syscall_table[] = {
&sc_is_task_running,
&sc_get_timestamp,
&sc_file_write,
- &sc_file_set_size
+ &sc_file_set_size,
+ &window_wants_mouse_movements
};
//these aren't really void ()'s, but gcc complains if we take an address of a void, so we give it a type
diff --git a/src/kernel/isrs.asm b/src/kernel/isrs.asm
index 70bab19..673e891 100644
--- a/src/kernel/isrs.asm
+++ b/src/kernel/isrs.asm
@@ -26,7 +26,7 @@ extern exception_halt
extern pf_check_stack
extern dump
-n_syscalls equ 0x1c
+n_syscalls equ 0x1d
;section .bss
;_debug_is_start_task resb 1
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
diff --git a/src/kernel/window.h b/src/kernel/window.h
index a1f9716..a1d6be3 100644
--- a/src/kernel/window.h
+++ b/src/kernel/window.h
@@ -36,4 +36,6 @@ void show_shutdown();
void move_mouse_by(int16_t y, int16_t x);
void mouse_button(enum mouse_button which, bool up);
+void window_wants_mouse_movements(struct window *w);
+
#endif