<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Thanks for your answer. I'm a newbie so I still have a few
questions :o) :<br>
<br>
1. I'm unsure of chronology of things to do in the program body. Is the
following correct :<br>
a) Create GTK stuff<br>
b) SDL Hack/SDL_WINDOWID<br>
c) SDL_INIT<br>
d) Show GTK widgets<br>
<br>
2. You mentioned "this is for gtk1 only. gtk2 is similar but different".<br>
What to do for GTK2 ?</tt><tt><br>
<br>
3. Which kind of GTK Object "APanel" can be ?<br>
</tt><tt><br>
4. FPC complains on "handle". What's wrong ? <br>
<br>
Free Pascal Compiler version 2.2.0 [2007/08/30] for i386<br>
Target OS: Linux for i386<br>
Compiling test.pas<br>
test.pas(45,77) Error: Illegal qualifier<br>
test.pas(45,77) Fatal: Syntax error, ")" expected but "identifier
HANDLE" found<br>
Fatal: Compilation aborted<br>
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did
not specify a source file to be compiled)<br>
<br>
Thanks Again.<br>
Tom<br>
<br>
<br>
<br>
<br>
<br>
</tt><br>
Andrew Haines wrote:
<blockquote cite="mid:473CCF05.5000209@aol.com" type="cite">
<pre wrap="">Tom wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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 ?
</pre>
</blockquote>
<pre wrap=""><!---->
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
</pre>
</blockquote>
</body>
</html>