ronantakizawa/codereview-bench huggingface dataset:
Repository: hyprwm/Hyprland
File: src/config/ConfigManager.cpp (C++)

Code before:
        return 500;
    if (loWeight == "semibold")
        return 600;
    if (loWeight == "bold")
        return 700;
    if (loWeight == "ultrabold")
        return 800;
    if (loWeight == "heavy")
        return 900;
    if (loWeight == "ultraheavy")
        return 1000;

    int w_i = std::stoi(weight);
    if (w_i < 100 || w_i > 1000)
        return 400;

    return w_i;
}

static Hyprlang::CParseResult configHandleFontWeightSet(const char* VALUE, void** data) {
    std::string V = VALUE;

    if (!*data)
        *data = new int;

    const auto             DATA = reinterpret_cast<Hyprlang::INT*>(*data);
    Hyprlang::CParseResult result;

    try {
        *DATA = strToPangoWeight(V);
    } catch (...) {
        std::string parseError = std::format("{} is not a valid font weight", V);
        result.setError(parseError.c_str());
    }

    return result;
}

static void configHandleFontWeightDestroy(void** data) {
    if (*data)
        delete reinterpret_cast<Hyprlang::INT*>(*data);
}

static Hyprlang::CParseResult handleExec(const char* c, const char* v) {
    const std::string      VALUE   = v;
    const std::string      COMMAND = c;

    const auto             RESULT = g_pConfigManager->handleExec(COMMAND, VALUE);

    Hyprlang::CParseResult result;
    if (RESULT.has_value())

Review comment (suggestion):
this will not pass tests. custom types in hyprland must be a `ICustomConfigValueData` (see `SConfigOptionDescription::jsonify()`)

Code after:

static void configHandleFontWeightDestroy(void** data) {
    if (*data)
        delete reinterpret_cast<CFontWeightConfigValueData*>(*data);
}

static Hyprlang::CParseResult handleExec(const char* c, const char* v) {
    const std::string      VALUE   = v;
    const std::string      COMMAND = c;

    const auto             RESULT = g_pConfigManager->handleExec(COMMAND, VALUE);

    Hyprlang::CParseResult result;
    if (RESULT.has_value())
        result.setError(RESULT.value().c_str());
    return result;
}

static Hyprlang::CParseResult handleRawExec(const char* c, const char* v) {
    const std::string      VALUE   = v;
    const std::string      COMMAND = c;

    const auto             RESULT = g_pConfigManager->handleRawExec(COMMAND, VALUE);

    Hyprlang::CParseResult result;
    if (RESULT.has_value())
        result.setError(RESULT.value().c_str());
    return result;
}

static Hyprlang::CParseResult handleExecOnce(const char* c, const char* v) {
    const std::string      VALUE   = v;
    const std::string      COMMAND = c;

    const auto             RESULT = g_pConfigManager->handleExecOnce(COMMAND, VALUE);

    Hyprlang::CParseResult result;
    if (RESULT.has_value())
        result.setError(RESULT.value().c_str());
    return result;
}

static Hyprlang::CParseResult handleExecRawOnce(const char* c, const char* v) {
    const std::string      VALUE   = v;
    const std::string      COMMAND = c;

    const auto             RESULT = g_pConfigManager->handleExecRawOnce(COMMAND, VALUE);

    Hyprlang::CParseResult result;
    if (RESULT.has_value())
        result.setError(RESULT.value().c_str());
Repository: hyprwm/Hyprland
File: src/protocols/ForeignToplevel.cpp (C++)

Code before:
void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
    const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get();

    if UNLIKELY (!RESOURCE->good()) {
        LOGM(ERR, "Couldn't create a foreign list");
        wl_client_post_no_memory(client);
        m_vManagers.pop_back();
        return;
    }
}

void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mgr) {
    std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; });
}

void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) {
    std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; });
}

bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {
    return validMapped(pWindow) && !pWindow->isX11OverrideRedirect();
}

