Skip to content

GLFW Window Focus Fix - #8530

Open
danoli3 wants to merge 3 commits into
openframeworks:masterfrom
danoli3:glfw-window-focus
Open

GLFW Window Focus Fix#8530
danoli3 wants to merge 3 commits into
openframeworks:masterfrom
danoli3:glfw-window-focus

Conversation

@danoli3

@danoli3 danoli3 commented Aug 9, 2026

Copy link
Copy Markdown
Member

ofxGLFWWindow Focus

  • Add bWindowFocused member to ofAppGLFWWindow
  • Add focus_cb static callback (matches GLFWfocusfun), registered with
    glfwSetWindowFocusCallback alongside the other window callbacks in setup()
  • Seed initial state from glfwGetWindowAttrib(windowP, GLFW_FOCUSED) right
    after registration, since a window isn't guaranteed to start focused
  • Clear the callback in close() for symmetry with the other teardown calls
  • isWindowActive() now returns bWindowFocused instead of the stub

ofAppGLFWWindow::isWindowActive()was hardcoded toreturn true`, so window now can be detected if active or not active... useful for backgrounding apps running machines, so you can now actively pause or sleep draw or update

@danoli3 danoli3 added this to the 0.12.2 milestone Aug 9, 2026
@danoli3 danoli3 added the glfw label Aug 9, 2026
@danoli3

danoli3 commented Aug 9, 2026

Copy link
Copy Markdown
Member Author

Ideally this should be a windowResized event in coreEvents, &ofBaseApp::windowFocusChanged... however I think for complexity it's easier for the moment to just add it as a ofEvent windowFocusChanged where opt in is:

ofAddListener(ofEvents().windowFocusChanged, this, &MyApp::onFocusChanged)

easy

@danoli3

danoli3 commented Aug 9, 2026

Copy link
Copy Markdown
Member Author

Added ofEvent windowFocusChanged; to ofEvents

@danoli3
danoli3 force-pushed the glfw-window-focus branch from 2a5fdee to 9768350 Compare August 9, 2026 17:33
@danoli3

danoli3 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@ofTheo is ofEvent good idea for now vs change core events virtual function etc... I think this is good to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants