-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom event carrying a pointer #688
Comments
What I should have done, but didn't think of at the time, is to add a pointer and a callback to that event. As it's too late for that, I'm planning to add a new event with that. In the meantime, you could use a standalone thread safe queue to much the same effect. |
I am thinking doing the reverse and push GLFW events through a pipe to second thread which run the actual event loop by |
typedef void (*GLFWcustomfun)(GLFWwindow*,void*);
GLFWcustomfun glfwSetCustomEventCallback(GLFWwindow* window, GLFWcustomfun cbfun);
void glfwPostCustomEvent(GLFWwindow* window, void* pointer); |
I'll just hijack this thread for the feature if that's all right. |
sounds good. oops... |
Why would this require window system specific code? |
@jadahl If it uses custom window events to interleave with the event stream. |
Is it something like a roundtrip function, i.e. the callback is called when the event has been processed by the display server and been passed back to the application? "CustomEvent" sounds rather like a specially crafted data packet sent to somewhere. |
Or does it just callback to be posted on the main thread? i.e. it won't involve any winsys things, it just needs to be aware of what thread happens to be the one dispatching window system events. If so, couldn't this be done without involving winsys backends? |
@jadahl The former. An actual window system event carrying a pointer, which I imagine would only be posted from secondary threads. This could absolutely be done by a client-side thread safe queue. It's more that it's there; the window system already has a thread safe queue that can carry an opaque pointer on every platform except Mir (where GLFW has one instead) and possibly Wayland, where I haven't had time to check yet. |
@elmindreda What you describe sounds like the latter, i.e. nothing needs to pass by the server. If it's just a callback to run on the main thread, in Wayland you'll have to add an fd to the the poll and make it readable when adding a "custom event" to some list somewhere which is dispatched when the fd becomes readable. |
Postponing this until (if) there's a shared event queue in 4.0. |
hi folks, any progress?:) |
I like to push custom events(file descriptors IO, etc) from a thread to the main thread, I see you can do
glfwPostEmptyEvent
but there is no callback for it. Am I missing something or is there a plan to support this in the future? And how do I tell ifglfwWaitEvent
returns from aglfwPostEmptyEvent
, for now I set a global flag every frame from callbacks and if that flag is not set I assumeglfwPostEmptyEvent
happened, is this reliable?The text was updated successfully, but these errors were encountered: