<commit_before>#include "kwm.h"

static CGWindowListOption OsxWindowListOption = kCGWindowListOptionOnScreenOnly | 
                                                   kCGWindowListExcludeDesktopElements;

extern std::vector<window_info> WindowLst;
extern ProcessSerialNumber FocusedPSN;
extern AXUIElementRef FocusedWindowRef;
extern window_info FocusedWindow;
extern bool EnableAutoraise;

bool WindowsAreEqual(window_info *Window, window_info *Match)
{
    if(Window->X == Match->X &&
        Window->Y == Match->Y &&
        Window->Width == Match->Width &&
        Window->Height == Match->Height &&
        Window->Name == Match->Name)
            return true;

    return false;
}

bool IsWindowBelowCursor(window_info *Window)
{
    CGEventRef Event = CGEventCreate(NULL);
    CGPoint Cursor = CGEventGetLocation(Event);
    CFRelease(Event);
    if(Cursor.x >= Window->X && 
            Cursor.x <= Window->X + Window->Width && 
            Cursor.y >= Window->Y && 
            Cursor.y <= Window->Y + Window->Height)
        return true;
        
    return false;
}

void DetectWindowBelowCursor()
{
    WindowLst.clear();

    CFArrayRef OsxWindowLst = CGWindowListCopyWindowInfo(OsxWindowListOption, kCGNullWindowID);
    if(OsxWindowLst)
    {
        CFIndex OsxWindowCount = CFArrayGetCount(OsxWindowLst);
        for(CFIndex WindowIndex = 0; WindowIndex < WindowIndex; ++WindowIndex)
        {
            CFDictionaryRef Elem = (CFDictionaryRef)CFArrayGetValueAtIndex(OsxWindowLst, WindowIndex);
            WindowLst.push_back(window_info());
            CFDictionaryApplyFunction(Elem, GetWindowInfo, NULL);
        }<commit_msg>accidentally used WindowIndex instead of WindowCount<commit_after>#include "kwm.h"

static CGWindowListOption OsxWindowListOption = kCGWindowListOptionOnScreenOnly | 
                                                   kCGWindowListExcludeDesktopElements;

extern std::vector<window_info> WindowLst;
extern ProcessSerialNumber FocusedPSN;
extern AXUIElementRef FocusedWindowRef;
extern window_info FocusedWindow;
extern bool EnableAutoraise;

bool WindowsAreEqual(window_info *Window, window_info *Match)
{
    if(Window->X == Match->X &&
        Window->Y == Match->Y &&
        Window->Width == Match->Width &&
        Window->Height == Match->Height &&
        Window->Name == Match->Name)
            return true;

    return false;
}

bool IsWindowBelowCursor(window_info *Window)
{
    CGEventRef Event = CGEventCreate(NULL);
    CGPoint Cursor = CGEventGetLocation(Event);
    CFRelease(Event);
    if(Cursor.x >= Window->X && 
            Cursor.x <= Window->X + Window->Width && 
            Cursor.y >= Window->Y && 
            Cursor.y <= Window->Y + Window->Height)
        return true;
        
    return false;
}

void DetectWindowBelowCursor()
{
    WindowLst.clear();

    CFArrayRef OsxWindowLst = CGWindowListCopyWindowInfo(OsxWindowListOption, kCGNullWindowID);
    if(OsxWindowLst)
    {
        CFIndex OsxWindowCount = CFArrayGetCount(OsxWindowLst);
        for(CFIndex WindowIndex = 0; WindowIndex < OsxWindowCount; ++WindowIndex)
        {
            CFDictionaryRef Elem = (CFDictionaryRef)CFArrayGetValueAtIndex(OsxWindowLst, WindowIndex);
            WindowLst.push_back(window_info());
            CFDictionaryApplyFunction(Elem, GetWindowInfo, NULL);
        }
{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.0005988023952095808, 'mean_word_length': 2.967933491686461, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3453181', 'n_tokens_mistral': 1002, 'n_tokens_neox': 939, 'n_words': 185}