added borders

This commit is contained in:
vaxerski 2022-03-19 16:13:19 +01:00
parent 61e10e2048
commit 9e735ad2f5
5 changed files with 46 additions and 2 deletions

View file

@ -10,4 +10,6 @@ general {
gaps_in=5 gaps_in=5
gaps_out=20 gaps_out=20
border_size=1 border_size=1
col.active_border=0x66ee1111
col.inactive_border=0x66333333
} }

View file

@ -15,6 +15,8 @@ CConfigManager::CConfigManager() {
configValues["general:border_size"].intValue = 1; configValues["general:border_size"].intValue = 1;
configValues["general:gaps_in"].intValue = 5; configValues["general:gaps_in"].intValue = 5;
configValues["general:gaps_out"].intValue = 20; configValues["general:gaps_out"].intValue = 20;
configValues["general:col.active_border"].intValue = 0xffffffff;
configValues["general:col.inactive_border"].intValue = 0xff444444;
} }
void CConfigManager::init() { void CConfigManager::init() {
@ -216,7 +218,7 @@ void CConfigManager::loadConfigLoadVars() {
void CConfigManager::tick() { void CConfigManager::tick() {
const char* const ENVHOME = getenv("HOME"); 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; struct stat fileStat;
int err = stat(CONFIGPATH.c_str(), &fileStat); int err = stat(CONFIGPATH.c_str(), &fileStat);

View file

@ -15,4 +15,9 @@
#define interface class #define interface class
#define STICKS(a, b) abs((a) - (b)) < 2 #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)

View file

@ -59,6 +59,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
continue; continue;
// render the bad boy // 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); 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}; 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; continue;
// render the bad boy // 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); 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}; 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) for (auto& la : PMONITOR->m_aLayerSurfaceLists)
arrangeLayerArray(PMONITOR, la); 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);
} }

View file

@ -3,6 +3,7 @@
#include "../defines.hpp" #include "../defines.hpp"
#include <list> #include <list>
#include "../helpers/Monitor.hpp" #include "../helpers/Monitor.hpp"
#include "../Window.hpp"
class CHyprRenderer { class CHyprRenderer {
public: public:
@ -13,6 +14,7 @@ public:
private: private:
void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&); void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&);
void drawBorderForWindow(CWindow*, SMonitor*);
}; };
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer; inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;