/
SilovAndrey
/
LotShell
Обзор
Документация
Войти
/
SilovAndrey
/
LotShell
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main.cpp
122 строки
4 KB
Andrey HomePC
output.cpp update
2 часа назад
2 часа назад
ed502b1
Код
Авторство
О чём код?
// src/main.cpp — точка входа #include <memory> #include <vector> #include <algorithm> #include <stdexcept> #include <easel/wayland/egl_backend.h> #include <easel/wayland/output.h> #include <easel/wayland/logger.h> #include "platform/panel.hpp" #include "modules/clock/clock.hpp" #include "modules/battery/battery.hpp" #include "modules/network/network.hpp" #include "core/lockfree_queue.hpp" #include "core/timer_engine.hpp" #include "ui/panel_manager.hpp" #include "wayland/wayland_setup.hpp" #include "modules/clock/clock_messages.hpp" #include <iostream> #include <thread> #include <atomic> #include <csignal> #include <chrono> #include <cstring> using namespace mvu; using namespace ui; // ============================================================================ // ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ // ============================================================================ std::atomic<bool> running{true}; void signal_handler(int sig) { running = false; } // ============================================================================ // ПОЛУЧЕНИЕ ТЕКУЩЕГО ВРЕМЕНИ // ============================================================================ clock_module::Tick get_current_time() { std::time_t now = std::time(nullptr); std::tm* tm = std::localtime(&now); char time_buf[16]; char date_buf[16]; std::strftime(time_buf, sizeof(time_buf), "%H:%M:%S", tm); std::strftime(date_buf, sizeof(date_buf), "%d.%m.%Y", tm); clock_module::Tick tick; tick.time_string = time_buf; tick.date_string = date_buf; tick.timestamp = now; return tick; } int main() { try { auto loop = WL::init_egl_display<Lot::Panel, WL::Output>(); if (tvg::Initializer::init(/*threads=*/4) != tvg::Result::Success) { throw std::runtime_error("Failed to initialize ThorVG"); } // 4. MVU компоненты LockFreeQueue queue; TimerEngine timer_engine(&queue); PanelManager panel_manager(&queue); panel_manager.set_on_quit([]() { running = false; std::cout << "\n🔴 Shutting down..." << std::endl; }); // 5. Регистрируем модуль ElementId clock_id = panel_manager.register_module<clock_module::ClockModule>(); auto& screen = WL::Display::connection().get_global<WL::Output>(); auto n = screen.size(); if (n > 0){ //Для прстоты добавляем панель на каждый экран screen.onCreated([&panel_manager, clock_id](wl_output* ptr, WL::OutputInfo& info) { // Создаем панель ElementId panel_id = panel_manager.create_panel(ptr); // Добавляем модуль на панель panel_manager.add_module_to_panel(panel_id, clock_id); // Подписываемся на закрытие auto* panel = panel_manager.get_panel(panel_id); if (panel) { panel->onClosed = [&panel_manager, panel_id]() { panel_manager.remove_panel(panel_id); WL::log_info("Panel closed: %d", panel_id); }; } }); loop.run(); } tvg::Initializer::term(); } catch (std::runtime_error const& e) { WL::log_error("Fatal error: %s", e.what()); return 1; } return 0; }