<commit_before>//
//  WindowInfo.swift
//  ScreenRecord
//
//  Created by nakajijapan on 2016/02/24.
//  Copyright © 2016 nakajijapan. All rights reserved.
//

import Foundation
import Cocoa

class WindowInfo:NSObject {
    var order:Int?
    var windowID:CGWindowID?
    var windowName:String?
    var ownerName:String?
    var	layer:Int32?
    var frame:NSRect?
    
    func toString(cfstring: CFString) -> String {
        let string = cfstring as NSString
        return string as String
    }
    
    init(item: [String: AnyObject]) {
        super.init()
        
        ownerName = item[kCGWindowOwnerName.toString] as? String
        layer = (item[kCGWindowLayer.toString] as! NSNumber).int32Value
        let bounds = item[kCGWindowBounds.toString] as! Dictionary<String, CGFloat>
        
        let cgFrame = CGRect(x: bounds["X"]!, y: bounds["Y"]!, width: bounds["Width"]!, height: bounds["Height"]!)

        var frame = NSRectFromCGRect(cgFrame)
        frame.origin = convertPosition(frame)
        
        let differencialValue = CGFloat(SengiriCropViewLineWidth - 2)
        let optimizeFrame = NSRect(
            x: frame.origin.x - differencialValue,
            y: frame.origin.y - differencialValue,
            width: frame.width + differencialValue * 2.0,
            height: frame.height + differencialValue * 2.0
        )
        
        frame = optimizeFrame
    }
    
    func convertPosition(_ frame:NSRect) -> NSPoint {
        let mainFrame = NSScreen.main()?.frame;
        var convertedPoint = frame.origin
        
        let y = mainFrame!.height - (frame.origin.y + frame.size.height)
        convertedPoint.y = y
        
        return convertedPoint
    }
    
    func isNormalWindow(_ normal:Bool) -> Bool {
        
        if ownerName! == "Dock" {
            return false
        }
        
        if normal && layer == CGWindowLevelForKey(.normalWindow) {
            return true
        }
        
        if normal && layer! < CGWindowLevelForKey(.mainMenuWindow) {
            return true
        }
        
        return false
    }
}<commit_msg>fram info was no data<commit_after>//
//  WindowInfo.swift
//  ScreenRecord
//
//  Created by nakajijapan on 2016/02/24.
//  Copyright © 2016 nakajijapan. All rights reserved.
//

import Foundation
import Cocoa

struct WindowInfo {
    var order: Int?
    var windowID: CGWindowID?
    var windowName = ""
    var ownerName = ""
    var layer: Int32 = 0
    var frame = NSRect.zero
    
    init(item: [String: AnyObject]) {

        ownerName = item[kCGWindowOwnerName.toString] as! String
        layer = (item[kCGWindowLayer.toString] as! NSNumber).int32Value
        let bounds = item[kCGWindowBounds.toString] as! Dictionary<String, CGFloat>
        
        let cgFrame = CGRect(x: bounds["X"]!, y: bounds["Y"]!, width: bounds["Width"]!, height: bounds["Height"]!)

        var windowFrame = NSRectFromCGRect(cgFrame)
        windowFrame.origin = convertPosition(windowFrame)
        
        let differencialValue = CGFloat(SengiriCropViewLineWidth - 2)
        let optimizeFrame = NSRect(
            x: windowFrame.origin.x - differencialValue,
            y: windowFrame.origin.y - differencialValue,
            width: windowFrame.width + differencialValue * 2.0,
            height: windowFrame.height + differencialValue * 2.0
        )

        frame = optimizeFrame
    }
    
    func convertPosition(_ frame:NSRect) -> NSPoint {
        let mainFrame = NSScreen.main()?.frame
        var convertedPoint = frame.origin
        
        let y = mainFrame!.height - (frame.origin.y + frame.size.height)
        convertedPoint.y = y
        
        return convertedPoint
    }
    
    func isNormalWindow(_ normal:Bool) -> Bool {
        
        if ownerName == "Dock" {
            return false
        }
        
        if normal && layer == CGWindowLevelForKey(.normalWindow) {
            return true
        }
        
        if normal && layer < CGWindowLevelForKey(.mainMenuWindow) {
            return true
        }
        
        return false
    }
}
{'fraction_non_alphanumeric': 0.09762662099339368, 'fraction_numerical': 0.010521164668460974, 'mean_word_length': 2.0147492625368733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '1324778', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1181, 'n_words': 283}