 (def clean-state {:mode :none
                   :focused-child nil})
 
-(def having-focus-state {:mode :has-focus
-                         :focused-child nil})
-
-(defn temporarily-taken-from-state [permanent-owner-child dir] {:mode :has-focus
-                                                                :focused-child permanent-owner-child
-                                                                :throw-mode dir})
+(defn having-focus-state [component comment]
+  (do
+    (fg/log-debug "Permanent focus (" comment ") received by" (:id component))
+    {:mode :has-focus
+     :focused-child nil}))
+
+(defn temporarily-taken-from-state [component comment permanent-owner-child dir]
+  (do
+    (fg/log-debug "Temporary focus (" comment ") from" permanent-owner-child "received by" (:id component))
+    {:mode :has-focus
+     :focused-child permanent-owner-child
+     :throw-mode dir}))
 
 (defn focus-child [child-id]
   (if (keyword? child-id)

(defn focus-child-by-direction [child-id dir]
  (assoc (focus-child child-id) :throw-mode dir))

(fg/defevolverfn :focus-state
  (let [reason (fg/get-reason)
        this-focused-child (:focused-child old-focus-state)
        this-mode (:mode old-focus-state)
        parent-focus-state (get-property [] :focus-state)
        parent-focused-child (:focused-child parent-focus-state)
        parent-mode (:mode parent-focus-state)]

        {:mode :requests-focus
         :focused-child this-focused-child}
        (and (:closed-focus-root component) (#{:none :throws-focus :requests-focus} this-mode))
        (having-focus-state component "closed root by mouse")
        (focus-uninterested? component)
        {:mode :got-trigger
         :focused-child nil}
        :else old-focus-state)

      (fgc/parent-reason? reason)
