Updated to crystal 1.0 json api
Now excludes windows without a name in the list and handles null values for namesmaster
parent
da4f6fd47b
commit
9b5b9b9562
|
@ -3,17 +3,32 @@ require "option_parser"
|
|||
|
||||
version = "0.1"
|
||||
|
||||
struct Nil
|
||||
def includes? ( a : String)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
class Window
|
||||
JSON.mapping({
|
||||
id: UInt32,
|
||||
name: String,
|
||||
wtype: {type: String, key: "type"},
|
||||
app_id: {type: String, default: ""},
|
||||
wclass: {type: String, key: "class", default: ""},
|
||||
marks: {type: Array(String), default: [] of String},
|
||||
nodes: {type: Array(Window), default: [] of Window},
|
||||
focused: {type: Bool, default: false}
|
||||
})
|
||||
include JSON::Serializable
|
||||
|
||||
property id : UInt32 = 0
|
||||
|
||||
@[JSON::Field(emit_null: true)]
|
||||
property name : String?
|
||||
|
||||
@[JSON::Field(key: "type")]
|
||||
property wtype : String = ""
|
||||
|
||||
property app_id : String = ""
|
||||
|
||||
@[JSON::Field(key: "class")]
|
||||
property wclass : String = ""
|
||||
|
||||
property marks : Array(String) = [] of String
|
||||
property nodes : Array(Window) = [] of Window
|
||||
|
||||
property focused : Bool = false
|
||||
|
||||
def clear_nodes
|
||||
@nodes = [] of Window
|
||||
|
@ -23,7 +38,7 @@ end
|
|||
def node_loop (root : Window)
|
||||
list = [] of Window
|
||||
root.nodes.each do |node|
|
||||
if node.wtype == "con"
|
||||
if node.wtype == "con" && !node.name.nil?
|
||||
list << node
|
||||
elsif !node.nodes.empty?
|
||||
list.concat node_loop node
|
||||
|
|
Loading…
Reference in New Issue