PHLWINDOW CForeignToplevelProtocol::windowFromHandleResource(wl_resource* res) {
    for (auto const& h : m_vHandles) {
        if (h->resource->resource() != res)
            continue;

        return h->window();
    }

    return nullptr;
}


Review comment (performance):
this sucks, as it's slow and unintuitive. See e.g. `CWLSurface::fromResource` for how to do it right.

Code after:
}

void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
    const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get();

    if UNLIKELY (!RESOURCE->good()) {
        LOGM(ERR, "Couldn't create a foreign list");
        wl_client_post_no_memory(client);
        m_vManagers.pop_back();
        return;
    }
}

void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mgr) {
    std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == mgr; });
}

void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) {
    std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; });
}

bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {
    return validMapped(pWindow) && !pWindow->isX11OverrideRedirect();
}

PHLWINDOW CForeignToplevelProtocol::windowFromHandleResource(wl_resource* res) {
    auto data = (CForeignToplevelHandle*)(((CExtForeignToplevelHandleV1*)wl_resource_get_user_data(res))->data());
    return data ? data->window() : nullptr;
}
Repository: hyprwm/Hyprland
File: src/managers/ANRManager.cpp (C++)

Code before:
    static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");

    if (!*PENABLEANR) {
        m_timer->updateTimeout(TIMER_TIMEOUT * 10);
        return;
    }

    for (auto& data : m_data) {
        PHLWINDOW firstWindow;
        int       count = 0;
        for (const auto& w : g_pCompositor->m_vWindows) {
            if (!w->m_bIsMapped)
                continue;

            if (!data->fitsWindow(w))
                continue;

            count++;
            if (!firstWindow)
                firstWindow = w;
        }

        if (count == 0)
            continue;

        if (data->missedResponses > *PANRTHRESHOLD) {
            if (!data->isThreadRunning() && !data->dialogThreadSaidWait) {
                data->runDialog("Application Not Responding", firstWindow->m_szTitle, firstWindow->m_szClass, data->getPid());

                for (const auto& w : g_pCompositor->m_vWindows) {
                    if (!w->m_bIsMapped)
                        continue;

                    if (!data->fitsWindow(w))
                        continue;

                    *w->m_notRespondingTint = 0.2F;
                }
            }
        } else if (data->isThreadRunning())
            data->killDialog();

        if (data->missedResponses == 0)
            data->dialogThreadSaidWait = false;

        data->missedResponses++;

        data->ping();
    }

    m_timer->updateTimeout(TIMER_TIMEOUT);

Review comment (suggestion):
here it was correctly `>=` before. I only meant `::isNotResponding` (look how isNotResponding is > 1, while here it's > 0 on main)

Code after:
    static auto PANRTHRESHOLD = CConfigValue<Hyprlang::INT>("misc:anr_missed_pings");

    if (!*PENABLEANR) {
        m_timer->updateTimeout(TIMER_TIMEOUT * 10);
        return;
    }

    for (auto& data : m_data) {
        PHLWINDOW firstWindow;
        int       count = 0;
        for (const auto& w : g_pCompositor->m_vWindows) {
            if (!w->m_bIsMapped)
                continue;

            if (!data->fitsWindow(w))
                continue;

            count++;
            if (!firstWindow)
                firstWindow = w;
        }

        if (count == 0)
            continue;

        if (data->missedResponses >= *PANRTHRESHOLD) {
            if (!data->isThreadRunning() && !data->dialogThreadSaidWait) {
                data->runDialog("Application Not Responding", firstWindow->m_szTitle, firstWindow->m_szClass, data->getPid());

                for (const auto& w : g_pCompositor->m_vWindows) {
                    if (!w->m_bIsMapped)
                        continue;

                    if (!data->fitsWindow(w))
                        continue;

                    *w->m_notRespondingTint = 0.2F;
                }
            }
        } else if (data->isThreadRunning())
            data->killDialog();

        if (data->missedResponses == 0)
            data->dialogThreadSaidWait = false;

        data->missedResponses++;

        data->ping();
    }

    m_timer->updateTimeout(TIMER_TIMEOUT);
Repository: hyprwm/Hyprland
File: src/desktop/Window.hpp (C++)

Code before:
    IDLEINHIBIT_ALWAYS,
    IDLEINHIBIT_FULLSCREEN,
    IDLEINHIBIT_FOCUS
};

