HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
552 stars 44 forks source link

Windows: Mouse cursor is not rendered until its value is changed #170

Closed peteruhnak closed 2 years ago

peteruhnak commented 2 years ago

(on Windows 10) When I open a new window, the cursor is not being rendered until the mouseCursor is changed to a different value (see example at the end).

I am also seeing the same behavior in the JWM example -- you can see that the Arrow button is highlighted, but the cursor only appears on Crosshair

https://user-images.githubusercontent.com/1276328/140554799-95d1fefe-1a6e-4a54-a389-d7a9a54ca1d1.mp4

(ns viz.cursor
  (:import
    (io.github.humbleui.jwm App EventWindowCloseRequest EventFrame LayerGL MouseCursor)
    (java.util.function Consumer)))

(defn user-app []
  (let [window (App/makeWindow)
        layer (new LayerGL)
        _ (.attach layer window)
        _ (.setMouseCursor window MouseCursor/NOT_ALLOWED) ; <-- if I comment out this line, the cursor will not be rendered
        _ (.setMouseCursor window MouseCursor/ARROW)]
    (.setTitle window "cursor example")
    (.setEventListener
      window
      (reify Consumer
        (accept [_ event]
          (cond
            (instance? EventWindowCloseRequest event)
            (do
              (.close window)
              (App/terminate))
            (instance? EventFrame event)
            (do
              (.requestFrame window))))))
    (.setVisible window true)
    (.requestFrame window)))

(defn -main [& _]
  (App/init)
  (user-app)
  (App/start))
tonsky commented 2 years ago

Interesting! I don’t have a windows machine for a next couple of weeks, but will take a look afterwards. Meanwhile, if you can figure that out, I’m happy to accept PR