pygame  committed 405796d

wminfo and other additions

  • Participants
  • Parent commits a6278c6

Comments (0)

Files changed (7)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
+July 16, 2004
+    mixer.set_num_channels() no longer crashes [BUG]
+ properly tracks when paused
+    pygame.display.get_wm_info() added, gets a dictionary
 July 6, 2004
     Sound object newstyle types
     added Sound.get_length()

File docs/index.html

 <a href=ref/Rect.html#unionall>Rect.unionall</a> - rectangle covering all inputs<br>
 <a href=ref/Rect.html#unionall_ip>Rect.unionall_ip</a> - rectangle covering all inputs<br>
 <a href=ref/Sound.html#fadeout>Sound.fadeout</a> - fadeout all channels playing this sound<br>
+<a href=ref/Sound.html#get_length>Sound.get_length</a> - get the length of the Sound in seconds.<br>
 <a href=ref/Sound.html#get_num_channels>Sound.get_num_channels</a> - number of channels with sound<br>
 <a href=ref/Sound.html#get_volume>Sound.get_volume</a> - query volume for sound<br>
 <a href=ref/Sound.html#play></a> - play sound<br>
 <a href=ref/pygame_display.html#get_driver>display.get_driver</a> - get the current sdl video driver<br>
 <a href=ref/pygame_display.html#get_init>display.get_init</a> - get status of display module initialization<br>
 <a href=ref/pygame_display.html#get_surface>display.get_surface</a> - get current display surface<br>
+<a href=ref/pygame_display.html#get_wm_info>display.get_wm_info</a> - get settings from the system window manager<br>
 <a href=ref/pygame_display.html#gl_get_attribute>display.gl_get_attribute</a> - get special OPENGL attributes<br>
 <a href=ref/pygame_display.html#gl_set_attribute>display.gl_set_attribute</a> - set special OPENGL attributes<br>
 <a href=ref/pygame_display.html#iconify>display.iconify</a> - minimize the display window<br>

File docs/ref/Sound.html

 fadeout all channels playing this sound</td></tr>
+<tr><td><a href=#get_length>get_length</a></td><td> -
+get the length of the Sound in seconds.</td></tr>
 <tr><td><a href=#get_num_channels>get_num_channels</a></td><td> -
 number of channels with sound</td></tr>
+<a name=get_length><font size=+2><b>get_length
+</b></font><br><font size=+1><tt>
+Sound.get_length() -> float
+Returns the number of seconds this Sound file has
+of data.
 <a name=get_num_channels><font size=+2><b>get_num_channels
 </b></font><br><font size=+1><tt>
 Sound.get_num_channels() -> int

File docs/ref/pygame_display.html

 get current display surface</td></tr>
+<tr><td><a href=#get_wm_info>get_wm_info</a></td><td> -
+get settings from the system window manager</td></tr>
 <tr><td><a href=#gl_get_attribute>gl_get_attribute</a></td><td> -
 get special OPENGL attributes</td></tr>
 return None if called before the display mode is set.
+<a name=get_wm_info><font size=+2><b>get_wm_info
+</b></font><br><font size=+1><tt>
+pygame.display.get_wm_info() -> dictionary
+Creates a dictionary filled with name and value pairs.
+Most platforms will have a 'window' value, set to the
+system's window id number or handle.
+Different platforms will get different key values, which
+are entirely dependent on SDL.
+On rare platforms this is unimplmented in the SDL system, and
+you will get an empty dictionary.
 <a name=gl_get_attribute><font size=+2><b>gl_get_attribute
 </b></font><br><font size=+1><tt>
 pygame.display.gl_get_attribute(flag) -> value

File docs/ref/pygame_image.html

 <h2 align=center>pygame.image</h2>
 This module contains functions to transfer images in and out
-of Surfaces. At the minimum the included <a href=pygame_mixer_music.html#load>load()</a> function will
+of Surfaces. At the minimum the included <a href=#load>load()</a> function will
 support BMP files. If SDL_image is properly installed when
 pygame is installed, it will support all the formats included
 with SDL_image. You can call the <a href=#get_extended>get_extended()</a> function to test

