lib/sdl: intro services to get the X11 window handle
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 14 Jan 2014 16:43:44 +0000 (11:43 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 26 Feb 2014 16:58:14 +0000 (11:58 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/mnit_linux/sdl.nit

index 094905b..839c2e1 100644 (file)
@@ -468,3 +468,26 @@ extern SDLFont in "C" `{TTF_Font *`}
                        return w;
        `}
 end
+
+# Information on the SDL window
+# Used in other modules to get window handle
+extern class SDLSystemWindowManagerInfo `{SDL_SysWMinfo *`}
+
+       new `{
+               SDL_SysWMinfo *val = malloc(sizeof(SDL_SysWMinfo));
+
+               SDL_VERSION(&val->version);
+
+               if(SDL_GetWMInfo(val) <= 0) {
+                       printf("Unable to get window handle");
+                       return 0;
+               }
+
+               return val;
+       `}
+
+       # Returns the handle of this window on a X11 window system
+       fun x11_window_handle: Pointer `{
+               return (void*)recv->info.x11.window;
+       `}
+end