<commit_before>#include "kwm.h"

static CGWindowListOption OsxWindowListOption = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements;

extern std::vector<window_info> WindowLst;
extern std::vector<int> FloatingWindowLst;
extern export_table ExportTable;

extern ProcessSerialNumber FocusedPSN;
extern AXUIElementRef FocusedWindowRef;
extern window_info *FocusedWindow;

extern int CurrentSpace;
extern int PrevSpace;
extern int MarkedWindowID;
extern screen_info *Screen;

int OldScreenID = -1;
window_info FocusedWindowCache;

void WriteNameOfFocusedWindowToFile()
{
    std::string Command = "echo \"" + FocusedWindow->Owner + " - " + FocusedWindow->Name + "\" > focus.kwm";
    system(Command.c_str());
}

bool WindowsAreEqual(window_info *Window, window_info *Match)
{
    bool Result = false;

    if(Window && Match)
    {
        if(Window->PID == Match->PID &&
           Window->WID == Match->WID &&
           Window->Layer == Match->Layer)
        {
            Result = true;
        }
    }

    return Result;
}

bool IsWindowPartOfWebBrowser(window_info *Window)
{
    bool Result = false;

    // Any Firefox window that has a width lower than 335 is not a browser window
    if(Window->Owner == "Firefox" &&
       Window->Name == "" &&
       Window->Width < 335) 
            Result = true;

    // Any Safari window that has a width lower than 500 is not a 
    // browser window, but items such as the searchbar and so on
    else if(Window->Owner == "Safari" &&
            Window->Name == "" &&
            Window->Width < 500) 
                 Result = true;

    // Any Google Chrome  window that has a width lower than 400
    // or height lower than 272 is not a browser window
    else if((Window->Owner == "Google Chrome" &&
            Window->Name == "") &&
            (Window->Width < 400 || 
            Window->Height < 272))
                 Result = true;

    return Result;
}

bool FilterWindowList(screen_info *Screen)
{
    bool Result = true;
    std::vector<window_info> FilteredWindowLst;

    for(int WindowIndex = 0; WindowIndex < WindowLst.size(); ++WindowIndex)
    {

        // Mission-Control mode is on and so we do not try to tile windows
        if(WindowLst[WindowIndex].Owner == "Dock" &&
           WindowLst[WindowIndex].Name == "")
               Result = false;

        if(WindowLst[WindowIndex].Layer == 0 &&
           Screen == GetDisplayOfWindow(&WindowLst[WindowIndex]) &&
           !IsWindowPartOfWebBrowser(&WindowLst[WindowIndex]))
               FilteredWindowLst.push_back(WindowLst[WindowIndex]);
    }

    WindowLst = FilteredWindowLst;
    return Result;<commit_msg>ui-elements of finder should be ignored<commit_after>#include "kwm.h"

static CGWindowListOption OsxWindowListOption = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements;

extern std::vector<window_info> WindowLst;
extern std::vector<int> FloatingWindowLst;
extern export_table ExportTable;

extern ProcessSerialNumber FocusedPSN;
extern AXUIElementRef FocusedWindowRef;
extern window_info *FocusedWindow;

extern int CurrentSpace;
extern int PrevSpace;
extern int MarkedWindowID;
extern screen_info *Screen;

int OldScreenID = -1;
window_info FocusedWindowCache;

void WriteNameOfFocusedWindowToFile()
{
    std::string Command = "echo \"" + FocusedWindow->Owner + " - " + FocusedWindow->Name + "\" > focus.kwm";
    system(Command.c_str());
}

bool WindowsAreEqual(window_info *Window, window_info *Match)
{
    bool Result = false;

    if(Window && Match)
    {
        if(Window->PID == Match->PID &&
           Window->WID == Match->WID &&
           Window->Layer == Match->Layer)
        {
            Result = true;
        }
    }

    return Result;
}

bool IsWindowAnElementOfAWindow(window_info *Window)
{
    bool Result = false;

    // Not a valid finder window, probably ui-element
    if((Window->Owner == "Finder" &&
       Window->Name == "") &&
       (Window->Width < 316 ||
        Window->Height < 268))
             Result = true;

    return Result || IsWindowPartOfWebBrowser(Window);
}

bool IsWindowPartOfWebBrowser(window_info *Window)
{
    bool Result = false;

    // Any Firefox window that has a width lower than 335 is not a browser window
    if(Window->Owner == "Firefox" &&
       Window->Name == "" &&
       Window->Width < 335) 
            Result = true;

    // Any Safari window that has a width lower than 500 is not a 
    // browser window, but items such as the searchbar and so on
    else if(Window->Owner == "Safari" &&
            Window->Name == "" &&
            Window->Width < 500) 
                 Result = true;

    // Any Google Chrome  window that has a width lower than 400
    // or height lower than 272 is not a browser window
    else if((Window->Owner == "Google Chrome" &&
            Window->Name == "") &&
            (Window->Width < 400 || 
            Window->Height < 272))
                 Result = true;

    return Result;
}

bool FilterWindowList(screen_info *Screen)
{
    bool Result = true;
    std::vector<window_info> FilteredWindowLst;

    for(int WindowIndex = 0; WindowIndex < WindowLst.size(); ++WindowIndex)
    {
        // Mission-Control mode is on and so we do not try to tile windows
        if(WindowLst[WindowIndex].Owner == "Dock" &&
           WindowLst[WindowIndex].Name == "")
               Result = false;

        if(WindowLst[WindowIndex].Layer == 0 &&
           Screen == GetDisplayOfWindow(&WindowLst[WindowIndex]) &&
           !IsWindowAnElementOfAWindow(&WindowLst[WindowIndex]))
               FilteredWindowLst.push_back(WindowLst[WindowIndex]);
    }

    WindowLst = FilteredWindowLst;
    return Result;
{'fraction_non_alphanumeric': 0.11035087719298245, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 2.7261437908496733, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3767274', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1616, 'n_words': 443}