Skip to content

Commit

Permalink
fix set focused
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Jan 3, 2025
1 parent 21f3616 commit 2d784ed
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/renderer/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,20 @@
(print "You can create or modify shapes using the command line.")
(print "Type (help) to see a list of commands."))

(defn set-focused!
[]
(rf/dispatch [::window.e/set-focused (or (.hasFocus js/document)
(and (dom/frame-document!)
(.hasFocus (dom/frame-document!))))]))

(defn add-listeners!
[]
(.addEventListener js/document "keydown" keyb/event-handler!)
(.addEventListener js/document "keyup" keyb/event-handler!)
(.addEventListener js/document "fullscreenchange" #(rf/dispatch [::window.e/set-fullscreen
(boolean (.-fullscreenElement js/document))]))

(.addEventListener js/document "fullscreenchange" #(rf/dispatch [::window.e/set-fullscreen (boolean (.-fullscreenElement js/document))]))
(.addEventListener js/document "DOMContentLoaded" set-focused!)
(.addEventListener js/window "focus" (rf/dispatch [::window.e/set-focused true]))
(.addEventListener js/window "blur" (rf/dispatch [::window.e/set-focused
(or (.hasFocus js/document)
(and (dom/frame-document!)
(.hasFocus (dom/frame-document!))))]))
(.addEventListener js/window "blur" (set-focused!))

(rf/dispatch [::document.e/center]))

Expand Down

0 comments on commit 2d784ed

Please sign in to comment.