fix string literal constness warnings

# Conflicts:
#	src/video/winrt/SDL_winrtvideo.cpp
This commit is contained in:
Shawn Hoffman 2022-12-22 00:12:03 -08:00 committed by Sam Lantinga
parent 7a5a1b16ce
commit 927c4d4aa4
2 changed files with 20 additions and 18 deletions

View file

@ -78,7 +78,7 @@ static GUID IID_IGameBarStatics_ = { MAKELONG(0xA292, 0x1DB9), 0xCC78, 0x4173, {
*/ */
static IGameBarStatics_ *WINRT_GetGameBar() static IGameBarStatics_ *WINRT_GetGameBar()
{ {
wchar_t *wClassName = L"Windows.Gaming.UI.GameBar"; const wchar_t *wClassName = L"Windows.Gaming.UI.GameBar";
HSTRING hClassName; HSTRING hClassName;
IActivationFactory *pActivationFactory = NULL; IActivationFactory *pActivationFactory = NULL;
IGameBarStatics_ *pGameBar = NULL; IGameBarStatics_ *pGameBar = NULL;

View file

@ -30,16 +30,16 @@
/* Standard C++11 includes */ /* Standard C++11 includes */
#include <functional> #include <functional>
#include <string>
#include <sstream> #include <sstream>
#include <string>
using namespace std; using namespace std;
/* Windows includes */ /* Windows includes */
#include <agile.h> #include <agile.h>
#include <windows.graphics.display.h>
#include <windows.system.display.h>
#include <dxgi.h> #include <dxgi.h>
#include <dxgi1_2.h> #include <dxgi1_2.h>
#include <windows.graphics.display.h>
#include <windows.system.display.h>
using namespace Windows::ApplicationModel::Core; using namespace Windows::ApplicationModel::Core;
using namespace Windows::Foundation; using namespace Windows::Foundation;
using namespace Windows::Graphics::Display; using namespace Windows::Graphics::Display;
@ -52,20 +52,20 @@ static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87,
/* SDL includes */ /* SDL includes */
extern "C" { extern "C" {
#include "../SDL_sysvideo.h" #include "../../core/windows/SDL_windows.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#include "../../render/SDL_sysrender.h" #include "../../render/SDL_sysrender.h"
#include "../SDL_pixels_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_winrtopengles.h" #include "SDL_winrtopengles.h"
#include "../../core/windows/SDL_windows.h"
} }
#include "../../core/winrt/SDL_winrtapp_direct3d.h" #include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "../../core/winrt/SDL_winrtapp_xaml.h" #include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtevents_c.h" #include "SDL_winrtevents_c.h"
#include "SDL_winrtgamebar_cpp.h" #include "SDL_winrtgamebar_cpp.h"
#include "SDL_winrtmouse_c.h" #include "SDL_winrtmouse_c.h"
#include "SDL_winrtvideo_cpp.h"
#define SDL_ENABLE_SYSWM_WINRT #define SDL_ENABLE_SYSWM_WINRT
#include <SDL3/SDL_syswm.h> #include <SDL3/SDL_syswm.h>
@ -266,7 +266,6 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
IDXGIOutput *dxgiOutput = NULL; IDXGIOutput *dxgiOutput = NULL;
DXGI_OUTPUT_DESC dxgiOutputDesc; DXGI_OUTPUT_DESC dxgiOutputDesc;
SDL_VideoDisplay display; SDL_VideoDisplay display;
char *displayName = NULL;
UINT numModes; UINT numModes;
DXGI_MODE_DESC *dxgiModes = NULL; DXGI_MODE_DESC *dxgiModes = NULL;
int functionResult = -1; /* -1 for failure, 0 for success */ int functionResult = -1; /* -1 for failure, 0 for success */
@ -304,7 +303,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
*/ */
SDL_DisplayMode mode; SDL_DisplayMode mode;
SDL_zero(mode); SDL_zero(mode);
display.name = "Windows Simulator / Terminal Services Display"; display.name = SDL_strdup("Windows Simulator / Terminal Services Display");
mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left); mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left);
mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top); mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM; mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
@ -318,8 +317,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr); WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr);
goto done; goto done;
} else { } else {
displayName = WIN_StringToUTF8(dxgiOutputDesc.DeviceName); display.name = WIN_StringToUTF8(dxgiOutputDesc.DeviceName);
display.name = displayName;
WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode); WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode);
display.current_mode = display.desktop_mode; display.current_mode = display.desktop_mode;
@ -363,8 +361,8 @@ done:
if (dxgiOutput) { if (dxgiOutput) {
dxgiOutput->Release(); dxgiOutput->Release();
} }
if (displayName) { if (display.name) {
SDL_free(displayName); SDL_free(display.name);
} }
return functionResult; return functionResult;
} }
@ -408,7 +406,7 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a
CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread(); CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread();
SDL_zero(display); SDL_zero(display);
SDL_zero(mode); SDL_zero(mode);
display.name = "DXGI Display-detection Workaround"; display.name = SDL_strdup("DXGI Display-detection Workaround");
/* HACK: ApplicationView's VisibleBounds property, appeared, via testing, to /* HACK: ApplicationView's VisibleBounds property, appeared, via testing, to
give a better approximation of display-size, than did CoreWindow's give a better approximation of display-size, than did CoreWindow's
@ -432,8 +430,12 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a
mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */ mode.refresh_rate = 0; /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
display.desktop_mode = mode; display.desktop_mode = mode;
display.current_mode = mode; display.current_mode = mode;
if ((SDL_AddDisplayMode(&display, &mode) < 0) || bool error = SDL_AddDisplayMode(&display, &mode) < 0 ||
(SDL_AddVideoDisplay(&display, SDL_FALSE) < 0)) { SDL_AddVideoDisplay(&display, SDL_FALSE) < 0;
if (display.name) {
SDL_free(display.name);
}
if (error) {
return SDL_SetError("Failed to apply DXGI Display-detection workaround"); return SDL_SetError("Failed to apply DXGI Display-detection workaround");
} }
} }
@ -803,7 +805,7 @@ int WINRT_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS) static ABI::Windows::System::Display::IDisplayRequest *WINRT_CreateDisplayRequest(_THIS)
{ {
/* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */ /* Setup a WinRT DisplayRequest object, usable for enabling/disabling screensaver requests */
wchar_t *wClassName = L"Windows.System.Display.DisplayRequest"; const wchar_t *wClassName = L"Windows.System.Display.DisplayRequest";
HSTRING hClassName; HSTRING hClassName;
IActivationFactory *pActivationFactory = NULL; IActivationFactory *pActivationFactory = NULL;
IInspectable *pDisplayRequestRaw = nullptr; IInspectable *pDisplayRequestRaw = nullptr;