mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-10-30 22:12:00 +00:00
added borders
This commit is contained in:
parent
61e10e2048
commit
9e735ad2f5
@ -10,4 +10,6 @@ general {
|
||||
gaps_in=5
|
||||
gaps_out=20
|
||||
border_size=1
|
||||
col.active_border=0x66ee1111
|
||||
col.inactive_border=0x66333333
|
||||
}
|
@ -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);
|
||||
|
@ -15,4 +15,9 @@
|
||||
|
||||
#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)
|
@ -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);
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user