<commit_before>package lumen.window;

import lumen.LumenTypes;
import lumen.window.Window;
import lumen.utils.Libs;

import lumen.window.system.WindowSystem;
import lumen.window.system.WindowSystem.LumenWindowSystem;

typedef DisplayMode = {
    format : Int,
    refresh_rate : Int,
    width : Int,
    height : Int
}

typedef DisplayBounds = {
    x : Int,
    y : Int,
    width : Int,
    height : Int
}

class Windowing {

    var lib : Lumen;

    public var window_list : Map<Int, Window>;
    public var window_count : Int = 0;
    public var system : LumenWindowSystem;

    public function new( _lib:Lumen ) {

        lib = _lib;
        window_list = new Map();

        system = new LumenWindowSystem(this, lib);

        system.init();

    } //new

//Public facing API

    public function create( _config:WindowConfig ) : Window {

        var _window = new Window( this, _config );

            window_list.set( _window.id, _window );
            window_count++;

        return _window;

    } //create

#if lumen_native

    public function desktop_get_display_count() : Int {
        return lumen_desktop_get_display_count();
    } //desktop_get_display_count

    public function desktop_get_display_mode_count( display:Int ) : Int {
        return lumen_desktop_get_display_mode_count( display );
    } //desktop_get_display_mode_count

    public function desktop_get_display_native_mode( display:Int ) : DisplayMode {
        return lumen_desktop_get_display_native_mode( display );
    } //desktop_get_display_native_mode

    public function desktop_get_display_current_mode( display:Int ) : DisplayMode {
        return lumen_desktop_get_display_current_mode( display );
    } //desktop_get_display_current_mode

    public function desktop_get_display_mode( display:Int, mode_index:Int ) : DisplayMode {
        return lumen_desktop_get_display_mode( display, mode_index );
    } //desktop_get_display_mode

    public function desktop_get_display_bounds( display:Int ) : DisplayBounds {
        return lumen_desktop_get_display_bounds( display );
    } //desktop_get_display_bounds

    public function desktop_get_display_name( display:Int ) : String {
        return lumen_desktop_get_display_name( display );
    } //desktop_get_display_name

#end //lumen_native


//Internal core API


    @:noCompletion public function on_event( _event:SystemEvent ) {

        var _window_event = _event.window;
        _window_event.type = WindowEvents.typed( cast _window_event.type );

        if(_window_event.window_id <= window_count) {
            var _window = window_list.get(_window_event.window_id);
            if(_window != null) {
                _window.on_event( _window_event );
            }
        }

    } //on_event<commit_msg>fixing inconsistent window behaviors when window id's aren't sequential as that isn't always the case. this fixes linux resizing not fixing the viewport and other window events not arriving.<commit_after>package lumen.window;

import lumen.LumenTypes;
import lumen.window.Window;
import lumen.utils.Libs;

import lumen.window.system.WindowSystem;
import lumen.window.system.WindowSystem.LumenWindowSystem;

typedef DisplayMode = {
    format : Int,
    refresh_rate : Int,
    width : Int,
    height : Int
}

typedef DisplayBounds = {
    x : Int,
    y : Int,
    width : Int,
    height : Int
}

class Windowing {

    var lib : Lumen;

    public var window_list : Map<Int, Window>;
    public var window_count : Int = 0;
    public var system : LumenWindowSystem;

    public function new( _lib:Lumen ) {

        lib = _lib;
        window_list = new Map();

        system = new LumenWindowSystem(this, lib);

        system.init();

    } //new

//Public facing API

    public function create( _config:WindowConfig ) : Window {

        var _window = new Window( this, _config );

            window_list.set( _window.id, _window );
            window_count++;

        return _window;

    } //create

#if lumen_native

    public function desktop_get_display_count() : Int {
        return lumen_desktop_get_display_count();
    } //desktop_get_display_count

    public function desktop_get_display_mode_count( display:Int ) : Int {
        return lumen_desktop_get_display_mode_count( display );
    } //desktop_get_display_mode_count

    public function desktop_get_display_native_mode( display:Int ) : DisplayMode {
        return lumen_desktop_get_display_native_mode( display );
    } //desktop_get_display_native_mode

    public function desktop_get_display_current_mode( display:Int ) : DisplayMode {
        return lumen_desktop_get_display_current_mode( display );
    } //desktop_get_display_current_mode

    public function desktop_get_display_mode( display:Int, mode_index:Int ) : DisplayMode {
        return lumen_desktop_get_display_mode( display, mode_index );
    } //desktop_get_display_mode

    public function desktop_get_display_bounds( display:Int ) : DisplayBounds {
        return lumen_desktop_get_display_bounds( display );
    } //desktop_get_display_bounds

    public function desktop_get_display_name( display:Int ) : String {
        return lumen_desktop_get_display_name( display );
    } //desktop_get_display_name

#end //lumen_native


//Internal core API


    @:noCompletion public function on_event( _event:SystemEvent ) {

        var _window_event = _event.window;
        _window_event.type = WindowEvents.typed( cast _window_event.type );

        var _window = window_list.get(_window_event.window_id);
        if(_window != null) {
            _window.on_event( _window_event );
        }

    } //on_event
{'fraction_non_alphanumeric': 0.08092280390417037, 'fraction_numerical': 0.000354924578527063, 'mean_word_length': 3.1532792925571114, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '7287916', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1609, 'n_words': 383}