Re: Window system dependant parts of gtk (sources), Win32integration
- From: Christiaan Welvaart <C J Welvaart phys uu nl>
- To: gtk-devel-list redhat com
- Subject: Re: Window system dependant parts of gtk (sources), Win32integration
- Date: Tue, 8 Dec 1998 13:44:34 +0100 (MET)
On 26 Nov 1998, Owen Taylor wrote:
> A few techniques that can be used instead of large-scale
> #ifdef's.
>
> 1) Conditionally include files including window-specific
> implementations. (I.e., Raph's suggestion)
>
> 2) Have win32 and unix variants of a few key files, and
> use a different set of files for the Win32 build.
>
> 3) Figure out a way of abstracting a window-system
> dependency to the GDK level. (This is probably the
> most productive, if most difficult, strategy)
Code duplication should be prevented, I guess, so I don't really see the
difference between these three approaches (1 & 2 are ways to implement 3).
If I see it right, GDK contains a lot of functionality by it self, so a
separate window-system dependent layer would be nice. This isn't too
difficult either, since X-specific code is concentrated in a few places,
and is sometimes already put in functions. I don't know if Tor is working
on this, but here are my two cents. (I'm interested in this because I plan
to do a MacOS port of GTK.)
One could define a set of window-system dependent functions, that are
called at fixed points in the GDK code. For example gdk_init does
initialisation of both the internal GDK administration and the window
system. If the current X-dependent code is moved to a function
gdk_init_xwindows, the choice between different window-systems could be
abstracted into a macro. (Is this a good way to do this?) The macro I used
(defined in config.h) is:
#if defined(DISPLAY_XWINDOWS)
#define DISPLAY_SPECIFIC(name) name##_xwindows
#elif defined(DISPLAY_WIN32)
#define DISPLAY_SPECIFIC(name) name##_win32
<and so on>
#endif
"problems":
- Function calls look a bit funny this way, like
DISPLAY_SPECIFIC(gdk_init)();
DISPLAY_SPECIFIC(gdk_event_tranlate)(event);
- no run-time choice between window-systems possible
"advantages":
- many source files can be made window-system independent (the
preprocessor adds the dependencies)
- when the display specific functions are defined as inline, there won't
be much difference with current code after compilation
I'm halfway implementing this in gdk.c, and I didn't find any real
problems, which doesn't prove anything, though... Is this of any use for
GTK?
Christiaan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]