From 52b9337d0624a0d9f641ed24990617c6c6a7865d Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 21 Dec 2025 20:58:41 +0100 Subject: [PATCH] You can now open minimized programs. --- Desktop_Test/helpers.cpp | 8 ++++---- Desktop_Test/helpers.h | 2 +- Desktop_Test/program.cpp | 2 +- Desktop_Test/shell.cpp | 30 +++++++++++++++++------------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Desktop_Test/helpers.cpp b/Desktop_Test/helpers.cpp index 485f847..664903a 100644 --- a/Desktop_Test/helpers.cpp +++ b/Desktop_Test/helpers.cpp @@ -1,13 +1,13 @@ #include "helpers.h" -void Helpers::recalculate_taskbar(std::vector* task_bar_items) { - for (size_t i = 0; i < task_bar_items->size(); ++i) { - auto& item = (*task_bar_items)[i]; +void Helpers::recalculate_taskbar(std::vector& task_bar_items) { + for (size_t i = 0; i < task_bar_items.size(); ++i) { + TaskBarItem item = task_bar_items[i]; if (i == 0) { item.place_x = 60; } else { - const TaskBarItem& prev = (*task_bar_items)[i - 1]; + const TaskBarItem& prev = task_bar_items[i - 1]; item.place_x = prev.place_x + prev.offset_x; } } diff --git a/Desktop_Test/helpers.h b/Desktop_Test/helpers.h index b6d2e5f..fd27592 100644 --- a/Desktop_Test/helpers.h +++ b/Desktop_Test/helpers.h @@ -4,5 +4,5 @@ #include struct Helpers { - static void recalculate_taskbar(std::vector* task_bar_items); + static void recalculate_taskbar(std::vector& task_bar_items); }; \ No newline at end of file diff --git a/Desktop_Test/program.cpp b/Desktop_Test/program.cpp index 93717a9..8874ad1 100644 --- a/Desktop_Test/program.cpp +++ b/Desktop_Test/program.cpp @@ -24,7 +24,7 @@ void Program::loop(void* pvParameters) { Program* self = static_cast(pvParameters); for(;;) { - self->_display_state->update_display.store(true); + //self->_display_state->update_display.store(true); vTaskDelay(500); } } \ No newline at end of file diff --git a/Desktop_Test/shell.cpp b/Desktop_Test/shell.cpp index a802b8b..b65eef2 100644 --- a/Desktop_Test/shell.cpp +++ b/Desktop_Test/shell.cpp @@ -2,6 +2,7 @@ #include "GLOBALS.h" #include #include "system_manager.h" +#include "helpers.h" void Shell::init(TFT_Handler* th, DISPLAY_STATE* ds, SystemManager* system_manager) { tft = th; @@ -114,19 +115,7 @@ void Shell::close_window(int window_id) { } } - for (int i = 0; i < task_bar_items.size(); ++i) { - TaskBarItem item = task_bar_items[i]; - - if (i == 0) { - item.place_x = 60; - } else { - // For subsequent items, use the previous item's position + offset - const TaskBarItem& prev = task_bar_items.back(); - item.place_x = prev.place_x + prev.offset_x; - } - - task_bar_items[i] = item; - } + Helpers::recalculate_taskbar(task_bar_items); } void Shell::minimize_window(int window_id) { @@ -341,6 +330,21 @@ int Shell::handle_desktop_click(CLICK_EVENT event) { } int Shell::handle_taskbar_click(CLICK_EVENT event) { + for (int i = 0; i < task_bar_items.size(); ++i) { + if (event.x >= task_bar_items[i].place_x && event.x <= (task_bar_items[i].place_x + task_bar_items[i].width) && event.y >= task_bar_items[i].place_y && event.y <= (task_bar_items[i].place_y + task_bar_items[i].height)) { + for (int j = 0; j < windows.size(); ++j) { + if (windows[j]->id == task_bar_items[i].id) { + for (int k = 0; k < windows.size(); ++k) windows[k]->focused = false; + windows[j]->focused = true; + windows[j]->minimized = false; + } + } + + for (int l = 0; l < task_bar_items.size(); ++l) task_bar_items[l].focused = false; + task_bar_items[i].focused = true; + return task_bar_items[i].id; + } + } return -1; }