From 44aeb1fc909ec9cb3e6b82a5397e9eec8839192b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:15:06 +0200 Subject: added decoration:shadow_offset --- src/helpers/MiscFunctions.cpp | 4 ++-- src/helpers/MiscFunctions.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index ce9dd788..d082799f 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -135,8 +135,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) { diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 8470eb81..733b7ca9 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -7,7 +7,7 @@ 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); -- cgit v1.2.3 From 8b4a373efa01ce2c685734cf85237456f8885944 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:30:07 +0200 Subject: update wlroots dep --- src/helpers/MiscFunctions.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++- src/helpers/MiscFunctions.hpp | 4 ++- 2 files changed, 60 insertions(+), 2 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index d082799f..d5eece67 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -4,6 +4,41 @@ #include "../Compositor.hpp" #include +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); @@ -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 733b7ca9..108ac7f7 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -14,4 +14,6 @@ float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Ve 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 -- cgit v1.2.3 From 80f04fa7c609403828278d95fe18c8449fddcd04 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 12:20:33 +0200 Subject: speed up damage log in commit subsurface --- src/helpers/SubsurfaceTree.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/helpers') diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index 064ca181..bcff2986 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -188,7 +188,8 @@ 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; } -- cgit v1.2.3 From 3cbd69e7039c7ed020bde7f7a58ed5c8da93155b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 12:39:56 +0200 Subject: added createworkspace destroyworkspace events --- src/helpers/Workspace.cpp | 8 ++++++-- src/helpers/Workspace.hpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index 90d234cb..7c0185b4 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}); } 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}); } 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 -- cgit v1.2.3 From 9fcef41d6653a2541a06275d0843bb61aaf5ea1b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 15:30:46 +0200 Subject: mutliple fixes to subsurface handling --- src/helpers/SubsurfaceTree.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/helpers') diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index bcff2986..c511b900 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -193,12 +193,22 @@ void Events::listener_commitSubsurface(void* owner, void* data) { 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); } -- cgit v1.2.3 From 6213328d2cba771aa8db4379d6ec88bf15f103d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Jun 2022 16:12:47 +0200 Subject: default currentrules to null --- src/helpers/WLClasses.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/helpers') diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index d6282224..d32ae333 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -71,7 +71,7 @@ struct SKeyboard { bool active = false; - xkb_rule_names currentRules; + xkb_rule_names currentRules = {0}; // For the list lookup bool operator==(const SKeyboard& rhs) { -- cgit v1.2.3 From 2659afee3cbb8ee5362e0acff2a384c7c7d474fe Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 18:19:06 +0200 Subject: force workspace events --- src/helpers/Workspace.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp index 7c0185b4..7a6ad070 100644 --- a/src/helpers/Workspace.cpp +++ b/src/helpers/Workspace.cpp @@ -31,7 +31,7 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) { 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}); + g_pEventManager->postEvent({"createworkspace", m_szName}, true); } CWorkspace::~CWorkspace() { @@ -45,7 +45,7 @@ CWorkspace::~CWorkspace() { m_pWlrHandle = nullptr; } - g_pEventManager->postEvent({"destroyworkspace", m_szName}); + g_pEventManager->postEvent({"destroyworkspace", m_szName}, true); } void CWorkspace::startAnim(bool in, bool left, bool instant) { -- cgit v1.2.3 From 4101006b5ed20efbde2accfbff0403e1ced3d113 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:22:24 +0200 Subject: remove asserts in CAnimatedVariable --- src/helpers/AnimatedVariable.hpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/helpers') 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(); } -- cgit v1.2.3 From 328b3fa4bc4f3776f2128f84709556569c4824d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:44:26 +0200 Subject: mordernize pointers --- src/helpers/MiscFunctions.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index d5eece67..067a351f 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -219,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) -- cgit v1.2.3 From 4510764f348d1a7c4cca613925ee22acfa38b388 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 20:02:04 +0200 Subject: finally fix scaled snapshots --- src/helpers/MiscFunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 067a351f..cb1d88d6 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -114,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); } -- cgit v1.2.3 From d010ca20492c7638d15690e888d80c6020685df1 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:26:00 +0200 Subject: added per-device config options --- src/helpers/WLClasses.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index d32ae333..33278053 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -71,7 +71,12 @@ struct SKeyboard { bool active = false; + 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); -- cgit v1.2.3