aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-05-26 21:23:13 +0200
committervaxerski <[email protected]>2022-05-26 21:23:13 +0200
commit8a3ea54184d123cec969e2e77c5bf87ec36befd3 (patch)
treeaa76b0a063f385e4c9000dbda4d2c141c9438e15
parent795504dad01e7d738f768315767523270e59ab54 (diff)
downloadHyprland-8a3ea54184d123cec969e2e77c5bf87ec36befd3.tar.gz
Hyprland-8a3ea54184d123cec969e2e77c5bf87ec36befd3.zip
Update border colors on config reload
-rw-r--r--src/Compositor.cpp33
-rw-r--r--src/Compositor.hpp2
-rw-r--r--src/config/ConfigManager.cpp8
3 files changed, 32 insertions, 11 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 82e2986e..40741d22 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -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
if (windowValidMapped(PLASTWINDOW)) {
- const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(PLASTWINDOW);
- if (RENDERDATA.isBorderColor)
- PLASTWINDOW->m_cRealBorderColor = RENDERDATA.borderColor;
- else
- PLASTWINDOW->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.inactive_border"));
+ updateWindowBorderColor(PLASTWINDOW);
if (PLASTWINDOW->m_bIsX11) {
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();
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y);
- const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);
- if (RENDERDATA.isBorderColor)
- pWindow->m_cRealBorderColor = RENDERDATA.borderColor;
- else
- pWindow->m_cRealBorderColor = CColor(g_pConfigManager->getInt("general:col.active_border"));
+ updateWindowBorderColor(pWindow);
// Send an event
g_pEventManager->postEvent(SHyprIPCEvent("activewindow", pWindow->m_szTitle));
@@ -894,3 +886,24 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
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);
+} \ No newline at end of file
diff --git a/src/Compositor.hpp b/src/Compositor.hpp
index fadc4c20..8a1a7750 100644
--- a/src/Compositor.hpp
+++ b/src/Compositor.hpp
@@ -121,6 +121,8 @@ public:
bool isPointOnAnyMonitor(const Vector2D&);
CWindow* getConstraintWindow(SMouse*);
SMonitor* getMonitorInDirection(const char&);
+ void updateAllWindowsBorders();
+ void updateWindowBorderColor(CWindow*);
private:
void initAllSignals();
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index efeb8660..659627b1 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -523,7 +523,10 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
// invalidate layouts jic
for (auto& m : g_pCompositor->m_lMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID);
-
+
+ // Update window border colors
+ g_pCompositor->updateAllWindowsBorders();
+
return retval;
}
@@ -700,6 +703,9 @@ void CConfigManager::loadConfigLoadVars() {
if (!isFirstLaunch) {
m_bWantsMonitorReload = true;
}
+
+ // Update window border colors
+ g_pCompositor->updateAllWindowsBorders();
}
void CConfigManager::tick() {