Tom wrote: > Hi, > > I'm desperately trying to build a application mixing GTK with SDL for *Linux*. > > I know that's not always recommended as it involves 2 listening loops but it > should work. I found some *C* snippets/applications (eg making window hacks) > but > I'm unable to translate them into Pascal. > My goal is to display Joystick events into a GTK2 window. Ideally I would > like > to use Jedi-SDL with GTK2. Of course either GTK2 or SDL used alone works fine. > Does anyone have some example to achieve this ? > >
uses sdl, gtk, gdk, X; var SDLWindowHack: String X11Window: X.TWindow; begin ... // this is for gtk1 only. gtk2 is similar but different X11Window := GDK_WINDOW_XWINDOW(PGdkWindowPrivate(GTK_WIDGET(APanel.Handle)^.window ) ); SDLWindowHack := 'SDL_WINDOWID='+ IntToStr(PtrUint(X11Window)); putenv (PChar(SDLWindowhack)); end; You have to for sure set the environment variable SDL_WINDOWID before you create the window with sdl and maybe before sdl_init. IIRC using this method somehow makes sdl not listen for keyboard/mouse events because it is using a window you have made and expects you to already be processing those events in some way. The other way to embed a window is to create the window normally with sdl without setting SDL_WINDOWID and then accessing the PSurface record get the X11 window ID and use XReparentWindow to embed it into your app. unfortunatly the window is created outside your app and is briefly visible before you have stuck it inside your app. Sdl will behave as if the window is not embedded in your app. Setting keyboard focus and mouse focus in the window may have quirks. Overall I think the first method is best. Setting the SDL_WINDOWID works on windows too if you set it to the (hwnd)TWinControl.Handle of whatever component you want sdl to draw to. Andrew _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal