Coder Social home page Coder Social logo

Handling Alt-Tab. about sokol HOT 4 OPEN

skejeton avatar skejeton commented on August 15, 2024
Handling Alt-Tab.

from sokol.

Comments (4)

skejeton avatar skejeton commented on August 15, 2024 2

The unfocus workaround worked super well for all my projects, so this can be the reasonable fix users will need to implement.

from sokol.

skejeton avatar skejeton commented on August 15, 2024

So, there's one solution is by detecting window unfocus to drop the key states.

from sokol.

floooh avatar floooh commented on August 15, 2024

Hmm yeah, I haven't been sure tbh whether it should be the responsibility of the user code to drop key presses that were stuck when the window loses focus, or whether sokol_app.h should do this automatically.

I'll try to have a look how GLFW handles this. It probably makes sense to copy their behaviour. It may be tricky on more esoteric platforms like the web though.

In general, listening for the events like UNFOCUSED is the correct workaround.

from sokol.

floooh avatar floooh commented on August 15, 2024

...on further thought, it's tricky to handle inside sokol_app.h I would basically need to remember any pressed key, and then send a KEY_UP event on unfocused (and probably other events like minimized). Since sokol_app.h input is event-based (and not polling-based), that doesn't quite fit int since in an event-driven API there isn't a relationship between different types of input events.

I keep rolling around the idea in my head to have a input-polling header which sits on top of sokol_app.h and which would keep track of input events and offer a simple polling API (which makes a lot more sense for games), and this the unfocused-fix would make a lot more sense such a polling-layer.

from sokol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.