# SDL_PollEvent in wxWidgets child window

This topic is 3382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is kind of a shot in the dark, but I'm out of ideas, and I really hope someone here might have a clue as to what can be going on here, because I sure don't. My setup is fairly simple. I'm running my game inside of a topmost wxFrame (via the SDL_WINDOWID hack, there are no other windows). Everything works fine except that SDL_PollEvent never gets any events. The moment I remove the SDL_WINDOWID hack, SDL_PollEvent begins to work as expected (returning mouse, keyboard events, etc). I've noticed that the wxFrame is the receiver of mouse events when my SDL window is a child, but it does not receive keyboard events (which prevents me from just avoiding SDL_PollEvent altogether and getting all input from wxFrame). I actually have no idea what happens to keyboard input at all :( I should note that this problem is manifesting on the GTK version of wxWidgets. I haven't gotten a Windows build set up yet, so I don't know how that will behave (and I don't know enough about how GTK works to troubleshoot the message mechanism). Has anyone seen anything like this before (or gotten SDL_PollEvent to work correctly with SDL in a child window)? Btw, this is my window hack code, although I doubt that there is anything wrong with the way it works...
static long WxGetWindowId(const wxWindow* window)
{
#if defined __WXGTK__
return window->m_wxwindow ?
GDK_WINDOW_XWINDOW(GTK_PIZZA(window->m_wxwindow)->bin_window) :
GDK_WINDOW_XWINDOW(window->m_widget->window);
#elif defined __WXMSW__
return reinterpret_cast<long>(window->GetHWND());
#else
return 0;
#endif
}

void WxSetSdlTargetWindow(const wxWindow* window)
{
static char windowHack[256] = {0};
sprintf(windowHack, "SDL_WINDOWID=%ld", WxGetWindowId(window));
putenv(windowHack);
}

Edit: I should add that there is always the possibility of falling back to drawing the SDL surface directly to my wxFrame using the DC, but I would really like to avoid this as it is unbearably slow compared to normal SDL rendering.

##### Share on other sites

This topic is 3382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.