Browse Source

Refactored GetICCProfile() to return type.

Implemented some more window APIs.
Brucey 3 years ago
parent
commit
3d9598db4d
3 changed files with 54 additions and 6 deletions
  1. 1 0
      sdl.mod/common.bmx
  2. 22 1
      sdlvideo.mod/common.bmx
  3. 31 5
      sdlvideo.mod/sdlvideo.bmx

+ 1 - 0
sdl.mod/common.bmx

@@ -131,6 +131,7 @@ Extern
 	Function SDL_IsTablet:Int()
 	
 	Function SDL_OpenURL:Int(url:Byte Ptr)
+	Function SDL_Free(data:Byte Ptr)
 End Extern
 
 

+ 22 - 1
sdlvideo.mod/common.bmx

@@ -21,6 +21,8 @@
 '
 SuperStrict
 
+Import SDL.SDLSurface
+
 ?win32x86
 Import "../../sdl.mod/sdl.mod/include/win32x86/*.h"
 
@@ -131,7 +133,9 @@ Extern
 	Function SDL_GetCurrentDisplayMode:Int(displayIndex:Int, mode:SDLDisplayMode Var)
 	Function SDL_GetClosestDisplayMode:SDLDisplayMode Ptr(displayIndex:Int, mode:SDLDisplayMode Var, closest:SDLDisplayMode Var)
 	Function SDL_GetWindowICCProfile:Byte Ptr(handle:Byte Ptr, size:Size_T Var)
-	Function SDL_FlashWindow:Int(handle:Byte Ptr, operation:ESDLFlashOperation) 
+	Function SDL_FlashWindow:Int(handle:Byte Ptr, operation:ESDLFlashOperation)
+	Function SDL_SetWindowAlwaysOnTop(handle:Byte Ptr, onTop:Int)
+	Function SDL_SetWindowKeyboardGrab(handle:Byte Ptr, grabbed:Int)
 
 	Function SDL_GetGrabbedWindow:Byte Ptr()
 	Function SDL_IsScreenSaverEnabled:Int()
@@ -445,3 +449,20 @@ Enum ESDLFlashOperation
 	SDL_FLASH_BRIEFLY
 	SDL_FLASH_UNTIL_FOCUSED
 End Enum
+
+Rem
+bbdoc: ICCProfile Data
+End Rem
+Type TICCProfile
+	Field data:Byte Ptr
+	Field size:Size_T
+
+	Method New(data:Byte Ptr, size:Size_T)
+		Self.data = data
+		Self.size = size
+	End Method
+
+	Method Delete()
+		SDL_Free(data)
+	End Method
+End Type

+ 31 - 5
sdlvideo.mod/sdlvideo.bmx

@@ -26,8 +26,6 @@ bbdoc: SDL Video
 End Rem
 Module SDL.SDLVideo
 
-Import SDL.SDLSurface
-
 Import "common.bmx"
 
 Rem
@@ -459,10 +457,11 @@ Type TSDLWindow
 
 	Rem
 	bbdoc: Gets the raw ICC profile data for the screen the window is currently on.
-	about: Data returned should be freed with #SDL_Free.
 	End Rem
-	Method GetICCProfile:Byte Ptr(size:Size_T Var)
-		Return SDL_GetWindowICCProfile(windowPtr, size)
+	Method GetICCProfile:TICCProfile()
+		Local size:Size_T
+		Local data:Byte Ptr = SDL_GetWindowICCProfile(windowPtr, size)
+		Return New TICCProfile(data, size)
 	End Method
 
 	Rem
@@ -473,6 +472,33 @@ Type TSDLWindow
 		Return SDL_FlashWindow(windowPtr, operation)
 	End Method
 
+	Rem
+	bbdoc: Sets the window to always be above the others.
+	about: This will add or remove the window's "SDL_WINDOW_ALWAYS_ON_TOP" flag. This will bring the window to the front and keep the window above the rest.
+	End Rem
+	Method SetAlwaysOnTop(onTop:Int)
+		SDL_SetWindowAlwaysOnTop(windowPtr, onTop)
+	End Method
+
+	Rem
+	bbdoc: Sets the window's keyboard grab mode.
+	about: Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or the Meta/Super key. Note that not all system keyboard shortcuts can be
+	captured by applications (one example is Ctrl+Alt+Del on Windows).
+
+	This is primarily intended for specialized applications such as VNC clients or VM frontends. Normal games should not use keyboard grab.
+
+	When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
+	window is full-screen to ensure the user is not trapped in your
+	application. If you have a custom keyboard shortcut to exit fullscreen
+	mode, you may suppress this behavior with `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
+
+	If the caller enables a grab while another window is currently grabbed, the
+	other window loses its grab in favor of the caller's window.
+	End Rem
+	Method SetKeyboardGrab(grabbed:Int)
+		SDL_SetWindowKeyboardGrab(windowPtr, grabbed)
+	End Method
+
 End Type
 
 Rem