Repository: microsoft/PowerToys
File: src/modules/fancyzones/lib/ZoneSet.cpp (C++)

Code before:
        }
        if (overlap)
        {
            break;
        }
    }

    if (overlap)
    {
        auto zoneArea = [](auto zone) {
            RECT rect = zone->GetZoneRect();
            return max(rect.bottom - rect.top, 0) * max(rect.right - rect.left, 0);
        };

        auto getCenter = [](auto zone) {
            RECT rect = zone->GetZoneRect();
            return POINT{ (rect.right + rect.left) / 2, (rect.top + rect.bottom) / 2 };
        };
        auto pointDifference = [](POINT pt1, POINT pt2) {
            return (pt1.x - pt2.x) * (pt1.x - pt2.x) + (pt1.y - pt2.y) * (pt1.y - pt2.y);
        };
        auto distanceFromCenter = [&](auto zone) {
            POINT center = getCenter(zone);
            return pointDifference(center, pt);
        };
        auto sensitivity = 75;
        auto closerToCenter = [&](auto zone1, auto zone2) {
            if (pointDifference(getCenter(zone1), getCenter(zone2)) > sensitivity)
            {
                return distanceFromCenter(zone1) < distanceFromCenter(zone2);
            }
            else
            {
                return zoneArea(zone1) < zoneArea(zone2);
            };
        };
       
        try
        {
            using Algorithm = Settings::OverlappingZonesAlgorithm;

            switch (m_config.SelectionAlgorithm)
            {
            case Algorithm::Smallest:
                return ZoneSelectPriority(capturedZones, [&](auto zone1, auto zone2) { return zoneArea(zone1) < zoneArea(zone2); });
            case Algorithm::Largest:
                return ZoneSelectPriority(capturedZones, [&](auto zone1, auto zone2) { return zoneArea(zone1) > zoneArea(zone2); });
            case Algorithm::Positional:
                return ZoneSelectSubregion(capturedZones, pt);
            case Algorithm::ClosestCenter:
                return ZoneSelectPriority(capturedZones, closerToCenter);

Review comment (suggestion):
Please, don't use magic numbers. Specify a constant in the namespace at the top of the `ZoneSet.cpp` 

Code after:
            }
        }
        if (overlap)
        {
            break;
        }
    }

    if (overlap)
    {
        auto zoneArea = [](auto zone) {
            RECT rect = zone->GetZoneRect();
            return max(rect.bottom - rect.top, 0) * max(rect.right - rect.left, 0);
        };

        auto getCenter = [](auto zone) {
            RECT rect = zone->GetZoneRect();
            return POINT{ (rect.right + rect.left) / 2, (rect.top + rect.bottom) / 2 };
        };
        auto pointDifference = [](POINT pt1, POINT pt2) {
            return (pt1.x - pt2.x) * (pt1.x - pt2.x) + (pt1.y - pt2.y) * (pt1.y - pt2.y);
        };
        auto distanceFromCenter = [&](auto zone) {
            POINT center = getCenter(zone);
            return pointDifference(center, pt);
        };
        auto closerToCenter = [&](auto zone1, auto zone2) {
            if (pointDifference(getCenter(zone1), getCenter(zone2)) > OVERLAPPING_CENTERS_SENSITIVITY)
            {
                return distanceFromCenter(zone1) < distanceFromCenter(zone2);
            }
            else
            {
                return zoneArea(zone1) < zoneArea(zone2);
            };
        };
       
        try
        {
            using Algorithm = Settings::OverlappingZonesAlgorithm;

            switch (m_config.SelectionAlgorithm)
            {
            case Algorithm::Smallest:
                return ZoneSelectPriority(capturedZones, [&](auto zone1, auto zone2) { return zoneArea(zone1) < zoneArea(zone2); });
            case Algorithm::Largest:
                return ZoneSelectPriority(capturedZones, [&](auto zone1, auto zone2) { return zoneArea(zone1) > zoneArea(zone2); });
            case Algorithm::Positional:
                return ZoneSelectSubregion(capturedZones, pt);
            case Algorithm::ClosestCenter:
                return ZoneSelectPriority(capturedZones, closerToCenter);