1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Window manager related SDL 2 services
18 module syswm
is pkgconfig
"sdl2"
23 #include <SDL2/SDL_syswm.h>
26 redef extern class SDLWindow
27 # Get the `SDLSysVMInfo` for the system running this window
29 # The returned value must be freed.
30 fun wm_info
: SDLSysWMInfo `{
31 SDL_SysWMinfo *val = malloc(sizeof(SDL_SysWMinfo));
33 SDL_VERSION(&val->version);
35 if(SDL_GetWindowWMInfo(recv, val) <= 0) {
44 # Information on the window manager
46 # Created using `SDLWindow::vm_info`
47 extern class SDLSysWMInfo `{ SDL_SysWMinfo * `}
48 # Is this an unknown window manager?
49 fun is_unknown: Bool `{ return recv->subsystem == SDL_SYSWM_UNKNOWN; `}
51 # Is this a Windows system?
52 fun is_windows
: Bool `{ return recv->subsystem == SDL_SYSWM_WINDOWS; `}
54 # Is this the X11 window manager?
55 fun is_x11: Bool `{ return recv->subsystem == SDL_SYSWM_X11; `}
57 # Is this a direct DirectFB?
58 fun is_direcfb
: Bool `{ return recv->subsystem == SDL_SYSWM_DIRECTFB; `}
60 # Is this system an OS X?
61 fun is_cocoa: Bool `{ return recv->subsystem == SDL_SYSWM_COCOA; `}
63 # Is this system an iOS?
64 fun is_uikit
: Bool `{ return recv->subsystem == SDL_SYSWM_UIKIT; `}
66 # It this window manager Wayland?
67 fun is_wayland: Bool `{
68 #if SDL_VERSION_ATLEAST(2, 0, 2)
69 return recv-
>subsystem
== SDL_SYSWM_WAYLAND;
75 # It this window manager Mir?
77 #if SDL_VERSION_ATLEAST(2, 0, 3)
78 return recv-
>subsystem
== SDL_SYSWM_MIR;
84 # Is this system a Windows RT?
86 #if SDL_VERSION_ATLEAST(2, 0, 3)
87 return recv-
>subsystem
== SDL_SYSWM_WINRT;
93 # Is this system an Android?
94 fun is_android: Bool `{
95 #if SDL_VERSION_ATLEAST(2, 0, 4)
96 return recv-
>subsystem
== SDL_SYSWM_ANDROID;
102 # Returns the handle of this window on a X11 window system
105 fun x11_window_handle: Pointer `{
106 return (void
*)recv-
>info
.x11
.window
;