Merge branch 'main' into scaling

This commit is contained in:
vaxerski 2022-05-18 13:10:22 +02:00 committed by GitHub
commit 6c437763f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 349 additions and 244 deletions

View file

@ -60,8 +60,8 @@ float CBezierCurve::getYForPoint(float x) {
}
// in the name of performance i shall make a hack
const auto LOWERPOINT = &m_aPointsBaked[(int)((float)BAKEDPOINTS * lowerT)];
const auto UPPERPOINT = &m_aPointsBaked[(int)((float)BAKEDPOINTS * upperT)];
const auto LOWERPOINT = &m_aPointsBaked[std::clamp((int)((float)BAKEDPOINTS * lowerT), 0, 199)];
const auto UPPERPOINT = &m_aPointsBaked[std::clamp((int)((float)BAKEDPOINTS * upperT), 0, 199)];
const auto PERCINDELTA = (x - LOWERPOINT->x) / (UPPERPOINT->x - LOWERPOINT->x);

View file

@ -1,6 +1,7 @@
#include "MiscFunctions.hpp"
#include "../defines.hpp"
#include <algorithm>
#include "../Compositor.hpp"
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) {
ASSERT(pSignal);
@ -120,4 +121,23 @@ bool isNumber(const std::string& str) {
bool isDirection(const std::string& arg) {
return arg == "l" || arg == "r" || arg == "u" || arg == "d" || arg == "t" || arg == "b";
}
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
int result = INT_MAX;
if (in.find("name:") == 0) {
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
if (!WORKSPACE) {
result = g_pCompositor->getNextAvailableNamedWorkspace();
} else {
result = WORKSPACE->m_iID;
}
outName = WORKSPACENAME;
} else {
result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX);
outName = std::to_string(result);
}
return result;
}

View file

@ -9,5 +9,6 @@ void scaleBox(wlr_box*, float);
std::string removeBeginEndSpacesTabs(std::string);
bool isNumber(const std::string&);
bool isDirection(const std::string&);
int getWorkspaceIDFromString(const std::string&, std::string&);
float getPlusMinusKeywordResult(std::string in, float relative);

View file

@ -54,6 +54,9 @@ struct SRenderData {
// for alpha settings
float alpha = 1.f;
// for decorations (border)
bool decorate = false;
};
struct SKeyboard {

View file

@ -23,6 +23,9 @@ CWorkspace::CWorkspace(int monitorID) {
m_vRenderOffset.m_pWorkspace = this;
m_vRenderOffset.create(AVARTYPE_VECTOR, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
m_fAlpha.m_pWorkspace = this;
m_fAlpha.create(AVARTYPE_FLOAT, &g_pConfigManager->getConfigValuePtr("animations:workspaces_speed")->floatValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces")->intValue, &g_pConfigManager->getConfigValuePtr("animations:workspaces_curve")->strValue, nullptr, AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(255.f);
}
CWorkspace::~CWorkspace() {
@ -33,4 +36,32 @@ CWorkspace::~CWorkspace() {
wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
m_pWlrHandle = nullptr;
}
}
void CWorkspace::startAnim(bool in, bool left) {
const auto ANIMSTYLE = g_pConfigManager->getString("animations:workspaces_style");
if (ANIMSTYLE == "fade") {
m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); // fix a bug, if switching from slide -> fade.
if (in) {
m_fAlpha.setValueAndWarp(0.f);
m_fAlpha = 255.f;
} else {
m_fAlpha.setValueAndWarp(255.f);
m_fAlpha = 0.f;
}
} else {
// fallback is slide
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
m_fAlpha.setValueAndWarp(255.f); // fix a bug, if switching from fade -> slide.
if (in) {
m_vRenderOffset.setValueAndWarp(Vector2D(left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x, 0));
m_vRenderOffset = Vector2D(0, 0);
} else {
m_vRenderOffset = Vector2D(left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x, 0);
}
}
}

View file

@ -21,4 +21,7 @@ public:
// for animations
CAnimatedVariable m_vRenderOffset;
CAnimatedVariable m_fAlpha;
void startAnim(bool in, bool left);
};