diff options
| author | xDarksome <dev@darkso.me> | 2022-07-02 19:43:52 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-02 19:43:52 +0300 |
| commit | 185c4d6ea13ad5f4483aa2e389e43bd09106002f (patch) | |
| tree | a7bc4a9510c39e367317b5ce64d2ee0e0a72d4f0 /src/helpers | |
| parent | fc4b10d13c14c4eb08febb0637f27177cb6a1940 (diff) | |
| parent | b7b3344188e3ebd2baed14bc288ee42a1ae8d6f2 (diff) | |
Merge branch 'hyprwm:main' into main
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/AnimatedVariable.hpp | 15 | ||||
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 76 | ||||
| -rw-r--r-- | src/helpers/MiscFunctions.hpp | 6 | ||||
| -rw-r--r-- | src/helpers/SubsurfaceTree.cpp | 15 | ||||
| -rw-r--r-- | src/helpers/WLClasses.hpp | 15 | ||||
| -rw-r--r-- | src/helpers/Workspace.cpp | 8 | ||||
| -rw-r--r-- | src/helpers/Workspace.hpp | 2 |
7 files changed, 104 insertions, 33 deletions
diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index bb04869f..ceda2c57 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -33,56 +33,47 @@ public: // gets the current vector value (real time) const Vector2D& vec() const { - RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access vec() of AVARTYPE %i!", m_eVarType); return m_vValue; } // gets the current float value (real time) const float& fl() const { - RASSERT(m_eVarType == AVARTYPE_FLOAT, "Tried to access fl() of AVARTYPE %i!", m_eVarType); return m_fValue; } // gets the current color value (real time) const CColor& col() const { - RASSERT(m_eVarType == AVARTYPE_COLOR, "Tried to access col() of AVARTYPE %i!", m_eVarType); return m_cValue; } // gets the goal vector value const Vector2D& goalv() const { - RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access goalv() of AVARTYPE %i!", m_eVarType); return m_vGoal; } // gets the goal float value const float& goalf() const { - RASSERT(m_eVarType == AVARTYPE_FLOAT, "Tried to access goalf() of AVARTYPE %i!", m_eVarType); return m_fGoal; } // gets the goal color value const CColor& goalc() const { - RASSERT(m_eVarType == AVARTYPE_COLOR, "Tried to access goalc() of AVARTYPE %i!", m_eVarType); return m_cGoal; } void operator=(const Vector2D& v) { - RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access =v of AVARTYPE %i!", m_eVarType); m_vGoal = v; animationBegin = std::chrono::system_clock::now(); m_vBegun = m_vValue; } void operator=(const float& v) { - RASSERT(m_eVarType == AVARTYPE_FLOAT, "Tried to access =f of AVARTYPE %i!", m_eVarType); m_fGoal = v; animationBegin = std::chrono::system_clock::now(); m_fBegun = m_fValue; } void operator=(const CColor& v) { - RASSERT(m_eVarType == AVARTYPE_COLOR, "Tried to access =c of AVARTYPE %i!", m_eVarType); m_cGoal = v; animationBegin = std::chrono::system_clock::now(); m_cBegun = m_cValue; @@ -90,7 +81,6 @@ public: // Sets the actual stored value, without affecting the goal, but resets the timer void setValue(const Vector2D& v) { - RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access setValue(v) of AVARTYPE %i!", m_eVarType); m_vValue = v; animationBegin = std::chrono::system_clock::now(); m_vBegun = m_vValue; @@ -98,7 +88,6 @@ public: // Sets the actual stored value, without affecting the goal, but resets the timer void setValue(const float& v) { - RASSERT(m_eVarType == AVARTYPE_FLOAT, "Tried to access setValue(f) of AVARTYPE %i!", m_eVarType); m_fValue = v; animationBegin = std::chrono::system_clock::now(); m_vBegun = m_vValue; @@ -106,7 +95,6 @@ public: // Sets the actual stored value, without affecting the goal, but resets the timer void setValue(const CColor& v) { - RASSERT(m_eVarType == AVARTYPE_COLOR, "Tried to access setValue(c) of AVARTYPE %i!", m_eVarType); m_cValue = v; animationBegin = std::chrono::system_clock::now(); m_vBegun = m_vValue; @@ -114,21 +102,18 @@ public: // Sets the actual value and goal void setValueAndWarp(const Vector2D& v) { - RASSERT(m_eVarType == AVARTYPE_VECTOR, "Tried to access setValueAndWarp(v) of AVARTYPE %i!", m_eVarType); m_vGoal = v; warp(); } // Sets the actual value and goal void setValueAndWarp(const float& v) { - RASSERT(m_eVarType == AVARTYPE_FLOAT, "Tried to access setValueAndWarp(f) of AVARTYPE %i!", m_eVarType); m_fGoal = v; warp(); } // Sets the actual value and goal void setValueAndWarp(const CColor& v) { - RASSERT(m_eVarType == AVARTYPE_COLOR, "Tried to access setValueAndWarp(c) of AVARTYPE %i!", m_eVarType); m_cGoal = v; warp(); } diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index ce9dd788..cb1d88d6 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -4,6 +4,41 @@ #include "../Compositor.hpp" #include <sys/utsname.h> +static const float transforms[][9] = {{ + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + 0.0f, 1.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + -1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + 0.0f, -1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + -1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + 1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + },{ + 0.0f, -1.0f, 0.0f, + -1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + }, +}; + void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) { ASSERT(pSignal); ASSERT(pListener); @@ -79,8 +114,8 @@ std::string getFormat(const char *fmt, ...) { } void scaleBox(wlr_box* box, float scale) { - box->width = std::round((box->x + box->width) * scale) - std::round(box->x * scale); - box->height = std::round((box->y + box->height) * scale) - std::round(box->y * scale); + box->width = std::round(box->width * scale); + box->height = std::round(box->height * scale); box->x = std::round(box->x * scale); box->y = std::round(box->y * scale); } @@ -135,8 +170,8 @@ float getPlusMinusKeywordResult(std::string source, float relative) { return result; } -bool isNumber(const std::string& str) { - return std::ranges::all_of(str.begin(), str.end(), [](char c) { return isdigit(c) != 0 || c == '-'; }); +bool isNumber(const std::string& str, bool allowfloat) { + return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); }); } bool isDirection(const std::string& arg) { @@ -184,12 +219,12 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { int lowestID = 99999; int highestID = -99999; - for (auto& w : g_pCompositor->m_lWorkspaces) { - if (w.m_iID < lowestID) - lowestID = w.m_iID; + for (auto& w : g_pCompositor->m_vWorkspaces) { + if (w->m_iID < lowestID) + lowestID = w->m_iID; - if (w.m_iID > highestID) - highestID = w.m_iID; + if (w->m_iID > highestID) + highestID = w->m_iID; } if (remains < 0) @@ -264,4 +299,25 @@ void logSystemInfo() { Debug::log(LOG, "os-release:"); Debug::log(NONE, "%s", execAndGet("cat /etc/os-release").c_str()); -}
\ No newline at end of file +} + +void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) { + memset(mat, 0, sizeof(*mat) * 9); + + const float* t = transforms[tr]; + float x = 2.0f / w; + float y = 2.0f / h; + + // Rotation + reflection + mat[0] = x * t[0]; + mat[1] = x * t[1]; + mat[3] = y * -t[3]; + mat[4] = y * -t[4]; + + // Translation + mat[2] = -copysign(1.0f, mat[0] + mat[1]); + mat[5] = -copysign(1.0f, mat[3] + mat[4]); + + // Identity + mat[8] = 1.0f; +} diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 8470eb81..108ac7f7 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -7,11 +7,13 @@ void wlr_signal_emit_safe(struct wl_signal *signal, void *data); std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string void scaleBox(wlr_box*, float); std::string removeBeginEndSpacesTabs(std::string); -bool isNumber(const std::string&); +bool isNumber(const std::string&, bool allowfloat = false); bool isDirection(const std::string&); int getWorkspaceIDFromString(const std::string&, std::string&); float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2); void logSystemInfo(); std::string execAndGet(const char*); -float getPlusMinusKeywordResult(std::string in, float relative);
\ No newline at end of file +float getPlusMinusKeywordResult(std::string in, float relative); + +void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
\ No newline at end of file diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index 064ca181..c511b900 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -188,16 +188,27 @@ void Events::listener_commitSubsurface(void* owner, void* data) { // no damaging if it's not visible if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) { - if (g_pConfigManager->getInt("debug:log_damage")) + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; + if (*PLOGDAMAGE) Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner); return; } - int lx = 0, ly = 0; addSurfaceGlobalOffset(pNode, &lx, &ly); + // I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox) + // What this does is that basically, if the pNode is a child of some other node, on commit, + // it will also damage (check & damage if needed) all its siblings. + if (pNode->pParent) for (auto& cs : pNode->pParent->childSubsurfaces) { + const auto NODECOORDS = pNode->pSubsurface ? Vector2D(pNode->pSubsurface->pSubsurface->current.x, pNode->pSubsurface->pSubsurface->current.y) : Vector2D(); + + if (&cs != pNode->pSubsurface && cs.pSubsurface) { + g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y); + } + } + g_pHyprRenderer->damageSurface(pNode->pSurface, lx, ly); } diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index d6282224..33278053 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -71,7 +71,12 @@ struct SKeyboard { bool active = false; - xkb_rule_names currentRules; + std::string name = ""; + + xkb_rule_names currentRules = {0}; + int repeatRate = 0; + int repeatDelay = 0; + int numlockOn = -1; // For the list lookup bool operator==(const SKeyboard& rhs) { @@ -87,6 +92,8 @@ struct SMouse { pixman_region32_t confinedTo; + std::string name = ""; + DYNLISTENER(commitConstraint); DYNLISTENER(destroyMouse); @@ -168,6 +175,8 @@ struct STablet { wlr_tablet_v2_tablet* wlrTabletV2 = nullptr; wlr_input_device* wlrDevice = nullptr; + std::string name = ""; + bool operator==(const STablet& b) { return wlrDevice == b.wlrDevice; } @@ -186,6 +195,8 @@ struct STabletTool { bool active = true; + std::string name = ""; + DYNLISTENER(TabletToolDestroy); DYNLISTENER(TabletToolSetCursor); @@ -198,6 +209,8 @@ struct STabletPad { wlr_tablet_v2_tablet_pad* wlrTabletPadV2 = nullptr; STablet* pTabletParent = nullptr; + std::string name = ""; + DYNLISTENER(Attach); DYNLISTENER(Button); DYNLISTENER(Strip); diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index 90d234cb..7a6ad070 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -1,7 +1,7 @@ #include "Workspace.hpp" #include "../Compositor.hpp" -CWorkspace::CWorkspace(int monitorID, bool special) { +CWorkspace::CWorkspace(int monitorID, std::string name, bool special) { const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID); if (!PMONITOR) { @@ -10,7 +10,7 @@ CWorkspace::CWorkspace(int monitorID, bool special) { } m_iMonitorID = monitorID; - + m_szName = name; m_bIsSpecialWorkspace = special; if (!special) { @@ -30,6 +30,8 @@ CWorkspace::CWorkspace(int monitorID, bool special) { 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); + + g_pEventManager->postEvent({"createworkspace", m_szName}, true); } CWorkspace::~CWorkspace() { @@ -42,6 +44,8 @@ CWorkspace::~CWorkspace() { wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle); m_pWlrHandle = nullptr; } + + g_pEventManager->postEvent({"destroyworkspace", m_szName}, true); } void CWorkspace::startAnim(bool in, bool left, bool instant) { diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 21b36e9f..2d0c5941 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -10,7 +10,7 @@ enum eFullscreenMode : uint8_t { class CWorkspace { public: - CWorkspace(int monitorID, bool special = false); + CWorkspace(int monitorID, std::string name, bool special = false); ~CWorkspace(); // Workspaces ID-based have IDs > 0 |
