summaryrefslogtreecommitdiff
path: root/src/kernel/window.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-02-17 09:11:39 -0500
committerBenji Dial <benji6283@gmail.com>2021-02-17 09:11:39 -0500
commit49d76d30a55707e2bf95fd9ba03296489fac8d1d (patch)
treeda8b7f9b0fcf5fbe7d8a84fbdf9f51d35c5dfe61 /src/kernel/window.c
parent642c3c69a69220170e2f68c2bf6c898e6cb5b20b (diff)
downloadportland-os-49d76d30a55707e2bf95fd9ba03296489fac8d1d.tar.gz
making win+space work when no tasks are running
Diffstat (limited to 'src/kernel/window.c')
-rw-r--r--src/kernel/window.c97
1 files changed, 52 insertions, 45 deletions
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