summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-19 16:13:19 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-19 16:13:19 +0100
commit9e735ad2f5c1c7e29a2f27e2be2a1daa5bf8cc8c (patch)
tree9d285a1ba41d5201b8fa633483747594afb57e22 /src
parent61e10e20484e8867656d39cbaa6d75c3aab7eba6 (diff)
added borders
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp4
-rw-r--r--src/defines.hpp7
-rw-r--r--src/render/Renderer.cpp33
-rw-r--r--src/render/Renderer.hpp2
4 files changed, 44 insertions, 2 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 4cd9c007..f48f1dcd 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -15,6 +15,8 @@ CConfigManager::CConfigManager() {
configValues["general:border_size"].intValue = 1;
configValues["general:gaps_in"].intValue = 5;
configValues["general:gaps_out"].intValue = 20;
+ configValues["general:col.active_border"].intValue = 0xffffffff;
+ configValues["general:col.inactive_border"].intValue = 0xff444444;
}
void CConfigManager::init() {
@@ -216,7 +218,7 @@ void CConfigManager::loadConfigLoadVars() {
void CConfigManager::tick() {
const char* const ENVHOME = getenv("HOME");
- const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprd.conf" : (std::string) "/.config/hypr/hypr.conf");
+ const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
struct stat fileStat;
int err = stat(CONFIGPATH.c_str(), &fileStat);
diff --git a/src/defines.hpp b/src/defines.hpp
index 9c3856aa..d048c658 100644
--- a/src/defines.hpp
+++ b/src/defines.hpp
@@ -15,4 +15,9 @@
#define interface class
-#define STICKS(a, b) abs((a) - (b)) < 2 \ No newline at end of file
+#define STICKS(a, b) abs((a) - (b)) < 2
+
+#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
+#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
+#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
+#define BLUE(c) ((double)(((c)) & 0xff) / 255.0) \ No newline at end of file
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index aeb19008..96276c76 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -59,6 +59,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
continue;
// render the bad boy
+
+ // border
+ drawBorderForWindow(&w, PMONITOR);
+
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vRealPosition.x, &w.m_vRealPosition.y);
SRenderData renderdata = {PMONITOR->output, time, w.m_vRealPosition.x, w.m_vRealPosition.y};
@@ -81,6 +85,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
continue;
// render the bad boy
+
+ // border
+ drawBorderForWindow(&w, PMONITOR);
+
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vRealPosition.x, &w.m_vRealPosition.y);
SRenderData renderdata = {PMONITOR->output, time, w.m_vRealPosition.x, w.m_vRealPosition.y};
@@ -205,4 +213,29 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
for (auto& la : PMONITOR->m_aLayerSurfaceLists)
arrangeLayerArray(PMONITOR, la);
+}
+
+void CHyprRenderer::drawBorderForWindow(CWindow* pWindow, SMonitor* pMonitor) {
+ const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size");
+ const auto BORDERCOL = pWindow == g_pCompositor->m_pLastFocus ? g_pConfigManager->getInt("general:col.active_border") : g_pConfigManager->getInt("general:col.inactive_border");
+
+ const float BORDERWLRCOL[4] = {RED(BORDERCOL), GREEN(BORDERCOL), BLUE(BORDERCOL), ALPHA(BORDERCOL)};
+
+ // top
+ wlr_box border = {pWindow->m_vRealPosition.x - BORDERSIZE, pWindow->m_vRealPosition.y - BORDERSIZE, pWindow->m_vRealSize.x + 2 * BORDERSIZE, BORDERSIZE };
+ wlr_render_rect(g_pCompositor->m_sWLRRenderer, &border, BORDERWLRCOL, pMonitor->output->transform_matrix);
+
+ // bottom
+ border.y = pWindow->m_vRealPosition.y + pWindow->m_vRealSize.y;
+ wlr_render_rect(g_pCompositor->m_sWLRRenderer, &border, BORDERWLRCOL, pMonitor->output->transform_matrix);
+
+ // left
+ border.y = pWindow->m_vRealPosition.y;
+ border.width = BORDERSIZE;
+ border.height = pWindow->m_vRealSize.y;
+ wlr_render_rect(g_pCompositor->m_sWLRRenderer, &border, BORDERWLRCOL, pMonitor->output->transform_matrix);
+
+ // right
+ border.x = pWindow->m_vRealPosition.x + pWindow->m_vRealSize.x;
+ wlr_render_rect(g_pCompositor->m_sWLRRenderer, &border, BORDERWLRCOL, pMonitor->output->transform_matrix);
} \ No newline at end of file
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index 21a32975..b6172ce8 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -3,6 +3,7 @@
#include "../defines.hpp"
#include <list>
#include "../helpers/Monitor.hpp"
+#include "../Window.hpp"
class CHyprRenderer {
public:
@@ -13,6 +14,7 @@ public:
private:
void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&);
+ void drawBorderForWindow(CWindow*, SMonitor*);
};
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;