File docs/ref/pygame_mixer_music.html

 The music module has many of the same types of functions as the
 Sound objects. The main difference is only one music object can
-be loaded at a time, with the <a href=#load>load()</a> function. Music
+be loaded at a time, with the <a href=pygame_image.html#load>load()</a> function. Music
 must be stored in an individual file on the system, it cannot be
 loaded from special file-like objects through python.

File src/display.c

 #include "pygame.h"
+#include <SDL_syswm.h>
 static char* pkgdatamodule_name = "pygame.pkgdata";
 static char* resourcepathfunc_name = "getResourcePath";
+    /*DOC*/ static char doc_get_wm_info[] =
+    /*DOC*/    "pygame.display.get_wm_info() -> dictionary\n"
+    /*DOC*/    "get settings from the system window manager\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Creates a dictionary filled with name and value pairs.\n"
+    /*DOC*/    "Most platforms will have a 'window' value, set to the\n"
+    /*DOC*/    "system's window id number or handle.\n"
+    /*DOC*/    "Different platforms will get different key values, which\n"
+    /*DOC*/    "are entirely dependent on SDL.\n"
+    /*DOC*/    "On rare platforms this is unimplmented in the SDL system, and\n"
+    /*DOC*/    "you will get an empty dictionary.\n"
+    /*DOC*/ ;
+static PyObject* get_wm_info(PyObject* self, PyObject* args)
+	PyObject *dict;
+        SDL_SysWMinfo info;
+	if(!PyArg_ParseTuple(args, ""))
+		return NULL;
+        SDL_VERSION(&(info.version))
+        dict = PyDict_New();
+        if(!dict || !SDL_GetWMInfo(&info))
+            return dict;
+/*scary #ifdef's match SDL_syswm.h*/
+#if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \
+    (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX) && \
+     !defined(__QNXNTO__))
+        PyDict_SetItemString(dict, "window", PyInt_FromLong(;
+        PyDict_SetItemString(dict, "display", PyCObject_FromVoidPtr(, NULL));
+        PyDict_SetItemString(dict, "lock_func", PyCObject_FromVoidPtr(, NULL));
+        PyDict_SetItemString(dict, "unlock_func", PyCObject_FromVoidPtr(, NULL));
+        PyDict_SetItemString(dict, "fswindow", PyInt_FromLong(;
+        PyDict_SetItemString(dict, "wmwindow", PyInt_FromLong(;
+#elif defined(ENABLE_NANOX)
+        PyDict_SetItemString(dict, "window", PyInt_FromLong(info.window));
+#elif defined(WIN32)
+        PyDict_SetItemString(dict, "window", PyInt_FromLong(info.window));
+        PyDict_SetItemString(dict, "hglrc", PyInt_FromLong(info.hglrc));
+#elif defined(__riscos__)
+        PyDict_SetItemString(dict, "window", PyInt_FromLong(info.window));
+        PyDict_SetItemString(dict, "wimpVersion", PyInt_FromLong(info.wimpVersion));
+        PyDict_SetItemString(dict, "taskHandle", PyInt_FromLong(info.taskHandle));
+        PyDict_SetItemString(dict, "data", PyInt_FromLong(;
+        return dict;
     /*DOC*/ static char doc_Info[] =
     /*DOC*/    "pygame.display.Info() -> VidInfo\n"
     /*DOC*/    "get display capabilities and settings\n"
 /*	{ "set_driver", set_driver, 1, doc_set_driver },*/
 	{ "get_driver", get_driver, 1, doc_get_driver },
+	{ "get_wm_info", get_wm_info, 1, doc_get_wm_info },
 	{ "Info", Info, 1, doc_Info },
 	{ "get_surface", get_surface, 1, doc_get_surface },
 	{ "gl_set_attribute", gl_set_attribute, 1, doc_gl_set_attribute },
 	{ "gl_get_attribute", gl_get_attribute, 1, doc_gl_get_attribute },
 	{ NULL, NULL }