LCOV - code coverage report
Current view: top level - source/lib/external_libraries - libsdl.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 44 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  *
       3             :  * Permission is hereby granted, free of charge, to any person obtaining
       4             :  * a copy of this software and associated documentation files (the
       5             :  * "Software"), to deal in the Software without restriction, including
       6             :  * without limitation the rights to use, copy, modify, merge, publish,
       7             :  * distribute, sublicense, and/or sell copies of the Software, and to
       8             :  * permit persons to whom the Software is furnished to do so, subject to
       9             :  * the following conditions:
      10             :  *
      11             :  * The above copyright notice and this permission notice shall be included
      12             :  * in all copies or substantial portions of the Software.
      13             :  *
      14             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      15             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      16             :  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      17             :  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
      18             :  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
      19             :  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      20             :  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      21             :  */
      22             : 
      23             : #include "precompiled.h"
      24             : 
      25             : #include "libsdl.h"
      26             : 
      27             : #include "lib/debug.h"
      28             : 
      29             : #include <SDL_error.h>
      30             : #include <SDL_syswm.h>
      31             : 
      32           0 : const char* GetSDLSubsystem(SDL_Window* window)
      33             : {
      34           0 :     SDL_SysWMinfo wminfo;
      35             :     // The info structure must be initialized with the SDL version.
      36           0 :     SDL_VERSION(&wminfo.version);
      37             : 
      38           0 :     if (!SDL_GetWindowWMInfo(window, &wminfo))
      39             :     {
      40           0 :         debug_printf("Failed to query SDL WM info: %s", SDL_GetError());
      41           0 :         return nullptr;
      42             :     }
      43             : 
      44           0 :     const char* subsystem = "unknown";
      45           0 :     switch (wminfo.subsystem)
      46             :     {
      47             :     case SDL_SYSWM_WAYLAND:
      48           0 :         subsystem = "Wayland";
      49             :         break;
      50           0 :     case SDL_SYSWM_X11:
      51           0 :         subsystem = "X11";
      52           0 :         break;
      53           0 :     case SDL_SYSWM_WINDOWS:
      54           0 :         subsystem = "Windows";
      55           0 :         break;
      56           0 :     case SDL_SYSWM_COCOA:
      57           0 :         subsystem = "Cocoa";
      58           0 :         break;
      59           0 :     case SDL_SYSWM_UIKIT:
      60           0 :         subsystem = "UIKit";
      61           0 :         break;
      62           0 :     case SDL_SYSWM_DIRECTFB:
      63           0 :         subsystem = "DirectFB";
      64           0 :         break;
      65           0 :     case SDL_SYSWM_MIR:
      66           0 :         subsystem = "Mir";
      67           0 :         break;
      68             : #if SDL_VERSION_ATLEAST(2, 0, 3)
      69           0 :     case SDL_SYSWM_WINRT:
      70           0 :         subsystem = "WinRT";
      71           0 :         break;
      72             : #endif
      73             : #if SDL_VERSION_ATLEAST(2, 0, 4)
      74           0 :     case SDL_SYSWM_ANDROID:
      75           0 :         subsystem = "Android";
      76           0 :         break;
      77             : #endif
      78             : #if SDL_VERSION_ATLEAST(2, 0, 5)
      79           0 :     case SDL_SYSWM_VIVANTE:
      80           0 :         subsystem = "Vivante";
      81           0 :         break;
      82             : #endif
      83             : #if SDL_VERSION_ATLEAST(2, 0, 6)
      84           0 :     case SDL_SYSWM_OS2:
      85           0 :         subsystem = "OS/2";
      86           0 :         break;
      87             : #endif
      88             : #if SDL_VERSION_ATLEAST(2, 0, 12)
      89           0 :     case SDL_SYSWM_HAIKU:
      90           0 :         subsystem = "Haiku";
      91           0 :         break;
      92             : #endif
      93             : #if SDL_VERSION_ATLEAST(2, 0, 11)
      94           0 :     default:
      95           0 :         debug_printf("Unknown platform, please add it to source/lib/external_libraries/libsdl.cpp\n");
      96             : #endif
      97             :     case SDL_SYSWM_UNKNOWN:
      98             :         break;
      99             :     }
     100             : 
     101             :     return subsystem;
     102             : }

Generated by: LCOV version 1.16