Update border colors on config reload

This commit is contained in:
vaxerski 2022-05-26 21:23:13 +02:00
parent 795504dad0
commit 8a3ea54184
3 changed files with 32 additions and 11 deletions

View File

@ -427,11 +427,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
// we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window // we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window
if (windowValidMapped(PLASTWINDOW)) { if (windowValidMapped(PLASTWINDOW)) {
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(PLASTWINDOW); updateWindowBorderColor(PLASTWINDOW);
if (RENDERDATA.isBorderColor)
PLASTWINDOW->m_cRealBorderColor = RENDERDATA.borderColor;
else
PLASTWINDOW->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.inactive_border"));
if (PLASTWINDOW->m_bIsX11) { if (PLASTWINDOW->m_bIsX11) {
wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat); wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat);
@ -451,11 +447,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition.goalv(); const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition.goalv();
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y); wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y);
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow); updateWindowBorderColor(pWindow);
if (RENDERDATA.isBorderColor)
pWindow->m_cRealBorderColor = RENDERDATA.borderColor;
else
pWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.active_border"));
// Send an event // Send an event
g_pEventManager->postEvent(SHyprIPCEvent("activewindow", pWindow->m_szTitle)); g_pEventManager->postEvent(SHyprIPCEvent("activewindow", pWindow->m_szTitle));
@ -894,3 +886,24 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
return nullptr; return nullptr;
} }
void CCompositor::updateAllWindowsBorders() {
for (auto& w : m_lWindows) {
if (!w.m_bIsMapped)
continue;
updateWindowBorderColor(&w);
}
}
void CCompositor::updateWindowBorderColor(CWindow* pWindow) {
// optimization
static int64_t* ACTIVECOL = &g_pConfigManager->getConfigValuePtr("general:col.active_border")->intValue;
static int64_t* INACTIVECOL = &g_pConfigManager->getConfigValuePtr("general:col.inactive_border")->intValue;
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);
if (RENDERDATA.isBorderColor)
pWindow->m_cRealBorderColor = RENDERDATA.borderColor;
else
pWindow->m_cRealBorderColor = CColor(pWindow == m_pLastWindow ? *ACTIVECOL : *INACTIVECOL);
}

View File

@ -121,6 +121,8 @@ public:
bool isPointOnAnyMonitor(const Vector2D&); bool isPointOnAnyMonitor(const Vector2D&);
CWindow* getConstraintWindow(SMouse*); CWindow* getConstraintWindow(SMouse*);
SMonitor* getMonitorInDirection(const char&); SMonitor* getMonitorInDirection(const char&);
void updateAllWindowsBorders();
void updateWindowBorderColor(CWindow*);
private: private:
void initAllSignals(); void initAllSignals();

View File

@ -524,6 +524,9 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_lMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID);
// Update window border colors
g_pCompositor->updateAllWindowsBorders();
return retval; return retval;
} }
@ -700,6 +703,9 @@ void CConfigManager::loadConfigLoadVars() {
if (!isFirstLaunch) { if (!isFirstLaunch) {
m_bWantsMonitorReload = true; m_bWantsMonitorReload = true;
} }
// Update window border colors
g_pCompositor->updateAllWindowsBorders();
} }
void CConfigManager::tick() { void CConfigManager::tick() {