diff options
author | vaxerski <[email protected]> | 2023-08-07 13:35:19 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-08-07 13:36:14 +0200 |
commit | 261c3307f70d14e5bbc7d4113b4ee6dac9e4b627 (patch) | |
tree | 4e1f5aa70bd571c4f5bc90724f2de2c7b566ddbe | |
parent | 6e53c47e68c1d15032b755270568eb5485f2c684 (diff) | |
download | Hyprland-261c3307f70d14e5bbc7d4113b4ee6dac9e4b627.tar.gz Hyprland-261c3307f70d14e5bbc7d4113b4ee6dac9e4b627.zip |
internal: cleanup headers in helpers/
-rw-r--r-- | .github/workflows/release.yaml | 2 | ||||
-rw-r--r-- | src/config/ConfigDataValues.hpp | 2 | ||||
-rw-r--r-- | src/defines.hpp | 83 | ||||
-rw-r--r-- | src/helpers/AnimatedVariable.hpp | 18 | ||||
-rw-r--r-- | src/helpers/BezierCurve.cpp | 3 | ||||
-rw-r--r-- | src/helpers/BezierCurve.hpp | 4 | ||||
-rw-r--r-- | src/helpers/Color.cpp | 6 | ||||
-rw-r--r-- | src/helpers/MiscFunctions.hpp | 5 | ||||
-rw-r--r-- | src/helpers/Splashes.hpp | 4 | ||||
-rw-r--r-- | src/helpers/SubsurfaceTree.hpp | 6 | ||||
-rw-r--r-- | src/helpers/Timer.hpp | 2 | ||||
-rw-r--r-- | src/helpers/Vector2D.hpp | 2 | ||||
-rw-r--r-- | src/helpers/WLListener.hpp | 9 | ||||
-rw-r--r-- | src/helpers/WLSurface.hpp | 15 | ||||
-rw-r--r-- | src/helpers/Workspace.hpp | 7 | ||||
-rw-r--r-- | src/layout/IHyprLayout.hpp | 2 | ||||
-rw-r--r-- | src/macros.hpp | 77 | ||||
-rw-r--r-- | src/protocols/WaylandProtocol.hpp | 4 | ||||
-rw-r--r-- | src/render/decorations/IHyprWindowDecoration.hpp | 5 |
19 files changed, 135 insertions, 121 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bed49001..2c1517c1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,7 +18,7 @@ jobs: - name: Create tarball with submodules id: tar run: | - sed -i "1s/^/#define GIT_COMMIT_HASH \"$(git rev-parse HEAD)\"\n#define GIT_TAG \"$(git describe --tags)\"\n/" ./src/defines.hpp + sed -i "1s/^/#define GIT_COMMIT_HASH \"$(git rev-parse HEAD)\"\n#define GIT_TAG \"$(git describe --tags)\"\n/" ./src/macros.hpp mkdir hyprland-source; mv ./* ./hyprland-source || tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f source.tar.gz * - id: whatrelease diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp index 7a4b5ee8..f6bf9881 100644 --- a/src/config/ConfigDataValues.hpp +++ b/src/config/ConfigDataValues.hpp @@ -7,7 +7,7 @@ enum eConfigValueDataTypes { CVD_TYPE_GRADIENT = 0 }; -interface ICustomConfigValueData { +class ICustomConfigValueData { public: virtual ~ICustomConfigValueData() = 0; diff --git a/src/defines.hpp b/src/defines.hpp index ca91fa55..4df72103 100644 --- a/src/defines.hpp +++ b/src/defines.hpp @@ -1,86 +1,5 @@ #include "includes.hpp" #include "debug/Log.hpp" -#include "helpers/MiscFunctions.hpp" #include "helpers/WLListener.hpp" #include "helpers/Color.hpp" - -#include <utility> - -#ifndef NDEBUG -#ifdef HYPRLAND_DEBUG -#define ISDEBUG true -#else -#define ISDEBUG false -#endif -#else -#define ISDEBUG false -#endif - -#define LISTENER(name) \ - void listener_##name(wl_listener*, void*); \ - inline wl_listener listen_##name = {.notify = listener_##name} -#define DYNLISTENFUNC(name) void listener_##name(void*, void*) -#define DYNLISTENER(name) CHyprWLListener hyprListener_##name -#define DYNMULTILISTENER(name) wl_listener listen_##name - -#define VECINRECT(vec, x1, y1, x2, y2) ((vec).x >= (x1) && (vec).x <= (x2) && (vec).y >= (y1) && (vec).y <= (y2)) - -#define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < (delta)) - -#define interface class - -#define STICKS(a, b) abs((a) - (b)) < 2 - -#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0) -#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0) -#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0) -#define BLUE(c) ((double)(((c)) & 0xff) / 255.0) - -#define HYPRATOM(name) \ - { name, 0 } - -#ifndef __INTELLISENSE__ -#define RASSERT(expr, reason, ...) \ - if (!(expr)) { \ - Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \ - getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \ - ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \ - printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \ - *((int*)nullptr) = 1; /* so that we crash and get a coredump */ \ - } -#else -#define RASSERT(expr, reason, ...) -#endif - -#define ASSERT(expr) RASSERT(expr, "?") - -#if ISDEBUG -#define UNREACHABLE() \ - { \ - Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \ - *((int*)nullptr) = 1; \ - } -#else -#define UNREACHABLE() std::unreachable(); -#endif - -// git stuff -#ifndef GIT_COMMIT_HASH -#define GIT_COMMIT_HASH "?" -#endif -#ifndef GIT_BRANCH -#define GIT_BRANCH "?" -#endif -#ifndef GIT_COMMIT_MESSAGE -#define GIT_COMMIT_MESSAGE "?" -#endif -#ifndef GIT_DIRTY -#define GIT_DIRTY "?" -#endif -#ifndef GIT_TAG -#define GIT_TAG "?" -#endif - -#define SPECIAL_WORKSPACE_START (-99) - -#define PI 3.14159265358979
\ No newline at end of file +#include "macros.hpp" diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index d234dce2..e8bb2774 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -1,18 +1,20 @@ #pragma once -#include "../defines.hpp" +#include <functional> #include <any> +#include <chrono> +#include "Vector2D.hpp" +#include "Color.hpp" +#include "../macros.hpp" -enum ANIMATEDVARTYPE -{ +enum ANIMATEDVARTYPE { AVARTYPE_INVALID = -1, AVARTYPE_FLOAT, AVARTYPE_VECTOR, AVARTYPE_COLOR }; -enum AVARDAMAGEPOLICY -{ +enum AVARDAMAGEPOLICY { AVARDAMAGE_NONE = -1, AVARDAMAGE_ENTIRE = 0, AVARDAMAGE_BORDER, @@ -32,10 +34,10 @@ class CAnimatedVariable { void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY); void create(ANIMATEDVARTYPE, std::any val, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY); - CAnimatedVariable(const CAnimatedVariable&) = delete; - CAnimatedVariable(CAnimatedVariable&&) = delete; + CAnimatedVariable(const CAnimatedVariable&) = delete; + CAnimatedVariable(CAnimatedVariable&&) = delete; CAnimatedVariable& operator=(const CAnimatedVariable&) = delete; - CAnimatedVariable& operator=(CAnimatedVariable&&) = delete; + CAnimatedVariable& operator=(CAnimatedVariable&&) = delete; ~CAnimatedVariable(); diff --git a/src/helpers/BezierCurve.cpp b/src/helpers/BezierCurve.cpp index e018811c..08190117 100644 --- a/src/helpers/BezierCurve.cpp +++ b/src/helpers/BezierCurve.cpp @@ -1,5 +1,8 @@ #include "BezierCurve.hpp" +#include "../debug/Log.hpp" +#include "../macros.hpp" +#include <chrono> #include <algorithm> void CBezierCurve::setup(std::vector<Vector2D>* pVec) { diff --git a/src/helpers/BezierCurve.hpp b/src/helpers/BezierCurve.hpp index 540d33a7..461e6142 100644 --- a/src/helpers/BezierCurve.hpp +++ b/src/helpers/BezierCurve.hpp @@ -1,7 +1,9 @@ #pragma once -#include "../defines.hpp" #include <deque> +#include <array> +#include <vector> +#include "Vector2D.hpp" constexpr int BAKEDPOINTS = 255; constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS; diff --git a/src/helpers/Color.cpp b/src/helpers/Color.cpp index ecd5a33c..77e0d530 100644 --- a/src/helpers/Color.cpp +++ b/src/helpers/Color.cpp @@ -1,5 +1,9 @@ #include "Color.hpp" -#include "../defines.hpp" + +#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0) +#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0) +#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0) +#define BLUE(c) ((double)(((c)) & 0xff) / 255.0) CColor::CColor() {} diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index a5f21313..90ac6d78 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -1,6 +1,9 @@ #pragma once -#include "../includes.hpp" +#include <string> +#include <wayland-server.h> +#include <wlr/util/box.h> +#include "Vector2D.hpp" std::string absolutePath(const std::string&, const std::string&); void addWLSignal(wl_signal*, wl_listener*, void* pOwner, const std::string& ownerString); diff --git a/src/helpers/Splashes.hpp b/src/helpers/Splashes.hpp index 32bef813..f5990506 100644 --- a/src/helpers/Splashes.hpp +++ b/src/helpers/Splashes.hpp @@ -1,9 +1,10 @@ #pragma once -#include <array> +#include <vector> #include <string> inline const std::vector<std::string> SPLASHES = { + // clang-format off "Woo, animations!", "It's like Hypr, but better.", "Release 1.0 when?", @@ -60,4 +61,5 @@ inline const std::vector<std::string> SPLASHES = { "Thanks ThatOneCalculator!", "The AUR packages always work, except for the times they don't.", "Funny animation compositor woo" + // clang-format on };
\ No newline at end of file diff --git a/src/helpers/SubsurfaceTree.hpp b/src/helpers/SubsurfaceTree.hpp index 7a0968fd..d6f04a58 100644 --- a/src/helpers/SubsurfaceTree.hpp +++ b/src/helpers/SubsurfaceTree.hpp @@ -26,7 +26,8 @@ struct SSurfaceTreeNode { void* globalOffsetData; CWindow* pWindowOwner = nullptr; - bool operator==(const SSurfaceTreeNode& rhs) const { + // + bool operator==(const SSurfaceTreeNode& rhs) const { return pSurface == rhs.pSurface; } }; @@ -43,7 +44,8 @@ struct SSubsurface { CWindow* pWindowOwner = nullptr; - bool operator==(const SSubsurface& rhs) const { + // + bool operator==(const SSubsurface& rhs) const { return pSubsurface == rhs.pSubsurface; } }; diff --git a/src/helpers/Timer.hpp b/src/helpers/Timer.hpp index 4ab0d294..e55f4ebf 100644 --- a/src/helpers/Timer.hpp +++ b/src/helpers/Timer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../defines.hpp" +#include <chrono> class CTimer { public: diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp index 3ba06de7..d23b3fbe 100644 --- a/src/helpers/Vector2D.hpp +++ b/src/helpers/Vector2D.hpp @@ -1,6 +1,6 @@ #pragma once -#include <math.h> +#include <cmath> class Vector2D { public: diff --git a/src/helpers/WLListener.hpp b/src/helpers/WLListener.hpp index 8327e945..d5d925b0 100644 --- a/src/helpers/WLListener.hpp +++ b/src/helpers/WLListener.hpp @@ -1,7 +1,8 @@ #pragma once -#include "../includes.hpp" +#include <string> #include <functional> +#include <wayland-server.h> class CHyprWLListener { public: @@ -9,10 +10,10 @@ class CHyprWLListener { CHyprWLListener(); ~CHyprWLListener(); - CHyprWLListener(const CHyprWLListener&) = delete; - CHyprWLListener(CHyprWLListener&&) = delete; + CHyprWLListener(const CHyprWLListener&) = delete; + CHyprWLListener(CHyprWLListener&&) = delete; CHyprWLListener& operator=(const CHyprWLListener&) = delete; - CHyprWLListener& operator=(CHyprWLListener&&) = delete; + CHyprWLListener& operator=(CHyprWLListener&&) = delete; void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = ""); diff --git a/src/helpers/WLSurface.hpp b/src/helpers/WLSurface.hpp index e3325f99..c5cdd37f 100644 --- a/src/helpers/WLSurface.hpp +++ b/src/helpers/WLSurface.hpp @@ -1,7 +1,6 @@ #pragma once #include "../defines.hpp" - class CWLSurface { public: CWLSurface() = default; @@ -11,20 +10,20 @@ class CWLSurface { void assign(wlr_surface* pSurface); void unassign(); - CWLSurface(const CWLSurface&) = delete; - CWLSurface(CWLSurface&&) = delete; + CWLSurface(const CWLSurface&) = delete; + CWLSurface(CWLSurface&&) = delete; CWLSurface& operator=(const CWLSurface&) = delete; - CWLSurface& operator=(CWLSurface&&) = delete; + CWLSurface& operator=(CWLSurface&&) = delete; wlr_surface* wlr() const; bool exists() const; CWLSurface& operator=(wlr_surface* pSurface) { - destroy(); - m_pWLRSurface = pSurface; - init(); + destroy(); + m_pWLRSurface = pSurface; + init(); - return *this; + return *this; } bool operator==(const CWLSurface& other) const { diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index b9de76d5..a7ee0e7a 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -1,10 +1,11 @@ #pragma once -#include "../defines.hpp" #include "AnimatedVariable.hpp" +#include <string> +#include "../defines.hpp" +#include "../wlrunstable/wlr_ext_workspace_v1.hpp" -enum eFullscreenMode : uint8_t -{ +enum eFullscreenMode : uint8_t { FULLSCREEN_FULL = 0, FULLSCREEN_MAXIMIZED }; diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index eff0d3e6..c673b330 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -23,7 +23,7 @@ enum eRectCorner { CORNER_BOTTOMLEFT }; -interface IHyprLayout { +class IHyprLayout { public: virtual ~IHyprLayout() = 0; virtual void onEnable() = 0; diff --git a/src/macros.hpp b/src/macros.hpp new file mode 100644 index 00000000..334ada80 --- /dev/null +++ b/src/macros.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include "helpers/MiscFunctions.hpp" +#include <cmath> +#include <utility> + +#ifndef NDEBUG +#ifdef HYPRLAND_DEBUG +#define ISDEBUG true +#else +#define ISDEBUG false +#endif +#else +#define ISDEBUG false +#endif + +// git stuff +#ifndef GIT_COMMIT_HASH +#define GIT_COMMIT_HASH "?" +#endif +#ifndef GIT_BRANCH +#define GIT_BRANCH "?" +#endif +#ifndef GIT_COMMIT_MESSAGE +#define GIT_COMMIT_MESSAGE "?" +#endif +#ifndef GIT_DIRTY +#define GIT_DIRTY "?" +#endif +#ifndef GIT_TAG +#define GIT_TAG "?" +#endif + +#define SPECIAL_WORKSPACE_START (-99) + +#define PI 3.14159265358979 + +#define LISTENER(name) \ + void listener_##name(wl_listener*, void*); \ + inline wl_listener listen_##name = {.notify = listener_##name} +#define DYNLISTENFUNC(name) void listener_##name(void*, void*) +#define DYNLISTENER(name) CHyprWLListener hyprListener_##name +#define DYNMULTILISTENER(name) wl_listener listen_##name + +#define VECINRECT(vec, x1, y1, x2, y2) ((vec).x >= (x1) && (vec).x <= (x2) && (vec).y >= (y1) && (vec).y <= (y2)) + +#define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < (delta)) + +#define STICKS(a, b) abs((a) - (b)) < 2 + +#define HYPRATOM(name) \ + { name, 0 } + +#ifndef __INTELLISENSE__ +#define RASSERT(expr, reason, ...) \ + if (!(expr)) { \ + Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \ + getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \ + ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \ + printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \ + *((int*)nullptr) = 1; /* so that we crash and get a coredump */ \ + } +#else +#define RASSERT(expr, reason, ...) +#endif + +#define ASSERT(expr) RASSERT(expr, "?") + +#if ISDEBUG +#define UNREACHABLE() \ + { \ + Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \ + *((int*)nullptr) = 1; \ + } +#else +#define UNREACHABLE() std::unreachable(); +#endif
\ No newline at end of file diff --git a/src/protocols/WaylandProtocol.hpp b/src/protocols/WaylandProtocol.hpp index 04a58387..904a3053 100644 --- a/src/protocols/WaylandProtocol.hpp +++ b/src/protocols/WaylandProtocol.hpp @@ -20,14 +20,14 @@ class CWaylandResource { wl_resource* m_pWLResource = nullptr; }; -interface IWaylandProtocol { +class IWaylandProtocol { public: IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name); ~IWaylandProtocol(); virtual void onDisplayDestroy(); - virtual void bindManager(wl_client * client, void* data, uint32_t ver, uint32_t id) = 0; + virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) = 0; private: wl_global* m_pGlobal = nullptr; diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index a30d63b3..e5eb1bb9 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -2,8 +2,7 @@ #include "../../defines.hpp" -enum eDecorationType -{ +enum eDecorationType { DECORATION_NONE = -1, DECORATION_GROUPBAR, DECORATION_SHADOW, @@ -18,7 +17,7 @@ struct SWindowDecorationExtents { class CWindow; class CMonitor; -interface IHyprWindowDecoration { +class IHyprWindowDecoration { public: virtual ~IHyprWindowDecoration() = 0; |