+ local entries={}
+ local iter_=addto(entries)
+
+ local function iter(obj)
+ return (not obj_is(obj, "WGroupWS")
+ or iter_(obj))
+ end
+
+ ioncore.region_i(iter)
+
+ return sort(entries)
+end
+
+local function focuslist(do_act)
+ local entries={}
+ local seen={}
+ local iter_=addto(entries)
+
+ local function iter(obj, attr)
+ if obj_is(obj, "WClientWin") then
+ iter_(obj, attr)
+ seen[obj]=true
+ end
+ return true
+ end
+
+ local function iter_act(obj)
+ return iter(obj, "activity")
+ end
+
+ local function iter_foc(obj)
+ return (seen[obj] or iter(obj))
+ end
+
+ if do_act then
+ -- Windows with activity first
+ ioncore.activity_i(iter_act)
+ end
+
+ -- The ones that have been focused in their lifetime
+ ioncore.focushistory_i(iter_foc)
+
+ -- And then the rest
+ ioncore.clientwin_i(iter_foc)
+
+ return entries