diff options
| author | Darksome <dev@darkso.me> | 2022-07-21 19:18:03 +0300 |
|---|---|---|
| committer | Darksome <dev@darkso.me> | 2022-07-21 19:18:03 +0300 |
| commit | eb8a1939e6dddaaf81f6b623d1c657b801978487 (patch) | |
| tree | d62d4ca30d4114fe2e2745e36907b65ac4be20af /src/helpers | |
| parent | 68cfc1a496f556f360c032651b75d33ddb576517 (diff) | |
| parent | 7f660fed0d4a8133ccde21c3e092dbc8c6e08c60 (diff) | |
Merge upstream
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 24 | ||||
| -rw-r--r-- | src/helpers/MiscFunctions.hpp | 1 | ||||
| -rw-r--r-- | src/helpers/SubsurfaceTree.cpp | 10 | ||||
| -rw-r--r-- | src/helpers/WLClasses.hpp | 1 | ||||
| -rw-r--r-- | src/helpers/WLListener.cpp | 2 |
5 files changed, 33 insertions, 5 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index cf415847..3fc6d20e 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -3,6 +3,7 @@ #include <algorithm> #include "../Compositor.hpp" #include <sys/utsname.h> +#include <iomanip> static const float transforms[][9] = {{ 1.0f, 0.0f, 0.0f, @@ -113,6 +114,29 @@ std::string getFormat(const char *fmt, ...) { return output; } +std::string escapeJSONStrings(const std::string& str) { + std::ostringstream oss; + for (auto &c : str) { + switch (c) { + case '"': oss << "\\\""; break; + case '\\': oss << "\\\\"; break; + case '\b': oss << "\\b"; break; + case '\f': oss << "\\f"; break; + case '\n': oss << "\\n"; break; + case '\r': oss << "\\r"; break; + case '\t': oss << "\\t"; break; + default: + if ('\x00' <= c && c <= '\x1f') { + oss << "\\u" + << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c); + } else { + oss << c; + } + } + } + return oss.str(); +} + void scaleBox(wlr_box* box, float scale) { box->width = std::round(box->width * scale); box->height = std::round(box->height * scale); diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 108ac7f7..a40471a9 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -5,6 +5,7 @@ void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString); void wlr_signal_emit_safe(struct wl_signal *signal, void *data); std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string +std::string escapeJSONStrings(const std::string& str); void scaleBox(wlr_box*, float); std::string removeBeginEndSpacesTabs(std::string); bool isNumber(const std::string&, bool allowfloat = false); diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index c511b900..376153f5 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -171,12 +171,14 @@ void Events::listener_unmapSubsurface(void* owner, void* data) { addSurfaceGlobalOffset(PNODE, &lx, &ly); wlr_box extents = {0}; - wlr_surface_get_extends(PNODE->pSurface, &extents); + if (PNODE->pSurface) { + wlr_surface_get_extends(PNODE->pSurface, &extents); - extents.x += lx; - extents.y += ly; + extents.x += lx; + extents.y += ly; - g_pHyprRenderer->damageBox(&extents); + g_pHyprRenderer->damageBox(&extents); + } SubsurfaceTree::destroySurfaceTree(subsurface->pChild); subsurface->pChild = nullptr; diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 58b6ce72..768dcb45 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -30,6 +30,7 @@ struct SLayerSurface { CAnimatedVariable alpha; bool fadingOut = false; bool readyToDelete = false; + bool noProcess = false; bool forceBlur = false; diff --git a/src/helpers/WLListener.cpp b/src/helpers/WLListener.cpp index adaab288..117e16eb 100644 --- a/src/helpers/WLListener.cpp +++ b/src/helpers/WLListener.cpp @@ -23,7 +23,7 @@ CHyprWLListener::~CHyprWLListener() { void CHyprWLListener::removeCallback() { if (m_bIsConnected) { - Debug::log(LOG, "Callback %x -> %x, %s removed.", m_pCallback, m_pOwner, m_szAuthor.c_str()); + Debug::log(LOG, "Callback %x -> %x, %s removed.", &m_pCallback, &m_pOwner, m_szAuthor.c_str()); wl_list_remove(&m_sListener.link); } |
