 (def old-bounds (atom {}))
 
 (defn full-screen!
-  "Make the given window/frame full-screen. Pass nil to return all windows
-to normal size."
+  "Make the given window/frame full-screen."
   [window]
-  (when window
+  (when (and window (not (@old-bounds window)))
     (when-not (@old-bounds window)
       (swap! old-bounds assoc window (.getBounds window)))
     (.dispose window)

                                

(defn handle-wheel [component z-atom]
  (.addMouseWheelListener component
    (proxy [MouseAdapter] []
      (mouseWheelMoved [e]
                       (swap! z-atom update-in [:z]
                              + (.getWheelRotation e)))))
  z-atom)

(defn handle-resize [component size-atom]
  (let [update-size #(let [bounds (.getBounds component)]

    (.show window)))

(defn exit-full-screen!
  "Restore the given full-screened window to its previous
   (non-full-screen) bounds."
  [window]
  (when (and window (@old-bounds window))
    (.dispose window)
    (.setUndecorated window false)
    (when (JavaUtils/isMac)
      (.setFullScreenWindow (window-screen window) nil))
    (when-let [bounds (@old-bounds window)]
      (.setBounds window bounds)
      (swap! old-bounds dissoc window))
    (.repaint window)
    (.show window)))

