Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeine01 authored Jan 7, 2025
2 parents c2f34f1 + d224c84 commit 5d1fef9
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 49 deletions.
10 changes: 5 additions & 5 deletions borders-plus-plus/borderDeco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "globals.hpp"

CBordersPlusPlus::CBordersPlusPlus(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
m_vLastWindowPos = pWindow->m_vRealPosition.value();
m_vLastWindowSize = pWindow->m_vRealSize.value();
m_vLastWindowPos = pWindow->m_vRealPosition->value();
m_vLastWindowSize = pWindow->m_vRealSize->value();
}

CBordersPlusPlus::~CBordersPlusPlus() {
Expand Down Expand Up @@ -97,7 +97,7 @@ void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) {
return;

const auto PWORKSPACE = PWINDOW->m_pWorkspace;
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset->value() : Vector2D();

auto rounding = PWINDOW->rounding() == 0 ? 0 : (PWINDOW->rounding() + **PBORDERSIZE) * pMonitor->scale;
const auto ORIGINALROUND = rounding == 0 ? 0 : (PWINDOW->rounding() + **PBORDERSIZE) * pMonitor->scale;
Expand Down Expand Up @@ -155,8 +155,8 @@ eDecorationType CBordersPlusPlus::getDecorationType() {
}

void CBordersPlusPlus::updateWindow(PHLWINDOW pWindow) {
m_vLastWindowPos = pWindow->m_vRealPosition.value();
m_vLastWindowSize = pWindow->m_vRealSize.value();
m_vLastWindowPos = pWindow->m_vRealPosition->value();
m_vLastWindowSize = pWindow->m_vRealSize->value();

damageEntire();
}
Expand Down
3 changes: 2 additions & 1 deletion borders-plus-plus/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/render/Renderer.hpp>

#include "borderDeco.hpp"
#include "globals.hpp"
Expand Down Expand Up @@ -59,5 +60,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
}

APICALL EXPORT void PLUGIN_EXIT() {
;
g_pHyprRenderer->m_sRenderPass.removeAllOfType("CBorderPPPassElement");
}
3 changes: 2 additions & 1 deletion hyprexpo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <hyprland/src/desktop/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/desktop/DesktopTypes.hpp>
#include <hyprland/src/render/Renderer.hpp>

#include "globals.hpp"
#include "overview.hpp"
Expand Down Expand Up @@ -229,5 +230,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
}

APICALL EXPORT void PLUGIN_EXIT() {
;
g_pHyprRenderer->m_sRenderPass.removeAllOfType("COverviewPassElement");
}
51 changes: 26 additions & 25 deletions hyprexpo/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#undef private
#include "OverviewPassElement.hpp"

