WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)

This commit is contained in:
David Ludwig 2013-09-06 21:13:15 -04:00
parent de8d9dbb93
commit 34722465d1
11 changed files with 204 additions and 204 deletions

View File

@ -197,8 +197,8 @@
<ClInclude Include="..\..\src\audio\SDL_wave.h" /> <ClInclude Include="..\..\src\audio\SDL_wave.h" />
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" /> <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" /> <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" /> <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" /> <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" /> <ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" /> <ClInclude Include="..\..\src\events\default_cursor.h" />
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" /> <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
@ -269,7 +269,13 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" /> <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
@ -281,12 +287,6 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" /> <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" /> <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
<ClCompile Include="..\..\src\events\SDL_dropevents.c" /> <ClCompile Include="..\..\src\events\SDL_dropevents.c" />

View File

@ -321,24 +321,24 @@
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h"> <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\include\SDL_config_winrt.h"> <ClInclude Include="..\..\include\SDL_config_winrt.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c"> <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
@ -581,9 +581,6 @@
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c"> <ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -599,10 +596,13 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp"> <ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp"> <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View File

@ -47,7 +47,15 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" /> <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
@ -63,14 +71,6 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" /> <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" /> <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
<ClCompile Include="..\..\src\events\SDL_dropevents.c" /> <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
@ -244,8 +244,8 @@
<ClInclude Include="..\..\src\audio\SDL_wave.h" /> <ClInclude Include="..\..\src\audio\SDL_wave.h" />
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" /> <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" /> <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" /> <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" /> <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" /> <ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" /> <ClInclude Include="..\..\src\events\default_cursor.h" />
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" /> <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />

View File

@ -258,9 +258,6 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp"> <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -273,7 +270,10 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp"> <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp"> <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -593,21 +593,21 @@
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h"> <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\include\SDL_config_winrt.h"> <ClInclude Include="..\..\include\SDL_config_winrt.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Header Files"> <Filter Include="Header Files">

View File

@ -38,7 +38,7 @@ extern "C" {
#include "../../video/winrt/SDL_winrtevents_c.h" #include "../../video/winrt/SDL_winrtevents_c.h"
#include "../../video/winrt/SDL_winrtvideo_cpp.h" #include "../../video/winrt/SDL_winrtvideo_cpp.h"
#include "SDL_winrtapp.h" #include "SDL_winrtapp_direct3d.h"
// Compile-time debugging options: // Compile-time debugging options:

View File

@ -32,7 +32,7 @@
#include "SDL.h" #include "SDL.h"
#include "../../video/winrt/SDL_winrtevents_c.h" #include "../../video/winrt/SDL_winrtevents_c.h"
#include "../../video/winrt/SDL_winrtvideo_cpp.h" #include "../../video/winrt/SDL_winrtvideo_cpp.h"
#include "SDL_winrtxaml_cpp.h" #include "SDL_winrtapp_xaml.h"
@ -51,28 +51,28 @@ static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
*/ */
#if WINAPI_FAMILY == WINAPI_FAMILY_APP #if WINAPI_FAMILY == WINAPI_FAMILY_APP
static void static void
WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{ {
WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
} }
static void static void
WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{ {
WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
} }
static void static void
WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{ {
WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
} }
static void static void
WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{ {
WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
} }
#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP #endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
@ -128,7 +128,7 @@ SDL_WinRTInitXAMLApp(Platform::Object ^backgroundPanel, int (*mainFunction)(int,
swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML); swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
// Setup for rendering: // Setup for rendering:
IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel); IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative); panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML)); WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));

View File

@ -20,8 +20,8 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#ifndef _SDL_winrtxaml_h #ifndef _SDL_winrtapp_xaml_h
#define _SDL_winrtxaml_h #define _SDL_winrtapp_xaml_h
#include "SDL_types.h" #include "SDL_types.h"
@ -30,4 +30,4 @@ extern SDL_bool WINRT_XAMLWasEnabled;
extern int (*WINRT_XAMLAppMainFunction)(int, char **); extern int (*WINRT_XAMLAppMainFunction)(int, char **);
#endif // ifdef __cplusplus #endif // ifdef __cplusplus
#endif // ifndef _SDL_winrtxaml_h #endif // ifndef _SDL_winrtapp_xaml_h

View File

@ -33,8 +33,8 @@ using Windows::UI::Core::CoreCursor;
* SDL includes: * SDL includes:
*/ */
#include "SDL_winrtevents_c.h" #include "SDL_winrtevents_c.h"
#include "../../core/winrt/SDL_winrtapp.h" #include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "../../core/winrt/SDL_winrtxaml_cpp.h" #include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_assert.h" #include "SDL_assert.h"
#include "SDL_system.h" #include "SDL_system.h"

