My way is a little simpler: i wrap a whole while(SDL_PollEvent(&ev)){…} is a nodejs call, and use setInterval to periodically call it.
node-sdl wrappers a single SDL_PollEvent call to a js function, and do while loop in js, but i doubt if it will run in blocking state in Xvfb virtual X server mode…
From running log output, SDL_PollEvent initially can receive SDL_WINDOWEVENT events,
if i don’t do any event loop, then initial window ui will not come out(I use gstreamer to capture the window and use WebRTC streaming to get encoded picture out)
But later SDL_PollEvent will not get any events, for there is no real input device in Xvfb-run mode?
“Standard” event handling in normal SDL2 apps looks like:
SDL_Event ev;
while(SDL_PollEvent(&ev)) {
switch(ev.type) {
// handle event
}
}
// and now render something
// ...
so if SDL_PollEvent() blocked, this wouldn’t work as the while-loop would never be left to render something.
AFAIK SDL_PollEvent() should be called in the main thread (i.e. the one that created the window), is that the case in your app?
And what are you trying to do anyway? This mixture of node.js and SDL looks pretty wild, to be honest.
I’m writing a service for receiving UI view render commands (in json format), and nodejs is used for WebSocket server and also for starting gstreamer to record the app window and push encoded video stream to a webrtc server/