Issues with Gethering SDL events

I am having some trouble getting user input working again.

Once upon a time we had it working correctly, We are trying to use Ogre3d
for 3d rendering and SDL for user input. We started off creating an SDL
window and passing some operating system specific information from SDL into
Ogre3d, and then Ogre could render onto the SDL window just fine, likewise
SDL was gathering all the correct user input events. However, this had some
limitations, Ogre3d could not control the pixel format of the window,
couldn’t adjust anti-aliasing settings, and a few other things. So we
decided to create a window using Ogre3d and try passing some operating
specific token into SDL.

There were some hiccups on windows, but Mako resolved those:
http://forums.libsdl.org/viewtopic.php?t=7589&highlight=
http://forums.libsdl.org/viewtopic.php?t=7426&highlight=
http://forums.libsdl.org/viewtopic.php?t=7415&highlight=

Now it seems fine on Windows, but it no longer works on Linux. Ogre is
rendering to the window, but none of the SDL events are being gathered by
our game code on Linux anymore.

Whats on/in my system in case it matters.

  • Ubuntu 11.04
  • Unity3d desktop environment
  • uname -a reports “Linux fast 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12
    21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux”
  • I have an nVidia 560m that reports as “nVidia Corporation Device 1251
    (rev a1)”
  • I have SDL 1.3 from the mercurial repo at http://hg.libsdl.org/SDL that I
    cloned on Saturday morning. The issue existed on older versions of 1.3 as
    well.

Here is what I know and where I am at:

  • I have all the bug fixes Mako applied to the codebase.
  • This all works fine on Windows, It seems to be a Linux/X11 specific bug.
  • I patched an SDL bug that segfaulted getting when the X11 window title.
  • When I attempt to initialize SDL using SDL_Init(SDL_INIT_VIDEO |
    SDL_INIT_NOPARACHUTE) or SDL_Init(SDL_INIT_VIDEO) it returns successfully,
    despite this I checked SDL_GetError() and it returns “Invalid window” in
    both cases.
  • The windows side also get the “Invalid window” error message but works
    perfectly
  • I am pulling all the events from SDL every frame using SDL_PollEvent()
  • We set an event filter with SDL_SetEventFilter() and our code makes the
    usual calls to it, but SDL does not.

Any ideas? Where else should I look?–

  • Joe Toppi
  • Sqeaky
    (402) 714-7539
    Toppij at gmail.com

After having Mako actually sit down at my machine and take a second stab at
debugging this he found:
------- At Line 219 of SDL_x11window.c ---------
/* FIXME: How can I tell?
{
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
if (style & WS_VISIBLE) {
if (style & (WS_BORDER | WS_THICKFRAME)) {
window->flags &= ~SDL_WINDOW_BORDERLESS;
} else {
window->flags |= SDL_WINDOW_BORDERLESS;
}
if (style & WS_THICKFRAME) {
window->flags |= SDL_WINDOW_RESIZABLE;
} else {
window->flags &= ~SDL_WINDOW_RESIZABLE;
}
if (style & WS_MINIMIZE) {
window->flags |= SDL_WINDOW_MINIMIZED;
} else {
window->flags &= ~SDL_WINDOW_MINIMIZED;
}
}
if (GetFocus() == hwnd) {
int index = data->videodata->keyboard;
window->flags |= SDL_WINDOW_INPUT_FOCUS;
SDL_SetKeyboardFocus(index, data->window);

   if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   RECT rect;
   GetClientRect(hwnd, &rect);
   ClientToScreen(hwnd, (LPPOINT) & rect);
   ClientToScreen(hwnd, (LPPOINT) & rect + 1);
   ClipCursor(&rect);
   }
   }
 */--------------

He says this is a copy/pasta of the windows code. I am looking into
re-implementing for X11. I am not sure that will fix it, but it the best
lead I can see.

On Mon, Oct 10, 2011 at 1:40 PM, Joseph Toppi wrote:

I am having some trouble getting user input working again.

Once upon a time we had it working correctly, We are trying to use Ogre3d
for 3d rendering and SDL for user input. We started off creating an SDL
window and passing some operating system specific information from SDL into
Ogre3d, and then Ogre could render onto the SDL window just fine, likewise
SDL was gathering all the correct user input events. However, this had some
limitations, Ogre3d could not control the pixel format of the window,
couldn’t adjust anti-aliasing settings, and a few other things. So we
decided to create a window using Ogre3d and try passing some operating
specific token into SDL.

There were some hiccups on windows, but Mako resolved those:
http://forums.libsdl.org/viewtopic.php?t=7589&highlight=
http://forums.libsdl.org/viewtopic.php?t=7426&highlight=
http://forums.libsdl.org/viewtopic.php?t=7415&highlight=

Now it seems fine on Windows, but it no longer works on Linux. Ogre is
rendering to the window, but none of the SDL events are being gathered by
our game code on Linux anymore.

Whats on/in my system in case it matters.

  • Ubuntu 11.04
  • Unity3d desktop environment
  • uname -a reports “Linux fast 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12
    21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux”
  • I have an nVidia 560m that reports as “nVidia Corporation Device 1251
    (rev a1)”
  • I have SDL 1.3 from the mercurial repo at http://hg.libsdl.org/SDL that
    I cloned on Saturday morning. The issue existed on older versions of 1.3 as
    well.

Here is what I know and where I am at:

  • I have all the bug fixes Mako applied to the codebase.
  • This all works fine on Windows, It seems to be a Linux/X11 specific bug.
  • I patched an SDL bug that segfaulted getting when the X11 window title.
  • When I attempt to initialize SDL using SDL_Init(SDL_INIT_VIDEO |
    SDL_INIT_NOPARACHUTE) or SDL_Init(SDL_INIT_VIDEO) it returns successfully,
    despite this I checked SDL_GetError() and it returns “Invalid window” in
    both cases.
  • The windows side also get the “Invalid window” error message but works
    perfectly
  • I am pulling all the events from SDL every frame using SDL_PollEvent()
  • We set an event filter with SDL_SetEventFilter() and our code makes the
    usual calls to it, but SDL does not.

Any ideas? Where else should I look?

  • Joe Toppi
  • Sqeaky
    (402) 714-7539
    Toppij at gmail.com

  • Joe Toppi
    (402) 714-7539
    Toppij at gmail.com