Jump to content
  • Advertisement
Sign in to follow this  

SDL_PollEvent in wxWidgets child window

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

If you intended to correct an error in the post then please contact us.

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) :
#elif defined __WXMSW__
    return reinterpret_cast<long>(window->GetHWND());
    return 0;

void WxSetSdlTargetWindow(const wxWindow* window)
    static char windowHack[256] = {0};
    sprintf(windowHack, "SDL_WINDOWID=%ld", WxGetWindowId(window));
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 this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!