mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2024-11-21 18:25:58 +01:00
all: chase hyprland
This commit is contained in:
parent
8b0f67a8a6
commit
97e9d252ff
11 changed files with 105 additions and 92 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "globals.hpp"
|
||||
|
||||
CBordersPlusPlus::CBordersPlusPlus(CWindow* pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
CBordersPlusPlus::CBordersPlusPlus(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.value();
|
||||
m_vLastWindowSize = pWindow->m_vRealSize.value();
|
||||
}
|
||||
|
@ -37,9 +37,8 @@ SDecorationPositioningInfo CBordersPlusPlus::getPositioningInfo() {
|
|||
|
||||
info.desiredExtents = {{size, size}, {size, size}};
|
||||
m_fLastThickness = size;
|
||||
} else {
|
||||
} else
|
||||
info.desiredExtents = {{m_fLastThickness, m_fLastThickness}, {m_fLastThickness, m_fLastThickness}};
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -61,10 +60,12 @@ std::string CBordersPlusPlus::getDisplayName() {
|
|||
}
|
||||
|
||||
void CBordersPlusPlus::draw(CMonitor* pMonitor, float a) {
|
||||
if (!g_pCompositor->windowValidMapped(m_pWindow))
|
||||
if (!validMapped(m_pWindow))
|
||||
return;
|
||||
|
||||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (!PWINDOW->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
static std::vector<Hyprlang::INT* const*> PCOLORS;
|
||||
|
@ -81,22 +82,17 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a) {
|
|||
if (**PBORDERS < 1)
|
||||
return;
|
||||
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
const auto PWORKSPACE = PWINDOW->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
|
||||
auto rounding = m_pWindow->rounding() == 0 ? 0 : m_pWindow->rounding() * pMonitor->scale + **PBORDERSIZE;
|
||||
const auto ORIGINALROUND = rounding == 0 ? 0 : m_pWindow->rounding() * pMonitor->scale + **PBORDERSIZE;
|
||||
auto rounding = PWINDOW->rounding() == 0 ? 0 : PWINDOW->rounding() * pMonitor->scale + **PBORDERSIZE;
|
||||
const auto ORIGINALROUND = rounding == 0 ? 0 : PWINDOW->rounding() * pMonitor->scale + **PBORDERSIZE;
|
||||
CBox fullBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
|
||||
|
||||
fullBox.translate(m_pWindow->m_vFloatingOffset - pMonitor->vecPosition + WORKSPACEOFFSET).scale(pMonitor->scale);
|
||||
fullBox.translate(PWINDOW->m_vFloatingOffset - pMonitor->vecPosition + WORKSPACEOFFSET).scale(pMonitor->scale).expand(**PBORDERSIZE * pMonitor->scale);
|
||||
|
||||
double fullThickness = 0;
|
||||
|
||||
fullBox.x -= **PBORDERSIZE * pMonitor->scale;
|
||||
fullBox.y -= **PBORDERSIZE * pMonitor->scale;
|
||||
fullBox.width += **PBORDERSIZE * 2 * pMonitor->scale;
|
||||
fullBox.height += **PBORDERSIZE * 2 * pMonitor->scale;
|
||||
|
||||
for (size_t i = 0; i < **PBORDERS; ++i) {
|
||||
const int PREVBORDERSIZESCALED = i == 0 ? 0 : (**PSIZES[i - 1] == -1 ? **PBORDERSIZE : **(PSIZES[i - 1])) * pMonitor->scale;
|
||||
const int THISBORDERSIZE = **(PSIZES[i]) == -1 ? **PBORDERSIZE : (**PSIZES[i]);
|
||||
|
@ -122,6 +118,8 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a) {
|
|||
|
||||
m_seExtents = {{fullThickness, fullThickness}, {fullThickness, fullThickness}};
|
||||
|
||||
m_bLastRelativeBox = CBox{0, 0, m_vLastWindowSize.x, m_vLastWindowSize.y}.expand(**PBORDERSIZE).addExtents(m_seExtents);
|
||||
|
||||
if (fullThickness != m_fLastThickness) {
|
||||
m_fLastThickness = fullThickness;
|
||||
g_pDecorationPositioner->repositionDeco(this);
|
||||
|
@ -132,7 +130,7 @@ eDecorationType CBordersPlusPlus::getDecorationType() {
|
|||
return DECORATION_CUSTOM;
|
||||
}
|
||||
|
||||
void CBordersPlusPlus::updateWindow(CWindow* pWindow) {
|
||||
void CBordersPlusPlus::updateWindow(PHLWINDOW pWindow) {
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.value();
|
||||
m_vLastWindowSize = pWindow->m_vRealSize.value();
|
||||
|
||||
|
@ -140,7 +138,6 @@ void CBordersPlusPlus::updateWindow(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
void CBordersPlusPlus::damageEntire() {
|
||||
CBox dm = {(int)(m_vLastWindowPos.x - m_seExtents.topLeft.x), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y),
|
||||
(int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x), (int)m_seExtents.topLeft.y};
|
||||
CBox dm = m_bLastRelativeBox.copy().translate(m_vLastWindowPos).expand(2);
|
||||
g_pHyprRenderer->damageBox(&dm);
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class CBordersPlusPlus : public IHyprWindowDecoration {
|
||||
public:
|
||||
CBordersPlusPlus(CWindow*);
|
||||
CBordersPlusPlus(PHLWINDOW);
|
||||
virtual ~CBordersPlusPlus();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
@ -17,7 +17,7 @@ class CBordersPlusPlus : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
@ -30,7 +30,9 @@ class CBordersPlusPlus : public IHyprWindowDecoration {
|
|||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
CBox m_bLastRelativeBox;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
|
|
@ -17,7 +17,7 @@ APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
|||
|
||||
void onNewWindow(void* self, std::any data) {
|
||||
// data is guaranteed
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, std::make_unique<CBordersPlusPlus>(PWINDOW));
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
if (w->isHidden() || !w->m_bIsMapped)
|
||||
continue;
|
||||
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, w.get(), std::make_unique<CBordersPlusPlus>(w.get()));
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, w, std::make_unique<CBordersPlusPlus>(w));
|
||||
}
|
||||
|
||||
HyprlandAPI::addNotification(PHANDLE, "[borders-plus-plus] Initialized successfully!", CColor{0.2, 1.0, 0.2, 1.0}, 5000);
|
||||
|
|
|
@ -28,10 +28,10 @@ void hkNotifyMotion(wlr_seat* wlr_seat, uint32_t time_msec, double sx, double sy
|
|||
static auto* const RESY = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:res_h")->getDataStaticPtr();
|
||||
static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:csgo-vulkan-fix:class")->getDataStaticPtr();
|
||||
|
||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_szInitialClass == *PCLASS && g_pCompositor->m_pLastMonitor) {
|
||||
if (!g_pCompositor->m_pLastWindow.expired() && g_pCompositor->m_pLastWindow.lock()->m_szInitialClass == *PCLASS && g_pCompositor->m_pLastMonitor) {
|
||||
// fix the coords
|
||||
sx *= (**RESX / g_pCompositor->m_pLastMonitor->vecSize.x) / g_pCompositor->m_pLastWindow->m_fX11SurfaceScaledBy;
|
||||
sy *= (**RESY / g_pCompositor->m_pLastMonitor->vecSize.y) / g_pCompositor->m_pLastWindow->m_fX11SurfaceScaledBy;
|
||||
sx *= (**RESX / g_pCompositor->m_pLastMonitor->vecSize.x) / g_pCompositor->m_pLastWindow.lock()->m_fX11SurfaceScaledBy;
|
||||
sy *= (**RESY / g_pCompositor->m_pLastMonitor->vecSize.y) / g_pCompositor->m_pLastWindow.lock()->m_fX11SurfaceScaledBy;
|
||||
}
|
||||
|
||||
(*(origMotion)g_pMouseMotionHook->m_pOriginal)(wlr_seat, time_msec, sx, sy);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "globals.hpp"
|
||||
|
||||
CHyprBar::CHyprBar(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
CHyprBar::CHyprBar(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
m_pWindow = pWindow;
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||
|
@ -51,9 +51,11 @@ std::string CHyprBar::getDisplayName() {
|
|||
}
|
||||
|
||||
void CHyprBar::onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e) {
|
||||
if (m_pWindow != g_pCompositor->m_pLastWindow)
|
||||
if (m_pWindow.lock() != g_pCompositor->m_pLastWindow.lock())
|
||||
return;
|
||||
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
const auto COORDS = cursorRelativeToBar();
|
||||
|
||||
static auto* const PHEIGHT = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->getDataStaticPtr();
|
||||
|
@ -67,7 +69,7 @@ void CHyprBar::onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e) {
|
|||
|
||||
if (m_bDraggingThis) {
|
||||
g_pKeybindManager->m_mDispatchers["mouse"]("0movewindow");
|
||||
Debug::log(LOG, "[hyprbars] Dragging ended on {:x}", (uintptr_t)m_pWindow);
|
||||
Debug::log(LOG, "[hyprbars] Dragging ended on {:x}", (uintptr_t)PWINDOW.get());
|
||||
}
|
||||
|
||||
m_bDraggingThis = false;
|
||||
|
@ -86,7 +88,7 @@ void CHyprBar::onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e) {
|
|||
g_pKeybindManager->m_mDispatchers["mouse"]("0movewindow");
|
||||
m_bDraggingThis = false;
|
||||
|
||||
Debug::log(LOG, "[hyprbars] Dragging ended on {:x}", (uintptr_t)m_pWindow);
|
||||
Debug::log(LOG, "[hyprbars] Dragging ended on {:x}", (uintptr_t)PWINDOW.get());
|
||||
}
|
||||
|
||||
m_bDragPending = false;
|
||||
|
@ -94,8 +96,8 @@ void CHyprBar::onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_pWindow->m_bIsFloating)
|
||||
g_pCompositor->changeWindowZOrder(m_pWindow, true);
|
||||
if (PWINDOW->m_bIsFloating)
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
|
||||
info.cancelled = true;
|
||||
m_bCancelledDown = true;
|
||||
|
@ -126,7 +128,7 @@ void CHyprBar::onMouseMove(Vector2D coords) {
|
|||
g_pKeybindManager->m_mDispatchers["mouse"]("1movewindow");
|
||||
m_bDraggingThis = true;
|
||||
|
||||
Debug::log(LOG, "[hyprbars] Dragging initiated on {:x}", (uintptr_t)m_pWindow);
|
||||
Debug::log(LOG, "[hyprbars] Dragging initiated on {:x}", (uintptr_t)m_pWindow.lock().get());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -200,7 +202,9 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) {
|
|||
|
||||
const bool BUTTONSRIGHT = std::string{*PALIGNBUTTONS} != "left";
|
||||
|
||||
const auto BORDERSIZE = m_pWindow->getRealBorderSize();
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
const auto BORDERSIZE = PWINDOW->getRealBorderSize();
|
||||
|
||||
float buttonSizes = **PBARBUTTONPADDING;
|
||||
for (auto& b : g_pGlobalState->buttons) {
|
||||
|
@ -244,7 +248,7 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) {
|
|||
int layoutWidth, layoutHeight;
|
||||
pango_layout_get_size(layout, &layoutWidth, &layoutHeight);
|
||||
const int xOffset = std::string{*PALIGN} == "left" ? std::round(scaledBarPadding + (BUTTONSRIGHT ? 0 : scaledButtonsSize)) :
|
||||
std::round(((bufferSize.x - scaledBorderSize) / 2.0 - layoutWidth / PANGO_SCALE / 2.0));
|
||||
std::round(((bufferSize.x - scaledBorderSize) / 2.0 - layoutWidth / PANGO_SCALE / 2.0));
|
||||
const int yOffset = std::round((bufferSize.y / 2.0 - layoutHeight / PANGO_SCALE / 2.0));
|
||||
|
||||
cairo_move_to(CAIRO, xOffset, yOffset);
|
||||
|
@ -377,10 +381,12 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float
|
|||
}
|
||||
|
||||
void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
||||
if (!g_pCompositor->windowValidMapped(m_pWindow))
|
||||
if (!validMapped(m_pWindow))
|
||||
return;
|
||||
|
||||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (!PWINDOW->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr();
|
||||
|
@ -396,10 +402,10 @@ void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
|||
return;
|
||||
}
|
||||
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
const auto PWORKSPACE = PWINDOW->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
|
||||
const auto ROUNDING = m_pWindow->rounding() + (*PPRECEDENCE ? 0 : m_pWindow->getRealBorderSize());
|
||||
const auto ROUNDING = PWINDOW->rounding() + (*PPRECEDENCE ? 0 : PWINDOW->getRealBorderSize());
|
||||
|
||||
const auto scaledRounding = ROUNDING > 0 ? ROUNDING * pMonitor->scale - 2 /* idk why but otherwise it looks bad due to the gaps */ : 0;
|
||||
|
||||
|
@ -415,7 +421,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
|||
CBox titleBarBox = {DECOBOX.x - pMonitor->vecPosition.x, DECOBOX.y - pMonitor->vecPosition.y, DECOBOX.w,
|
||||
DECOBOX.h + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */};
|
||||
|
||||
titleBarBox.translate(m_pWindow->m_vFloatingOffset).scale(pMonitor->scale).round();
|
||||
titleBarBox.translate(PWINDOW->m_vFloatingOffset).scale(pMonitor->scale).round();
|
||||
|
||||
if (titleBarBox.w < 1 || titleBarBox.h < 1)
|
||||
return;
|
||||
|
@ -424,9 +430,9 @@ void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
|||
|
||||
if (ROUNDING) {
|
||||
// the +1 is a shit garbage temp fix until renderRect supports an alpha matte
|
||||
CBox windowBox = {m_pWindow->m_vRealPosition.value().x + m_pWindow->m_vFloatingOffset.x - pMonitor->vecPosition.x + 1,
|
||||
m_pWindow->m_vRealPosition.value().y + m_pWindow->m_vFloatingOffset.y - pMonitor->vecPosition.y + 1, m_pWindow->m_vRealSize.value().x - 2,
|
||||
m_pWindow->m_vRealSize.value().y - 2};
|
||||
CBox windowBox = {PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vFloatingOffset.x - pMonitor->vecPosition.x + 1,
|
||||
PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vFloatingOffset.y - pMonitor->vecPosition.y + 1, PWINDOW->m_vRealSize.value().x - 2,
|
||||
PWINDOW->m_vRealSize.value().y - 2};
|
||||
|
||||
if (windowBox.w < 1 || windowBox.h < 1)
|
||||
return;
|
||||
|
@ -452,8 +458,8 @@ void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
|||
g_pHyprOpenGL->renderRect(&titleBarBox, color, scaledRounding);
|
||||
|
||||
// render title
|
||||
if (**PENABLETITLE && (m_szLastTitle != m_pWindow->m_szTitle || m_bWindowSizeChanged || m_tTextTex.m_iTexID == 0)) {
|
||||
m_szLastTitle = m_pWindow->m_szTitle;
|
||||
if (**PENABLETITLE && (m_szLastTitle != PWINDOW->m_szTitle || m_bWindowSizeChanged || m_tTextTex.m_iTexID == 0)) {
|
||||
m_szLastTitle = PWINDOW->m_szTitle;
|
||||
renderBarTitle(BARBUF, pMonitor->scale);
|
||||
}
|
||||
|
||||
|
@ -485,7 +491,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a) {
|
|||
|
||||
// dynamic updates change the extents
|
||||
if (m_iLastHeight != **PHEIGHT) {
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(m_pWindow);
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(PWINDOW);
|
||||
m_iLastHeight = **PHEIGHT;
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +500,7 @@ eDecorationType CHyprBar::getDecorationType() {
|
|||
return DECORATION_CUSTOM;
|
||||
}
|
||||
|
||||
void CHyprBar::updateWindow(CWindow* pWindow) {
|
||||
void CHyprBar::updateWindow(PHLWINDOW pWindow) {
|
||||
damageEntire();
|
||||
}
|
||||
|
||||
|
@ -516,15 +522,17 @@ uint64_t CHyprBar::getDecorationFlags() {
|
|||
}
|
||||
|
||||
CBox CHyprBar::assignedBoxGlobal() {
|
||||
CBox box = m_bAssignedBox;
|
||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
CBox box = m_bAssignedBox;
|
||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, PWINDOW));
|
||||
|
||||
const auto PWORKSPACE = PWINDOW->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
|
||||
return box.translate(WORKSPACEOFFSET);
|
||||
}
|
||||
|
||||
CWindow* CHyprBar::getOwner() {
|
||||
return m_pWindow;
|
||||
PHLWINDOW CHyprBar::getOwner() {
|
||||
return m_pWindow.lock();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class CHyprBar : public IHyprWindowDecoration {
|
||||
public:
|
||||
CHyprBar(CWindow*);
|
||||
CHyprBar(PHLWINDOW);
|
||||
virtual ~CHyprBar();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
@ -19,7 +19,7 @@ class CHyprBar : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
@ -31,12 +31,12 @@ class CHyprBar : public IHyprWindowDecoration {
|
|||
|
||||
virtual std::string getDisplayName();
|
||||
|
||||
CWindow* getOwner();
|
||||
PHLWINDOW getOwner();
|
||||
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
CBox m_bAssignedBox;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
|||
|
||||
static void onNewWindow(void* self, std::any data) {
|
||||
// data is guaranteed
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
if (!PWINDOW->m_bX11DoesntWantBorders) {
|
||||
std::unique_ptr<CHyprBar> bar = std::make_unique<CHyprBar>(PWINDOW);
|
||||
|
@ -28,7 +28,7 @@ static void onNewWindow(void* self, std::any data) {
|
|||
|
||||
static void onCloseWindow(void* self, std::any data) {
|
||||
// data is guaranteed
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
const auto BARIT = std::find_if(g_pGlobalState->bars.begin(), g_pGlobalState->bars.end(), [PWINDOW](const auto& bar) { return bar->getOwner() == PWINDOW; });
|
||||
|
||||
|
@ -110,7 +110,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
if (w->isHidden() || !w->m_bIsMapped)
|
||||
continue;
|
||||
|
||||
onNewWindow(nullptr /* unused */, std::any(w.get()));
|
||||
onNewWindow(nullptr /* unused */, std::any(w));
|
||||
}
|
||||
|
||||
HyprlandAPI::reloadConfig();
|
||||
|
|
|
@ -19,7 +19,7 @@ APICALL EXPORT std::string PLUGIN_API_VERSION() {
|
|||
|
||||
void onNewWindow(void* self, std::any data) {
|
||||
// data is guaranteed
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, PWINDOW, std::make_unique<CTrail>(PWINDOW));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprtrails:history_step", Hyprlang::INT{2});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprtrails:color", Hyprlang::INT{configStringToInt("rgba(ffaa00ff)")});
|
||||
|
||||
HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); });
|
||||
static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(self, data); });
|
||||
|
||||
g_pGlobalState = std::make_unique<SGlobalState>();
|
||||
initGlobal();
|
||||
|
@ -126,7 +126,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
if (w->isHidden() || !w->m_bIsMapped)
|
||||
continue;
|
||||
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, w.get(), std::make_unique<CTrail>(w.get()));
|
||||
HyprlandAPI::addWindowDecoration(PHANDLE, w, std::make_unique<CTrail>(w));
|
||||
}
|
||||
|
||||
HyprlandAPI::reloadConfig();
|
||||
|
|
|
@ -11,9 +11,11 @@ void CTrail::onTick() {
|
|||
|
||||
m_iTimer++;
|
||||
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (m_iTimer > **PHISTORYSTEP) {
|
||||
m_dLastGeoms.push_front({box{(float)m_pWindow->m_vRealPosition.value().x, (float)m_pWindow->m_vRealPosition.value().y, (float)m_pWindow->m_vRealSize.value().x,
|
||||
(float)m_pWindow->m_vRealSize.value().y},
|
||||
m_dLastGeoms.push_front({box{(float)PWINDOW->m_vRealPosition.value().x, (float)PWINDOW->m_vRealPosition.value().y, (float)PWINDOW->m_vRealSize.value().x,
|
||||
(float)PWINDOW->m_vRealSize.value().y},
|
||||
std::chrono::system_clock::now()});
|
||||
while (m_dLastGeoms.size() > **PHISTORYPOINTS)
|
||||
m_dLastGeoms.pop_back();
|
||||
|
@ -27,7 +29,7 @@ void CTrail::onTick() {
|
|||
}
|
||||
}
|
||||
|
||||
CTrail::CTrail(CWindow* pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
CTrail::CTrail(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.value();
|
||||
m_vLastWindowSize = pWindow->m_vRealSize.value();
|
||||
|
||||
|
@ -77,10 +79,12 @@ Vector2D vecForBezierT(const float& t, const std::vector<Vector2D>& verts) {
|
|||
}
|
||||
|
||||
void CTrail::draw(CMonitor* pMonitor, float a) {
|
||||
if (!g_pCompositor->windowValidMapped(m_pWindow))
|
||||
if (!validMapped(m_pWindow))
|
||||
return;
|
||||
|
||||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (!PWINDOW->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
static auto* const PBEZIERSTEP = (Hyprlang::FLOAT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprtrails:bezier_step")->getDataStaticPtr();
|
||||
|
@ -92,9 +96,9 @@ void CTrail::draw(CMonitor* pMonitor, float a) {
|
|||
if (m_dLastGeoms.size() < 2)
|
||||
return;
|
||||
|
||||
box thisbox = box{(float)m_pWindow->m_vRealPosition.value().x, (float)m_pWindow->m_vRealPosition.value().y, (float)m_pWindow->m_vRealSize.value().x,
|
||||
(float)m_pWindow->m_vRealSize.value().y};
|
||||
CBox wlrbox = {thisbox.x - pMonitor->vecPosition.x, thisbox.y - pMonitor->vecPosition.y, thisbox.w, thisbox.h};
|
||||
box thisbox =
|
||||
box{(float)PWINDOW->m_vRealPosition.value().x, (float)PWINDOW->m_vRealPosition.value().y, (float)PWINDOW->m_vRealSize.value().x, (float)PWINDOW->m_vRealSize.value().y};
|
||||
CBox wlrbox = {thisbox.x - pMonitor->vecPosition.x, thisbox.y - pMonitor->vecPosition.y, thisbox.w, thisbox.h};
|
||||
wlrbox.scale(pMonitor->scale).round();
|
||||
|
||||
g_pHyprOpenGL->scissor((CBox*)nullptr); // allow the entire window and stencil to render
|
||||
|
@ -107,7 +111,7 @@ void CTrail::draw(CMonitor* pMonitor, float a) {
|
|||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
g_pHyprOpenGL->renderRect(&wlrbox, CColor(0, 0, 0, 0), m_pWindow->rounding() * pMonitor->scale);
|
||||
g_pHyprOpenGL->renderRect(&wlrbox, CColor(0, 0, 0, 0), PWINDOW->rounding() * pMonitor->scale);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
glStencilFunc(GL_NOTEQUAL, 1, -1);
|
||||
|
@ -154,7 +158,7 @@ void CTrail::draw(CMonitor* pMonitor, float a) {
|
|||
float dists[2] = {0, 0};
|
||||
|
||||
Vector2D mainVec = {originalCoeff / pMonitor->vecSize.x, originalCoeff / pMonitor->vecSize.y};
|
||||
Vector2D windowMiddle = m_pWindow->middle() - pMonitor->vecPosition;
|
||||
Vector2D windowMiddle = PWINDOW->middle() - pMonitor->vecPosition;
|
||||
|
||||
points.push_back(
|
||||
Vector2D{cos(0) * mainVec.x - sin(0) * mainVec.y + windowMiddle.x / pMonitor->vecSize.x, sin(0) * mainVec.x + cos(0) * mainVec.y + windowMiddle.y / pMonitor->vecSize.y});
|
||||
|
@ -237,10 +241,10 @@ void CTrail::draw(CMonitor* pMonitor, float a) {
|
|||
}
|
||||
}
|
||||
|
||||
box thisboxopengl = box{(m_pWindow->m_vRealPosition.value().x - pMonitor->vecPosition.x) / pMonitor->vecSize.x,
|
||||
(m_pWindow->m_vRealPosition.value().y - pMonitor->vecPosition.y) / pMonitor->vecSize.y,
|
||||
(m_pWindow->m_vRealPosition.value().x + m_pWindow->m_vRealSize.value().x) / pMonitor->vecSize.x,
|
||||
(m_pWindow->m_vRealPosition.value().y + m_pWindow->m_vRealSize.value().y) / pMonitor->vecSize.y};
|
||||
box thisboxopengl = box{(PWINDOW->m_vRealPosition.value().x - pMonitor->vecPosition.x) / pMonitor->vecSize.x,
|
||||
(PWINDOW->m_vRealPosition.value().y - pMonitor->vecPosition.y) / pMonitor->vecSize.y,
|
||||
(PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x) / pMonitor->vecSize.x,
|
||||
(PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y) / pMonitor->vecSize.y};
|
||||
glUniform4f(g_pGlobalState->trailShader.gradient, thisboxopengl.x, thisboxopengl.y, thisboxopengl.w, thisboxopengl.h);
|
||||
glUniform4f(g_pGlobalState->trailShader.color, COLOR.r, COLOR.g, COLOR.b, COLOR.a);
|
||||
|
||||
|
@ -315,7 +319,7 @@ eDecorationType CTrail::getDecorationType() {
|
|||
return DECORATION_CUSTOM;
|
||||
}
|
||||
|
||||
void CTrail::updateWindow(CWindow* pWindow) {
|
||||
void CTrail::updateWindow(PHLWINDOW pWindow) {
|
||||
const auto PWORKSPACE = pWindow->m_pWorkspace;
|
||||
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
|
|
|
@ -30,7 +30,7 @@ struct point2 {
|
|||
|
||||
class CTrail : public IHyprWindowDecoration {
|
||||
public:
|
||||
CTrail(CWindow*);
|
||||
CTrail(PHLWINDOW);
|
||||
virtual ~CTrail();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
@ -41,7 +41,7 @@ class CTrail : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
@ -55,7 +55,7 @@ class CTrail : public IHyprWindowDecoration {
|
|||
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
|
|
@ -26,10 +26,10 @@ inline CFunctionHook* commitHook = nullptr;
|
|||
typedef void (*origCommitSubsurface)(CSubsurface* thisptr);
|
||||
typedef void (*origCommit)(void* owner, void* data);
|
||||
|
||||
std::vector<CWindow*> bgWindows;
|
||||
std::vector<PHLWINDOWREF> bgWindows;
|
||||
|
||||
//
|
||||
void onNewWindow(CWindow* pWindow) {
|
||||
void onNewWindow(PHLWINDOW pWindow) {
|
||||
static auto* const PCLASS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprwinwrap:class")->getDataStaticPtr();
|
||||
|
||||
if (pWindow->m_szInitialClass != *PCLASS)
|
||||
|
@ -59,8 +59,8 @@ void onNewWindow(CWindow* pWindow) {
|
|||
Debug::log(LOG, "[hyprwinwrap] new window moved to bg {}", pWindow);
|
||||
}
|
||||
|
||||
void onCloseWindow(CWindow* pWindow) {
|
||||
std::erase(bgWindows, pWindow);
|
||||
void onCloseWindow(PHLWINDOW pWindow) {
|
||||
std::erase_if(bgWindows, [pWindow](const auto& ref) { return ref.expired() || ref.lock() == pWindow; });
|
||||
|
||||
Debug::log(LOG, "[hyprwinwrap] closed window {}", pWindow);
|
||||
}
|
||||
|
@ -69,7 +69,9 @@ void onRenderStage(eRenderStage stage) {
|
|||
if (stage != RENDER_PRE_WINDOWS)
|
||||
return;
|
||||
|
||||
for (auto& bgw : bgWindows) {
|
||||
for (auto& bg : bgWindows) {
|
||||
const auto bgw = bg.lock();
|
||||
|
||||
if (bgw->m_iMonitorID != g_pHyprOpenGL->m_RenderData.pMonitor->ID)
|
||||
continue;
|
||||
|
||||
|
@ -88,7 +90,7 @@ void onRenderStage(eRenderStage stage) {
|
|||
void onCommitSubsurface(CSubsurface* thisptr) {
|
||||
const auto PWINDOW = thisptr->m_sWLSurface.getWindow();
|
||||
|
||||
if (!PWINDOW || std::find(bgWindows.begin(), bgWindows.end(), PWINDOW) == bgWindows.end()) {
|
||||
if (!PWINDOW || std::find_if(bgWindows.begin(), bgWindows.end(), [PWINDOW](const auto& ref) { return ref.lock() == PWINDOW; }) == bgWindows.end()) {
|
||||
((origCommitSubsurface)subsurfaceHook->m_pOriginal)(thisptr);
|
||||
return;
|
||||
}
|
||||
|
@ -104,9 +106,9 @@ void onCommitSubsurface(CSubsurface* thisptr) {
|
|||
}
|
||||
|
||||
void onCommit(void* owner, void* data) {
|
||||
const auto PWINDOW = (CWindow*)owner;
|
||||
const auto PWINDOW = ((CWindow*)owner)->m_pSelf.lock();
|
||||
|
||||
if (std::find(bgWindows.begin(), bgWindows.end(), PWINDOW) == bgWindows.end()) {
|
||||
if (std::find_if(bgWindows.begin(), bgWindows.end(), [PWINDOW](const auto& ref) { return ref.lock() == PWINDOW; }) == bgWindows.end()) {
|
||||
((origCommit)commitHook->m_pOriginal)(owner, data);
|
||||
return;
|
||||
}
|
||||
|
@ -139,8 +141,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
}
|
||||
|
||||
// clang-format off
|
||||
static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(std::any_cast<CWindow*>(data)); });
|
||||
static auto P2 = HyprlandAPI::registerCallbackDynamic(PHANDLE, "closeWindow", [&](void* self, SCallbackInfo& info, std::any data) { onCloseWindow(std::any_cast<CWindow*>(data)); });
|
||||
static auto P = HyprlandAPI::registerCallbackDynamic(PHANDLE, "openWindow", [&](void* self, SCallbackInfo& info, std::any data) { onNewWindow(std::any_cast<PHLWINDOW>(data)); });
|
||||
static auto P2 = HyprlandAPI::registerCallbackDynamic(PHANDLE, "closeWindow", [&](void* self, SCallbackInfo& info, std::any data) { onCloseWindow(std::any_cast<PHLWINDOW>(data)); });
|
||||
static auto P3 = HyprlandAPI::registerCallbackDynamic(PHANDLE, "render", [&](void* self, SCallbackInfo& info, std::any data) { onRenderStage(std::any_cast<eRenderStage>(data)); });
|
||||
static auto P4 = HyprlandAPI::registerCallbackDynamic(PHANDLE, "configReloaded", [&](void* self, SCallbackInfo& info, std::any data) { onConfigReloaded(); });
|
||||
// clang-format on
|
||||
|
|
Loading…
Reference in a new issue