enum eGroupRules : uint8_t {
    // effective only during first map, except for _ALWAYS variant
    GROUP_NONE        = 0,
    GROUP_SET         = 1 << 0, // Open as new group or add to focused group
    GROUP_SET_ALWAYS  = 1 << 1,
    GROUP_BARRED      = 1 << 2, // Don't insert to focused group.
    GROUP_LOCK        = 1 << 3, // Lock m_sGroupData.lock
    GROUP_LOCK_ALWAYS = 1 << 4,
    GROUP_INVADE      = 1 << 5, // Force enter a group, event if lock is engaged
    GROUP_OVERRIDE    = 1 << 6, // Override other rules
};

enum eGetWindowProperties : uint8_t {
    WINDOW_ONLY      = 0,
    RESERVED_EXTENTS = 1 << 0,
    INPUT_EXTENTS    = 1 << 1,
    FULL_EXTENTS     = 1 << 2,
    FLOATING_ONLY    = 1 << 3,
    ALLOW_FLOATING   = 1 << 4,
    USE_PROP_TILED   = 1 << 5,
    NON_FULLSCREEN   = 1 << 6,
};

enum eSuppressEvents : uint8_t {
    SUPPRESS_NONE               = 0,
    SUPPRESS_FULLSCREEN         = 1 << 0,
    SUPPRESS_MAXIMIZE           = 1 << 1,
    SUPPRESS_ACTIVATE           = 1 << 2,
    SUPPRESS_ACTIVATE_FOCUSONLY = 1 << 3,
    SUPPRESS_FULLSCREEN_OUTPUT  = 1 << 4,
};

class IWindowTransformer;

struct SAlphaValue {
    float m_fAlpha;
    bool  m_bOverride;

    float applyAlpha(float alpha) const {
        if (m_bOverride)
            return m_fAlpha;
        else
            return m_fAlpha * alpha;
    };
};


Review comment (suggestion):
misleading for what it does. It doesn't "return a non-fullscreen window" but rather "skip fullscreen window's priority"

I suggest `SKIP_FULLSCREEN_PRIORITY`

Code after:
    IDLEINHIBIT_ALWAYS,
    IDLEINHIBIT_FULLSCREEN,
    IDLEINHIBIT_FOCUS
};

enum eGroupRules : uint8_t {
    // effective only during first map, except for _ALWAYS variant
    GROUP_NONE        = 0,
    GROUP_SET         = 1 << 0, // Open as new group or add to focused group
    GROUP_SET_ALWAYS  = 1 << 1,
    GROUP_BARRED      = 1 << 2, // Don't insert to focused group.
    GROUP_LOCK        = 1 << 3, // Lock m_sGroupData.lock
    GROUP_LOCK_ALWAYS = 1 << 4,
    GROUP_INVADE      = 1 << 5, // Force enter a group, event if lock is engaged
    GROUP_OVERRIDE    = 1 << 6, // Override other rules
};

enum eGetWindowProperties : uint8_t {
    WINDOW_ONLY              = 0,
    RESERVED_EXTENTS         = 1 << 0,
    INPUT_EXTENTS            = 1 << 1,
    FULL_EXTENTS             = 1 << 2,
    FLOATING_ONLY            = 1 << 3,
    ALLOW_FLOATING           = 1 << 4,
    USE_PROP_TILED           = 1 << 5,
    SKIP_FULLSCREEN_PRIORITY = 1 << 6,
};

enum eSuppressEvents : uint8_t {
    SUPPRESS_NONE               = 0,
    SUPPRESS_FULLSCREEN         = 1 << 0,
    SUPPRESS_MAXIMIZE           = 1 << 1,
    SUPPRESS_ACTIVATE           = 1 << 2,
    SUPPRESS_ACTIVATE_FOCUSONLY = 1 << 3,
    SUPPRESS_FULLSCREEN_OUTPUT  = 1 << 4,
};

