diff options
Diffstat (limited to 'src/kernel/window.c')
-rw-r--r-- | src/kernel/window.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/kernel/window.c b/src/kernel/window.c index 9487211..b1d5f92 100644 --- a/src/kernel/window.c +++ b/src/kernel/window.c @@ -272,6 +272,17 @@ static void paint_all() { paint_and_above(bottom_window); } +static void send_action(struct window *w, struct window_action packet) { + struct window_action *next_next = w->next_action_write + 1; + if (next_next >= AB_END(w->action_buffer)) + next_next = w->action_buffer; + if (next_next != w->next_action_read) { + *(w->next_action_write) = packet; + w->next_action_write = next_next; + unwait(w->from_task, (struct wait){.mode = WINDOW_ACTION}); + } +} + struct window *new_window(uint16_t width, uint16_t height, const struct pixel *pixel_buffer) { if (!pixel_buffer) { logf(LOG_WARN, "Refusing to create window with null pixel buffer for task %s.", active_task->name); @@ -298,14 +309,18 @@ got_window: w->next_action_read = ab; w->next_action_write = ab; - if (top_window) + if (top_window) { + send_action(top_window, (struct window_action){.action_type = FOCUS_LEAVE}); top_window->above = w; + } else bottom_window = w; w->above = 0; w->below = top_window; top_window = w; + send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER}); + w->from_task = active_task; paint_and_above(w); @@ -313,8 +328,10 @@ got_window: } static void del_no_paint(struct window *w) { - if (w == top_window) + if (w == top_window) { top_window = w->below; + send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER}); + } if (w == bottom_window) bottom_window = w->above; if (w->below) @@ -384,17 +401,6 @@ struct window_action next_window_action(struct window *w) { return *action; } -static void send_action(struct window *w, struct window_action packet) { - struct window_action *next_next = w->next_action_write + 1; - if (next_next >= AB_END(w->action_buffer)) - next_next = w->action_buffer; - if (next_next != w->next_action_read) { - *(w->next_action_write) = packet; - w->next_action_write = next_next; - unwait(w->from_task, (struct wait){.mode = WINDOW_ACTION}); - } -} - #define RUN_COMMAND_FILE "sys/winspace.rc" enum wm_action { |