[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: SDL_GetWMInfo



On Saturday 29 May 2004 04:53, Pete Shinners wrote:

> Passing the WMInfo through would be a good idea. I've never used these
> structures in SDL C, so I wasn't sure how people would want to use them
> in pygame.
>
> If you have a loose spec on how you think it should work I'll probably
> get it into some future release.

I only needed to use the info.x11.wmwindow member of SDL_SysWMinfo to
reparent the Pygame display window into another toolkit, but I can see that
some of the other information would also be useful.

The declaration for SDL_SysWMinfo reads:

typedef struct {
	SDL_version version;
	SDL_SYSWM_TYPE subsystem;
	union {
	    struct {
	    	Display *display;	/* The X11 display */
	    	Window window;		/* The X11 display window */
		/* These locking functions should be called around
                   any X11 functions using the display variable.
                   They lock the event thread, so should not be
		   called around event functions or from event filters.
		 */
		void (*lock_func)(void);
		void (*unlock_func)(void);

		/* Introduced in SDL 1.0.2 */
	    	Window fswindow;	/* The X11 fullscreen window */
	    	Window wmwindow;	/* The X11 managed input window */
	    } x11;
	} info;
} SDL_SysWMinfo;

The SDL version and subsystem might be useful, if they're not already
exposed elsewhere. Of the members of the x11 struct, fswindow and
wmwindow appear to be most useful, although I'm sure a case could be
made for exposing display and window, too.

The lock_func and unlock_func functions don't appear to be particularly
useful for Python programmers.

Since the values in the struct need to be filled in when the information is
required, perhaps the initialisation method of a SysWMinfo class would call
the following code (having defined "info" and claimed memory for the struct):

    SDL_VERSION(&(info->version))
    SDL_GetWMInfo(info);

Each of the relevant members would then be stored as attributes in the newly
created instance.

Comments?

David