                       options
                       (safe-fns options))
 
+        display           (or (:display options) 0)
+
         options           (merge (dissoc options :features)
                                  features)
 
-        size              (process-size (:size options))
+        size              (process-size (:size options) display)
         title             (or (:title options) (str "Quil " (swap! untitled-applet-id* inc)))
         renderer          (or (:renderer options) :java2d)
         draw-fn           (or (:draw options) no-fn)

(defn- display-size
  "Returns size of screen. If there are 2 or more screens it probably return size of
  default one whatever it means."
  []
  (let [bounds (.. (java.awt.GraphicsEnvironment/getLocalGraphicsEnvironment)
                   getDefaultScreenDevice
                   getDefaultConfiguration
                   getBounds)]
    [(.-width bounds) (.-height bounds)]))

(defn- process-size
  "Checks that the size vector is exactly two elements. If not, throws
  an exception, otherwise returns the size vector unmodified."
  [size]
  (cond (= size :fullscreen) (display-size)
        (and (coll? size) (= 2 (count size))) size
        :else (throw (IllegalArgumentException.
                      (str "Invalid size definition:" size ". Was expecting :fullscreen or 2 elements vector: [x-size y-size].")))))

(defn- to-method-name [keyword]
  "Converts keyword to java-style method symbol. :on-key-pressed => onKeyPressed"

                                  :draw-fn draw-fn
                                  :renderer renderer
                                  :size size
                                  :display display
                                  :target-frame-rate (atom 60)}
                                 listeners)
        prx-obj           (quil.Applet. applet-state)]
