From 49d76d30a55707e2bf95fd9ba03296489fac8d1d Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 17 Feb 2021 09:11:39 -0500 Subject: making win+space work when no tasks are running --- src/kernel/window.c | 97 ++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'src/kernel/window.c') diff --git a/src/kernel/window.c b/src/kernel/window.c index c251077..74273fb 100644 --- a/src/kernel/window.c +++ b/src/kernel/window.c @@ -289,63 +289,70 @@ void on_action(struct window_action packet) { if (packet.action_type == NOT_READY) return; - if (top_window) { - if (packet.action_type == KEY_DOWN) - for (uint8_t i = 0; i < N_WM_ACTIONS; ++i) - if (fuzzy_key_match(keybinds[i], packet.as_key)) { - switch_to_kernel_cr3(); - struct window *old_top, *old_bottom; - switch (i) { - case WM_SHUFFLE_UP: - if (!top_window->below) - break; - old_top = top_window; - old_bottom = bottom_window; - top_window = old_top->below; - top_window->above = 0; - old_top->below = 0; - old_top->above = old_bottom; - old_bottom->below = old_top; - bottom_window = old_top; - paint_and_above(bottom_window->above); + if (packet.action_type == KEY_DOWN) + for (uint8_t i = 0; i < N_WM_ACTIONS; ++i) + if (fuzzy_key_match(keybinds[i], packet.as_key)) { + switch_to_kernel_cr3(); + struct window *old_top, *old_bottom; + switch (i) { + case WM_SHUFFLE_UP: + if (!top_window || !top_window->below) break; - case WM_SHUFFLE_DOWN: - if (!top_window->below) - break; - old_top = top_window; - old_bottom = bottom_window; - bottom_window = old_bottom->above; - bottom_window->below = 0; - old_bottom->above = 0; - old_bottom->below = old_top; - old_top->above = old_bottom; - top_window = old_bottom; - paint_and_above(top_window); + old_top = top_window; + old_bottom = bottom_window; + top_window = old_top->below; + top_window->above = 0; + old_top->below = 0; + old_top->above = old_bottom; + old_bottom->below = old_top; + bottom_window = old_top; + paint_and_above(bottom_window->above); + break; + case WM_SHUFFLE_DOWN: + if (!top_window || !top_window->below) break; - case WM_MOVE_LEFT: + old_top = top_window; + old_bottom = bottom_window; + bottom_window = old_bottom->above; + bottom_window->below = 0; + old_bottom->above = 0; + old_bottom->below = old_top; + old_top->above = old_bottom; + top_window = old_bottom; + paint_and_above(top_window); + break; + case WM_MOVE_LEFT: + if (top_window) { --top_window->xpos; paint_all(); - break; - case WM_MOVE_RIGHT: + } + break; + case WM_MOVE_RIGHT: + if (top_window) { ++top_window->xpos; paint_all(); - break; - case WM_MOVE_UP: + } + break; + case WM_MOVE_UP: + if (top_window) { --top_window->ypos; paint_all(); - break; - case WM_MOVE_DOWN: + } + break; + case WM_MOVE_DOWN: + if (top_window) { ++top_window->ypos; paint_all(); - break; - case WM_RUN_COMMAND: - if (!try_elf_run(drives, run_command, run_command_pass, 0)) - PANIC("Couldn't run program listed in " RUN_COMMAND_FILE "."); } - switch_to_task_cr3(); - return; + break; + case WM_RUN_COMMAND: + if (!try_elf_run(drives, run_command, run_command_pass, 0)) + PANIC("Couldn't run program listed in " RUN_COMMAND_FILE "."); } + switch_to_task_cr3(); + return; + } + if (top_window) send_action(top_window, packet); - } } \ No newline at end of file -- cgit v1.2.3