|
92 | 92 | ["closed" #(reset! main-window nil)]]]
|
93 | 93 | (.on (.-webContents ^js @main-window) web-contents-event f)))
|
94 | 94 |
|
| 95 | +(defn handle-on-ready-to-show! |
| 96 | + [^js window] |
| 97 | + (doseq |
| 98 | + [action |
| 99 | + [(if (.isMaximized window) "window-maximized" "window-unmaximized") |
| 100 | + (if (.isFullScreen window) "window-entered-fullscreen" "window-leaved-fullscreen") |
| 101 | + (if (.isFocused window) "window-focused" "window-blurred") |
| 102 | + "window-loaded"]] |
| 103 | + (send-to-renderer! action))) |
| 104 | + |
95 | 105 | (defn init-main-window!
|
96 | 106 | []
|
97 | 107 | (let [win-state (window-state-keeper #js {:defaultWidth 1920
|
|
112 | 122 | #js {:sandbox false
|
113 | 123 | :preload (.join path js/__dirname "preload.js")}}))
|
114 | 124 |
|
115 |
| - (.once ^js @main-window "ready-to-show" |
| 125 | + (.once ^js @main-window |
| 126 | + "ready-to-show" |
116 | 127 | (fn []
|
117 | 128 | (.show ^js @main-window)
|
118 | 129 | (.manage win-state ^js @main-window)
|
119 | 130 | (.hide ^js @loading-window)
|
120 | 131 | (.close ^js @loading-window)))
|
121 | 132 |
|
122 |
| - (.on ^js @main-window "ready-to-show" |
123 |
| - (fn [] |
124 |
| - (send-to-renderer! (if (.isMaximized ^js @main-window) |
125 |
| - "window-maximized" |
126 |
| - "window-unmaximized")) |
127 |
| - (send-to-renderer! (if (.isFullScreen ^js @main-window) |
128 |
| - "window-entered-fullscreen" |
129 |
| - "window-leaved-fullscreen")) |
130 |
| - (send-to-renderer! (if (.isFocused ^js @main-window) |
131 |
| - "window-focused" |
132 |
| - "window-blurred")) |
133 |
| - (send-to-renderer! "window-loaded"))) |
134 |
| - |
135 |
| - (.loadURL ^js @main-window (if config/debug? |
136 |
| - "http://localhost:8080" |
137 |
| - (.join path "file://" js/__dirname "/public/index.html"))) |
| 133 | + (.on ^js @main-window "ready-to-show" #(handle-on-ready-to-show! @main-window)) |
| 134 | + |
| 135 | + (.loadURL ^js @main-window |
| 136 | + (if config/debug? |
| 137 | + "http://localhost:8080" |
| 138 | + (.join path "file://" js/__dirname "/public/index.html"))) |
138 | 139 |
|
139 | 140 | (register-web-contents-events!)
|
140 | 141 | (register-ipc-on-events!)
|
|
0 commit comments