View File

@ -42,7 +42,7 @@ extern "C" {
#include "SDL_log.h" #include "SDL_log.h"
} }
#include "../../core/winrt/SDL_winrtapp.h" #include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "SDL_winrtvideo_cpp.h" #include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtmouse_c.h" #include "SDL_winrtmouse_c.h"

View File

@ -44,8 +44,8 @@ extern "C" {
#include "SDL_syswm.h" #include "SDL_syswm.h"
} }
#include "../../core/winrt/SDL_winrtapp.h" #include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "../../core/winrt/SDL_winrtxaml_cpp.h" #include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_winrtvideo_cpp.h" #include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtevents_c.h" #include "SDL_winrtevents_c.h"
#include "SDL_winrtmouse_c.h" #include "SDL_winrtmouse_c.h"
@ -61,7 +61,7 @@ static void WINRT_VideoQuit(_THIS);
/* Window functions */ /* Window functions */
static int WINRT_CreateWindow(_THIS, SDL_Window * window); static int WINRT_CreateWindow(_THIS, SDL_Window * window);
static void WINRT_DestroyWindow(_THIS, SDL_Window * window); static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
@ -131,76 +131,76 @@ WINRT_VideoInit(_THIS)
} }
WINRT_InitMouse(_this); WINRT_InitMouse(_this);
WINRT_InitTouch(_this); WINRT_InitTouch(_this);
return 0; return 0;
} }
SDL_DisplayMode SDL_DisplayMode
WINRT_CalcDisplayModeUsingNativeWindow() WINRT_CalcDisplayModeUsingNativeWindow()
{ {
using namespace Windows::Graphics::Display; using namespace Windows::Graphics::Display;
// Create an empty, zeroed-out display mode: // Create an empty, zeroed-out display mode:
SDL_DisplayMode mode; SDL_DisplayMode mode;
SDL_zero(mode); SDL_zero(mode);
// Go no further if a native window cannot be accessed. This can happen, // Go no further if a native window cannot be accessed. This can happen,
// for example, if this function is called from certain threads, such as // for example, if this function is called from certain threads, such as
// the SDL/XAML thread. // the SDL/XAML thread.
if (!CoreWindow::GetForCurrentThread()) { if (!CoreWindow::GetForCurrentThread()) {
return mode; return mode;
} }
// Fill in most fields: // Fill in most fields:
mode.format = SDL_PIXELFORMAT_RGB888; mode.format = SDL_PIXELFORMAT_RGB888;
mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps) mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
mode.driverdata = (void *) DisplayProperties::CurrentOrientation; mode.driverdata = (void *) DisplayProperties::CurrentOrientation;
// Calculate the display size given the window size, taking into account // Calculate the display size given the window size, taking into account
// the current display's DPI: // the current display's DPI:
const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
const float dipsPerInch = 96.0f; const float dipsPerInch = 96.0f;
mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch); mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch); mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
// On Windows Phone, the native window's size is always in portrait, // On Windows Phone, the native window's size is always in portrait,
// regardless of the device's orientation. This is in contrast to // regardless of the device's orientation. This is in contrast to
// Windows 8/RT, which will resize the native window as the device's // Windows 8/RT, which will resize the native window as the device's
// orientation changes. In order to compensate for this behavior, // orientation changes. In order to compensate for this behavior,
// on Windows Phone, the mode's width and height will be swapped when // on Windows Phone, the mode's width and height will be swapped when
// the device is in a landscape (non-portrait) mode. // the device is in a landscape (non-portrait) mode.
switch (DisplayProperties::CurrentOrientation) { switch (DisplayProperties::CurrentOrientation) {
case DisplayOrientations::Landscape: case DisplayOrientations::Landscape:
case DisplayOrientations::LandscapeFlipped: case DisplayOrientations::LandscapeFlipped:
{ {
const int tmp = mode.h; const int tmp = mode.h;
mode.h = mode.w; mode.h = mode.w;
mode.w = tmp; mode.w = tmp;
break; break;
} }
default: default:
break; break;
} }
// Attach the mode to te // Attach the mode to te
#endif #endif
return mode; return mode;
} }
int int
WINRT_InitModes(_THIS) WINRT_InitModes(_THIS)
{ {
// Retrieve the display mode: // Retrieve the display mode:
SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow(); SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
if (mode.w == 0 || mode.h == 0) { if (mode.w == 0 || mode.h == 0) {
return SDL_SetError("Unable to calculate the WinRT window/display's size"); return SDL_SetError("Unable to calculate the WinRT window/display's size");
} }
if (SDL_AddBasicVideoDisplay(&mode) < 0) { if (SDL_AddBasicVideoDisplay(&mode) < 0) {
return -1; return -1;
} }
SDL_AddDisplayMode(&_this->displays[0], &mode); SDL_AddDisplayMode(&_this->displays[0], &mode);
@ -219,64 +219,64 @@ WINRT_VideoQuit(_THIS)
WINRT_QuitMouse(_this); WINRT_QuitMouse(_this);
} }
int int
WINRT_CreateWindow(_THIS, SDL_Window * window) WINRT_CreateWindow(_THIS, SDL_Window * window)
{ {
// Make sure that only one window gets created, at least until multimonitor // Make sure that only one window gets created, at least until multimonitor
// support is added. // support is added.
if (WINRT_GlobalSDLWindow != NULL) { if (WINRT_GlobalSDLWindow != NULL) {
SDL_SetError("WinRT only supports one window"); SDL_SetError("WinRT only supports one window");
return -1; return -1;
} }
SDL_WindowData *data = new SDL_WindowData; SDL_WindowData *data = new SDL_WindowData;
if (!data) { if (!data) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return -1; return -1;
} }
window->driverdata = data; window->driverdata = data;
data->sdlWindow = window; data->sdlWindow = window;
/* To note, when XAML support is enabled, access to the CoreWindow will not /* To note, when XAML support is enabled, access to the CoreWindow will not
be possible, at least not via the SDL/XAML thread. Attempts to access it be possible, at least not via the SDL/XAML thread. Attempts to access it
from there will throw exceptions. As such, the SDL_WindowData's from there will throw exceptions. As such, the SDL_WindowData's
'coreWindow' field will only be set (to a non-null value) if XAML isn't 'coreWindow' field will only be set (to a non-null value) if XAML isn't
enabled. enabled.
*/ */
if (!WINRT_XAMLWasEnabled) { if (!WINRT_XAMLWasEnabled) {
data->coreWindow = CoreWindow::GetForCurrentThread(); data->coreWindow = CoreWindow::GetForCurrentThread();
} }
/* Make sure the window is considered to be positioned at {0,0}, /* Make sure the window is considered to be positioned at {0,0},
and is considered fullscreen, shown, and the like. and is considered fullscreen, shown, and the like.
*/ */
window->x = 0; window->x = 0;
window->y = 0; window->y = 0;
window->flags = window->flags =
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN |
SDL_WINDOW_SHOWN | SDL_WINDOW_SHOWN |
SDL_WINDOW_BORDERLESS | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MAXIMIZED |
SDL_WINDOW_INPUT_GRABBED; SDL_WINDOW_INPUT_GRABBED;
/* WinRT does not, as of this writing, appear to support app-adjustable /* WinRT does not, as of this writing, appear to support app-adjustable
window sizes. Set the window size to whatever the native WinRT window sizes. Set the window size to whatever the native WinRT
CoreWindow is set at. CoreWindow is set at.
TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces. TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces.
*/ */
window->w = _this->displays[0].current_mode.w; window->w = _this->displays[0].current_mode.w;
window->h = _this->displays[0].current_mode.h; window->h = _this->displays[0].current_mode.h;
/* Make sure the WinRT app's IFramworkView can post events on /* Make sure the WinRT app's IFramworkView can post events on
behalf of SDL: behalf of SDL:
*/ */
WINRT_GlobalSDLWindow = window; WINRT_GlobalSDLWindow = window;
/* All done! */ /* All done! */
return 0; return 0;
} }
void void
WINRT_DestroyWindow(_THIS, SDL_Window * window) WINRT_DestroyWindow(_THIS, SDL_Window * window)
{ {
@ -293,21 +293,21 @@ WINRT_DestroyWindow(_THIS, SDL_Window * window)
} }
} }
SDL_bool SDL_bool
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{ {
SDL_WindowData * data = (SDL_WindowData *) window->driverdata; SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
if (info->version.major <= SDL_MAJOR_VERSION) { if (info->version.major <= SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_WINRT; info->subsystem = SDL_SYSWM_WINRT;
info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get()); info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
return SDL_TRUE; return SDL_TRUE;
} else { } else {
SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_SetError("Application not compiled with SDL %d.%d\n",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION); SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE; return SDL_FALSE;
} }
return SDL_FALSE; return SDL_FALSE;
} }
#endif /* SDL_VIDEO_DRIVER_WINRT */ #endif /* SDL_VIDEO_DRIVER_WINRT */