From a4ef84d987120707f0cda9cb21068ce1c0285cd2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 17 Mar 2022 17:08:54 +0100 Subject: [PATCH] it now actually runs lol --- src/Compositor.cpp | 26 ++++++++++++++++---------- src/ManagerThread.cpp | 3 +++ src/config/ConfigManager.cpp | 2 ++ src/config/ConfigManager.hpp | 1 + 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 552b58bd..6119a2a2 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -40,7 +40,7 @@ CCompositor::CCompositor() { m_sWLRXDGActivation - wlr_xdg_activation_v1_create(m_sWLDisplay); m_sWLROutputLayout = wlr_output_layout_create(); - wl_signal_add(&m_sWLRXDGActivation->events.request_activate, &Events::listen_activate); + // wl_signal_add(&m_sWLRXDGActivation->events.request_activate, &Events::listen_activate); wl_signal_add(&m_sWLROutputLayout->events.change, &Events::listen_change); wl_signal_add(&m_sWLRBackend->events.new_output, &Events::listen_newOutput); @@ -88,6 +88,21 @@ CCompositor::~CCompositor() { } void CCompositor::startCompositor() { + + // Init all the managers BEFORE we start with the wayland server so that ALL of the stuff is initialized + // properly and we dont get any bad mem reads. + // + Debug::log(LOG, "Creating the config manager!"); + g_pConfigManager = std::make_unique(); + + Debug::log(LOG, "Creating the ManagerThread!"); + g_pManagerThread = std::make_unique(); + + Debug::log(LOG, "Creating the InputManager!"); + g_pInputManager = std::make_unique(); + // + // + m_szWLDisplaySocket = wl_display_add_socket_auto(m_sWLDisplay); if (!m_szWLDisplaySocket) { @@ -108,15 +123,6 @@ void CCompositor::startCompositor() { wlr_xcursor_manager_set_cursor_image(m_sWLRXCursorMgr, "left_ptr", m_sWLRCursor); - Debug::log(LOG, "Creating the config manager!"); - g_pConfigManager = std::make_unique(); - - Debug::log(LOG, "Creating the ManagerThread!"); - g_pManagerThread = std::make_unique(); - - Debug::log(LOG, "Creating the InputManager!"); - g_pInputManager = std::make_unique(); - // This blocks until we are done. Debug::log(LOG, "Hyprland is ready, running the event loop!"); wl_display_run(m_sWLDisplay); diff --git a/src/ManagerThread.cpp b/src/ManagerThread.cpp index 8ddb3b53..6dfa46de 100644 --- a/src/ManagerThread.cpp +++ b/src/ManagerThread.cpp @@ -14,6 +14,9 @@ CManagerThread::~CManagerThread() { } void CManagerThread::handle() { + + g_pConfigManager->init(); + while (3.1415f) { g_pConfigManager->tick(); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 47255651..4cd9c007 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -15,7 +15,9 @@ CConfigManager::CConfigManager() { configValues["general:border_size"].intValue = 1; configValues["general:gaps_in"].intValue = 5; configValues["general:gaps_out"].intValue = 20; +} +void CConfigManager::init() { loadConfigLoadVars(); isFirstLaunch = false; diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index eda06044..b9c58900 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -26,6 +26,7 @@ public: CConfigManager(); void tick(); + void init(); int getInt(std::string); float getFloat(std::string);