The SDL forums have moved to
This is just a read-only archive of the previous forums, to keep old links working.

SDL Forum Index
Simple Directmedia Layer Forums
CreateWindowFrom() on Linux

Joined: 10 Feb 2011
Posts: 46
A colleague of mine is currently trying to replicate my recent efforts on the Linux side of our engine and is having quite a bit more difficult time then I had. He'd be posting this himself but currently can't post on account of waiting for moderator approval. Sad He did sign up for the mailing lists though. Just to help reach as many people as possible I'm posting his email here as well:


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:

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 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?


Also, while source diving I found this bit of code sitting in the linux SetupWindowData() function:
  /* 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);

This is identical to the windows counterpart, and makes reference to windows specific stuff (such as the HWND). So I can see why it was commented out, but I don't understand the comment. It does seem apparent that nothing in SetupWindowData() calls on input, which is why we're having everything but input work properly. Is this snippet of code what is responsible for ensuring input gets registered by the window? Does the Linux side need a counterpart and that is just missing?