class IWindowTransformer;

struct SAlphaValue {
    float m_fAlpha;
    bool  m_bOverride;

    float applyAlpha(float alpha) const {
        if (m_bOverride)
            return m_fAlpha;
        else
            return m_fAlpha * alpha;
    };
};
Repository: hyprwm/Hyprland
File: hyprpm/src/helpers/Sys.cpp (C++)

Code before:
            escaped += "'\\''";
        else
            escaped += c;
    }
    escaped += "'";
    return escaped;
}

int NSys::getUID() {
    const auto UID   = getuid();
    const auto PWUID = getpwuid(UID);
    return PWUID ? PWUID->pw_uid : UID;
}

int NSys::getEUID() {
    const auto UID   = geteuid();
    const auto PWUID = getpwuid(UID);
    return PWUID ? PWUID->pw_uid : UID;
}

bool NSys::isSuperuser() {
    return getuid() != geteuid() || geteuid() == 0;
}

std::string NSys::runAsSuperuser(const std::string& cmd) {
    const std::string escapedCmd = shellEscape(cmd);

    for (const auto& BIN : SUPERUSER_BINARIES) {
        if (!executableExistsInPath(std::string{BIN}))
            continue;

        const auto result = execAndGet(std::string{BIN} + " /bin/sh -c " + escapedCmd, true);
        if (!result.has_value() || result->second != 0)
            Debug::die("Failed to run a command as sudo. This could be due to an invalid password, or a hyprpm bug.");

        return result->first;
    }

    Debug::die("{} {}", "Failed to find a superuser binary. Supported: ", fetchSuperuserBins());
    return "";
}

void NSys::cacheSudo() {
    // "caches" the sudo so that the prompt later doesn't pop up in a weird spot
    // sudo will not ask us again for a moment
    runAsSuperuser("echo e > /dev/null");
}