static void damageMonitor(void*) {
static void damageMonitor(WP<Hyprutils::Animation::CBaseAnimatedVariable> thisptr) {
g_pOverview->damage();
}

static void removeOverview(void*) {
static void removeOverview(WP<Hyprutils::Animation::CBaseAnimatedVariable> thisptr) {
g_pOverview.reset();
}

Expand Down Expand Up @@ -162,18 +162,19 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
// zoom on the current workspace.
const auto& TILE = images[std::clamp(currentid, 0, SIDE_LENGTH * SIDE_LENGTH)];

size.create(pMonitor->vecSize * pMonitor->vecSize / tileSize, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
pos.create((-((pMonitor->vecSize / (double)SIDE_LENGTH) * Vector2D{currentid % SIDE_LENGTH, currentid / SIDE_LENGTH}) * pMonitor->scale) * (pMonitor->vecSize / tileSize),
g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
g_pAnimationManager->createAnimation(pMonitor->vecSize * pMonitor->vecSize / tileSize, size, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);
g_pAnimationManager->createAnimation((-((pMonitor->vecSize / (double)SIDE_LENGTH) * Vector2D{currentid % SIDE_LENGTH, currentid / SIDE_LENGTH}) * pMonitor->scale) *
(pMonitor->vecSize / tileSize),
pos, g_pConfigManager->getAnimationPropertyConfig("windowsMove"), AVARDAMAGE_NONE);

size.setUpdateCallback(damageMonitor);
pos.setUpdateCallback(damageMonitor);
size->setUpdateCallback(damageMonitor);
pos->setUpdateCallback(damageMonitor);

if (!swipe) {
size = pMonitor->vecSize;
pos = {0, 0};
*size = pMonitor->vecSize;
*pos = {0, 0};

size.setCallbackOnEnd([this](void*) { redrawAll(true); });
size->setCallbackOnEnd([this](auto) { redrawAll(true); });
}

openedID = currentid;
Expand Down Expand Up @@ -228,7 +229,7 @@ void COverview::redrawID(int id, bool forcelowres) {
Vector2D tileRenderSize = (pMonitor->vecSize - Vector2D{GAP_WIDTH, GAP_WIDTH} * (SIDE_LENGTH - 1)) / SIDE_LENGTH;
CBox monbox{0, 0, tileSize.x * 2, tileSize.y * 2};

if (!forcelowres && (size.value() != pMonitor->vecSize || closing))
if (!forcelowres && (size->value() != pMonitor->vecSize || closing))
monbox = {{0, 0}, pMonitor->vecPixelSize};

if (!ENABLE_LOWRES)
Expand Down Expand Up @@ -301,7 +302,7 @@ void COverview::damage() {
void COverview::onDamageReported() {
damageDirty = true;

Vector2D SIZE = size.value();
Vector2D SIZE = size->value();

Vector2D tileSize = (SIZE / SIDE_LENGTH);
Vector2D tileRenderSize = (SIZE - Vector2D{GAP_WIDTH, GAP_WIDTH} * (SIDE_LENGTH - 1)) / SIDE_LENGTH;
Expand All @@ -328,10 +329,10 @@ void COverview::close() {

Vector2D tileSize = (pMonitor->vecSize / SIDE_LENGTH);

size = pMonitor->vecSize * pMonitor->vecSize / tileSize;
pos = (-((pMonitor->vecSize / (double)SIDE_LENGTH) * Vector2D{ID % SIDE_LENGTH, ID / SIDE_LENGTH}) * pMonitor->scale) * (pMonitor->vecSize / tileSize);
*size = pMonitor->vecSize * pMonitor->vecSize / tileSize;
*pos = (-((pMonitor->vecSize / (double)SIDE_LENGTH) * Vector2D{ID % SIDE_LENGTH, ID / SIDE_LENGTH}) * pMonitor->scale) * (pMonitor->vecSize / tileSize);

size.setCallbackOnEnd(removeOverview);
size->setCallbackOnEnd(removeOverview);

closing = true;

Expand Down Expand Up @@ -386,14 +387,14 @@ void COverview::render() {
}

void COverview::fullRender() {
const auto GAPSIZE = (closing ? (1.0 - size.getPercent()) : size.getPercent()) * GAP_WIDTH;
const auto GAPSIZE = (closing ? (1.0 - size->getPercent()) : size->getPercent()) * GAP_WIDTH;

if (pMonitor->activeWorkspace != startedOn && !closing) {
// likely user changed.
onWorkspaceChange();
}

Vector2D SIZE = size.value();
Vector2D SIZE = size->value();

Vector2D tileSize = (SIZE / SIDE_LENGTH);
Vector2D tileRenderSize = (SIZE - Vector2D{GAPSIZE, GAPSIZE} * (SIDE_LENGTH - 1)) / SIDE_LENGTH;
Expand All @@ -403,10 +404,10 @@ void COverview::fullRender() {
for (size_t y = 0; y < SIDE_LENGTH; ++y) {
for (size_t x = 0; x < SIDE_LENGTH; ++x) {
CBox texbox = {x * tileRenderSize.x + x * GAPSIZE, y * tileRenderSize.y + y * GAPSIZE, tileRenderSize.x, tileRenderSize.y};
texbox.scale(pMonitor->scale).translate(pos.value());
texbox.scale(pMonitor->scale).translate(pos->value());
texbox.round();
CRegion damage{0, 0, INT16_MAX, INT16_MAX};
g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, damage, 0, false, false, false, false, nullptr, 0);
g_pHyprOpenGL->renderTextureInternalWithDamage(images[x + y * SIDE_LENGTH].fb.getTexture(), &texbox, 1.0, damage);
}
}
}
Expand Down Expand Up @@ -436,22 +437,22 @@ void COverview::onSwipeUpdate(double delta) {
const auto SIZEMIN = pMonitor->vecSize;
const auto POSMIN = Vector2D{0, 0};

size.setValueAndWarp(lerp(SIZEMIN, SIZEMAX, PERC));
pos.setValueAndWarp(lerp(POSMIN, POSMAX, PERC));
size->setValueAndWarp(lerp(SIZEMIN, SIZEMAX, PERC));
pos->setValueAndWarp(lerp(POSMIN, POSMAX, PERC));
}

void COverview::onSwipeEnd() {
const auto SIZEMIN = pMonitor->vecSize;
const auto SIZEMAX = pMonitor->vecSize * pMonitor->vecSize / (pMonitor->vecSize / SIDE_LENGTH);
const auto PERC = (size.value() - SIZEMIN).x / (SIZEMAX - SIZEMIN).x;
const auto PERC = (size->value() - SIZEMIN).x / (SIZEMAX - SIZEMIN).x;
if (PERC > 0.5) {
close();
return;
}
size = pMonitor->vecSize;
pos = {0, 0};
*size = pMonitor->vecSize;
*pos = {0, 0};

size.setCallbackOnEnd([this](void*) { redrawAll(true); });
size->setCallbackOnEnd([this](WP<Hyprutils::Animation::CBaseAnimatedVariable> thisptr) { redrawAll(true); });

swipeWasCommenced = true;
}
4 changes: 2 additions & 2 deletions hyprexpo/overview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class COverview {

PHLWORKSPACE startedOn;

CAnimatedVariable<Vector2D> size;
CAnimatedVariable<Vector2D> pos;
PHLANIMVAR<Vector2D> size;
PHLANIMVAR<Vector2D> pos;

bool closing = false;

Expand Down
2 changes: 2 additions & 0 deletions hyprtrails/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <hyprland/src/desktop/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/render/Shaders.hpp>
#include <hyprland/src/render/Renderer.hpp>

#include "globals.hpp"
#include "shaders.hpp"
Expand Down Expand Up @@ -135,4 +136,5 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {

APICALL EXPORT void PLUGIN_EXIT() {
wl_event_source_remove(g_pGlobalState->tick);
g_pHyprRenderer->m_sRenderPass.removeAllOfType("CTrailPassElement");
}
24 changes: 12 additions & 12 deletions hyprtrails/trail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void CTrail::onTick() {
const auto PWINDOW = m_pWindow.lock();

if (m_iTimer > **PHISTORYSTEP) {
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},
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();
Expand All @@ -32,8 +32,8 @@ void CTrail::onTick() {
}

CTrail::CTrail(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) {
m_vLastWindowPos = pWindow->m_vRealPosition.value();
m_vLastWindowSize = pWindow->m_vRealSize.value();
m_vLastWindowPos = pWindow->m_vRealPosition->value();
m_vLastWindowSize = pWindow->m_vRealSize->value();

pTickCb = HyprlandAPI::registerCallbackDynamic(PHANDLE, "trailTick", [this](void* self, SCallbackInfo& info, std::any data) { this->onTick(); });
}
Expand Down Expand Up @@ -106,7 +106,7 @@ void CTrail::renderPass(PHLMONITOR pMonitor, const float& a) {
return;

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};
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();

Expand Down Expand Up @@ -246,10 +246,10 @@ void CTrail::renderPass(PHLMONITOR pMonitor, const float& a) {
}
}

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};
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);

Expand Down Expand Up @@ -327,10 +327,10 @@ eDecorationType CTrail::getDecorationType() {
void CTrail::updateWindow(PHLWINDOW pWindow) {
const auto PWORKSPACE = pWindow->m_pWorkspace;

const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset->value() : Vector2D();

m_vLastWindowPos = pWindow->m_vRealPosition.value() + WORKSPACEOFFSET;
m_vLastWindowSize = pWindow->m_vRealSize.value();
m_vLastWindowPos = pWindow->m_vRealPosition->value() + WORKSPACEOFFSET;
m_vLastWindowSize = pWindow->m_vRealSize->value();

damageEntire();
}
Expand Down
6 changes: 3 additions & 3 deletions hyprwinwrap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ void onNewWindow(PHLWINDOW pWindow) {
if (!pWindow->m_bIsFloating)
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(pWindow);

pWindow->m_vRealSize.setValueAndWarp(PMONITOR->vecSize);
pWindow->m_vRealPosition.setValueAndWarp(PMONITOR->vecPosition);
pWindow->m_vRealSize->setValueAndWarp(PMONITOR->vecSize);
pWindow->m_vRealPosition->setValueAndWarp(PMONITOR->vecPosition);
pWindow->m_vSize = PMONITOR->vecSize;
pWindow->m_vPosition = PMONITOR->vecPosition;
pWindow->m_bPinned = true;
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goal(), true);
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize->goal(), true);

bgWindows.push_back(pWindow);

Expand Down

0 comments on commit 5d1fef9

Please sign in to comment.