def Wmii.find_client aClientId, *aPlaces
aClientId = aClientId.to_i
needle = Wmii.get_client(aClientId)
if needle.exist?
haystack = []
aPlaces.select {|p| p.exist?}.each do |place|
if place.respond_to? :clients
haystack << place
end
if place.respond_to? :areas
haystack.concat place.areas
end
end
if haystack.empty?
needle.tags.map {|t| get_view t}.each do |v|
haystack.concat v.areas
end
end
haystack.each do |a|
if a.indices.detect {|i| i == aClientId}
return a[aClientId]
end
end
end
puts "could not find client #{aClientId} in area #{aArea.inspect} or view #{aView.inspect}" if $DEBUG
nil
end