void NSys::dropSudo() {
    for (const auto& BIN : SUPERUSER_BINARIES) {
        if (!executableExistsInPath(std::string{BIN}))

Review comment (bug):
this is bad. We should escape _before_. Reason:
```
runAsSuperuser("cd '/somedir/with spaces'")
```
will be incorrectly "sanitized" to `\'/somedir...` which will return a bad path

Code after:
}

int NSys::getEUID() {
    const auto UID   = geteuid();
    const auto PWUID = getpwuid(UID);
    return PWUID ? PWUID->pw_uid : UID;
}

bool NSys::isSuperuser() {
    return getuid() != geteuid() || geteuid() == 0;
}

std::string NSys::runAsSuperuser(const std::string& cmd) {
    for (const auto& BIN : SUPERUSER_BINARIES) {
        if (!executableExistsInPath(std::string{BIN}))
            continue;

        const auto result = execAndGet(std::string{BIN} + " /bin/sh -c " + cmd, true);
        if (!result.has_value() || result->second != 0)
            Debug::die("Failed to run a command as sudo. This could be due to an invalid password, or a hyprpm bug.");

        return result->first;
    }

    Debug::die("{} {}", "Failed to find a superuser binary. Supported: ", fetchSuperuserBins());
    return "";
}

void NSys::cacheSudo() {
    // "caches" the sudo so that the prompt later doesn't pop up in a weird spot
    // sudo will not ask us again for a moment
    runAsSuperuser("echo e > /dev/null");
}

void NSys::dropSudo() {
    for (const auto& BIN : SUPERUSER_BINARIES) {
        if (!executableExistsInPath(std::string{BIN}))
            continue;

        if (BIN == "sudo")
            execAndGet("sudo -k");
        else {
            // note the superuser binary that is being dropped
            std::println("{}", infoString("Don't know how to drop timestamp for '{}', ignoring.", BIN));
        }
    }
}
Repository: hyprwm/Hyprland
File: src/desktop/LayerRule.cpp (C++)

Code before:
#include <re2/re2.h>
#include "LayerRule.hpp"
#include <unordered_set>
#include <algorithm>
#include "../debug/Log.hpp"

static const auto RULES        = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"};

CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) {
    const bool VALID = RULES.contains(m_rule) || std::ranges::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });

    if (!VALID)
        return;

    if (m_rule == "noanim")
        m_ruleType = RULE_NOANIM;
    else if (m_rule == "blur")
        m_ruleType = RULE_BLUR;
    else if (m_rule == "blurpopups")
        m_ruleType = RULE_BLURPOPUPS;
    else if (m_rule == "dimaround")
        m_ruleType = RULE_DIMAROUND;
    else if (m_rule.starts_with("ignorealpha"))
        m_ruleType = RULE_IGNOREALPHA;
    else if (m_rule.starts_with("ignorezero"))
        m_ruleType = RULE_IGNOREZERO;
    else if (m_rule.starts_with("xray"))
        m_ruleType = RULE_XRAY;
    else if (m_rule.starts_with("animation"))
        m_ruleType = RULE_ANIMATION;
    else if (m_rule.starts_with("order"))
        m_ruleType = RULE_ORDER;
    else if (m_rule.starts_with("abovelock"))
        m_ruleType = RULE_ABOVELOCK;
    else {

Review comment (suggestion):
if you are using ranges, drop the begin and end, just do `RULES_PREFIX`. Those stl containers are ranges themselves so it's fine

Code after:
#include <re2/re2.h>
#include "LayerRule.hpp"
#include <unordered_set>
#include <algorithm>
#include "../debug/Log.hpp"

static const auto RULES        = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround"};
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"};

CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) {
    const bool VALID = RULES.contains(m_rule) || std::ranges::any_of(RULES_PREFIX, [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });

    if (!VALID)
        return;

    if (m_rule == "noanim")
        m_ruleType = RULE_NOANIM;
    else if (m_rule == "blur")
        m_ruleType = RULE_BLUR;
    else if (m_rule == "blurpopups")
        m_ruleType = RULE_BLURPOPUPS;
    else if (m_rule == "dimaround")
        m_ruleType = RULE_DIMAROUND;
    else if (m_rule.starts_with("ignorealpha"))
        m_ruleType = RULE_IGNOREALPHA;
    else if (m_rule.starts_with("ignorezero"))
        m_ruleType = RULE_IGNOREZERO;
    else if (m_rule.starts_with("xray"))
        m_ruleType = RULE_XRAY;
    else if (m_rule.starts_with("animation"))
        m_ruleType = RULE_ANIMATION;
    else if (m_rule.starts_with("order"))
        m_ruleType = RULE_ORDER;
    else if (m_rule.starts_with("abovelock"))
        m_ruleType = RULE_ABOVELOCK;
    else {
Repository: hyprwm/Hyprland
File: src/xwayland/XWM.hpp (C++)

Code before:

    void             onSelection();
    void             onKeyboardFocus();
    bool             sendData(xcb_selection_request_event_t* e, std::string mime);
    int              onRead(int fd, uint32_t mask);
    int              onWrite();

    struct {
        CHyprSignalListener setSelection;
        CHyprSignalListener keyboardFocusChange;
    } listeners;

    std::vector<UP<SXTransfer>> transfers;
};

class CXCBConnection {
  public:
    CXCBConnection(int fd) : m_connection{xcb_connect_to_fd(fd, nullptr)} {
        ;
    }

    ~CXCBConnection() {
        if (m_connection) {
            std::ostringstream oss;
            oss << "Disconnecting XCB connection 0x" << std::hex << reinterpret_cast<uintptr_t>(m_connection);
            Debug::log(LOG, oss.str());
            xcb_disconnect(m_connection);
            m_connection = nullptr;
        } else
            Debug::log(ERR, "Double xcb_disconnect attempt");
    }

    bool hasError() const {
        return xcb_connection_has_error(m_connection);
    }

    operator xcb_connection_t*() const {
        return m_connection;
    }

  private:
    xcb_connection_t* m_connection = nullptr;
};

class CXCBErrorContext {
  public:
    explicit CXCBErrorContext(xcb_connection_t* connection) {
        if (xcb_errors_context_new(connection, &m_errors) != 0)
            m_errors = nullptr;
    }


Review comment (bug):
wat
```cpp
Debug::log(LOG, "Disconnecting XCB connection {:x}", (uintptr_t)m_connection);
```

Code after:

    void             onSelection();
    void             onKeyboardFocus();
    bool             sendData(xcb_selection_request_event_t* e, std::string mime);
    int              onRead(int fd, uint32_t mask);
    int              onWrite();

    struct {
        CHyprSignalListener setSelection;
        CHyprSignalListener keyboardFocusChange;
    } listeners;

    std::vector<UP<SXTransfer>> transfers;
};

class CXCBConnection {
  public:
    CXCBConnection(int fd) : m_connection{xcb_connect_to_fd(fd, nullptr)} {
        ;
    }

    ~CXCBConnection() {
        if (m_connection) {
            Debug::log(LOG, "Disconnecting XCB connection {:x}", (uintptr_t)m_connection);
            xcb_disconnect(m_connection);
            m_connection = nullptr;
        } else
            Debug::log(ERR, "Double xcb_disconnect attempt");
    }

    bool hasError() const {
        return xcb_connection_has_error(m_connection);
    }

    operator xcb_connection_t*() const {
        return m_connection;
    }

  private:
    xcb_connection_t* m_connection = nullptr;
};

class CXCBErrorContext {
  public:
    explicit CXCBErrorContext(xcb_connection_t* connection) {
        if (xcb_errors_context_new(connection, &m_errors) != 0)
            m_errors = nullptr;
    }

    ~CXCBErrorContext() {
        if (m_errors)
Repository: hyprwm/Hyprland
File: hyprtester/src/tests/main/snap.cpp (C++)

Code before:

    NLog::log("");
    testSnap(false, false);

    NLog::log("\n{}Turning on border_overlap", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap true"));
    testSnap(true, false);

    NLog::log("\n{}Turning on respect_gaps", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap false"));
    OK(getFromSocket("/keyword general:snap:respect_gaps true"));
    testSnap(false, true);

    NLog::log("\n{}Turning on both border_overlap and respect_gaps", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap true"));
    testSnap(true, true);

    // kill all
    NLog::log("\n{}Killing all windows", Colors::YELLOW);
    Tests::killAllWindows();

    NLog::log("{}Expecting 0 windows", Colors::YELLOW);
    EXPECT(Tests::windowCount(), 0);

    NLog::log("{}Removing reserved monitor area from HEADLESS-2", Colors::YELLOW);
    OK(getFromSocket("/keyword monitor HEADLESS-2,addreserved,0,0,0,0"));

    return !ret;
}

REGISTER_TEST_FN(test)


Review comment (suggestion):
I'd just issue `hyprctl reload` instead over the socket, aka `/reload` to clear any unwanted dynamic stuff.

Code after:

    NLog::log("");
    testSnap(false, false);

    NLog::log("\n{}Turning on border_overlap", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap true"));
    testSnap(true, false);

    NLog::log("\n{}Turning on respect_gaps", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap false"));
    OK(getFromSocket("/keyword general:snap:respect_gaps true"));
    testSnap(false, true);

    NLog::log("\n{}Turning on both border_overlap and respect_gaps", Colors::YELLOW);
    OK(getFromSocket("/keyword general:snap:border_overlap true"));
    testSnap(true, true);

    // kill all
    NLog::log("\n{}Killing all windows", Colors::YELLOW);
    Tests::killAllWindows();

    NLog::log("{}Expecting 0 windows", Colors::YELLOW);
    EXPECT(Tests::windowCount(), 0);

    NLog::log("{}Reloading the config", Colors::YELLOW);
    OK(getFromSocket("/reload"));

    return !ret;
}

REGISTER_TEST_FN(test)