WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
--- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj Fri Sep 06 21:00:52 2013 -0400
+++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj Fri Sep 06 21:13:15 2013 -0400
@@ -197,8 +197,8 @@
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" />
+ <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
+ <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" />
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
@@ -269,7 +269,13 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile>
<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)'=='Release|ARM'">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)'=='Release|Win32'">true</CompileAsWinRT>
</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\events\SDL_clipboardevents.c" />
<ClCompile Include="..\..\src\events\SDL_dropevents.c" />
--- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters Fri Sep 06 21:00:52 2013 -0400
+++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters Fri Sep 06 21:13:15 2013 -0400
@@ -321,24 +321,24 @@
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
- <Filter>Source Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
- <Filter>Source Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL_config_winrt.h">
<Filter>Header Files</Filter>
</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>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c">
@@ -581,9 +581,6 @@
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -599,10 +596,13 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
+ <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
<Filter>Source Files</Filter>
</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>
</ClCompile>
</ItemGroup>
--- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj Fri Sep 06 21:00:52 2013 -0400
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj Fri Sep 06 21:13:15 2013 -0400
@@ -47,7 +47,15 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<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)'=='Release|ARM'">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)'=='Release|x64'">true</CompileAsWinRT>
</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\events\SDL_clipboardevents.c" />
<ClCompile Include="..\..\src\events\SDL_dropevents.c" />
@@ -244,8 +244,8 @@
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" />
+ <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
+ <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" />
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
--- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters Fri Sep 06 21:00:52 2013 -0400
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters Fri Sep 06 21:13:15 2013 -0400
@@ -258,9 +258,6 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -273,7 +270,10 @@
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
<Filter>Source Files</Filter>
</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>
</ClCompile>
</ItemGroup>
@@ -593,21 +593,21 @@
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
- <Filter>Source Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
- <Filter>Source Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\SDL_config_winrt.h">
<Filter>Header Files</Filter>
</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>
<Filter Include="Header Files">
--- a/src/core/winrt/SDL_winrtapp.cpp Fri Sep 06 21:00:52 2013 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,549 +0,0 @@
-
-/* Standard C++11 includes */
-#include <functional>
-#include <string>
-#include <sstream>
-using namespace std;
-
-
-/* Windows includes */
-#include "ppltasks.h"
-using namespace concurrency;
-using namespace Windows::ApplicationModel;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::ApplicationModel::Activation;
-using namespace Windows::Devices::Input;
-using namespace Windows::Graphics::Display;
-using namespace Windows::Foundation;
-using namespace Windows::System;
-using namespace Windows::UI::Core;
-using namespace Windows::UI::Input;
-
-
-/* SDL includes */
-extern "C" {
-#include "SDL_assert.h"
-#include "SDL_events.h"
-#include "SDL_hints.h"
-#include "SDL_log.h"
-#include "SDL_main.h"
-#include "SDL_stdinc.h"
-#include "SDL_render.h"
-#include "../../video/SDL_sysvideo.h"
-//#include "../../SDL_hints_c.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_windowevents_c.h"
-#include "../../render/SDL_sysrender.h"
-}
-
-#include "../../video/winrt/SDL_winrtevents_c.h"
-#include "../../video/winrt/SDL_winrtvideo_cpp.h"
-#include "SDL_winrtapp.h"
-
-
-// Compile-time debugging options:
-// To enable, uncomment; to disable, comment them out.
-//#define LOG_POINTER_EVENTS 1
-//#define LOG_WINDOW_EVENTS 1
-//#define LOG_ORIENTATION_EVENTS 1
-
-
-// HACK, DLudwig: The C-style main() will get loaded via the app's
-// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
-// This seems wrong on some level, but does seem to work.
-typedef int (*SDL_WinRT_MainFunction)(int, char **);
-static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
-
-// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
-// SDL/WinRT will use this throughout its code.
-//
-// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
-// non-global, such as something created inside
-// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
-// SDL_CreateWindow().
-SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
-
-ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
-{
-public:
- virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
-};
-
-IFrameworkView^ SDLApplicationSource::CreateView()
-{
- // TODO, WinRT: see if this function (CreateView) can ever get called
- // more than once. For now, just prevent it from ever assigning
- // SDL_WinRTGlobalApp more than once.
- SDL_assert(!SDL_WinRTGlobalApp);
- SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
- if (!SDL_WinRTGlobalApp)
- {
- SDL_WinRTGlobalApp = app;
- }
- return app;
-}
-
-__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
-{
- SDL_WinRT_main = mainFunction;
- auto direct3DApplicationSource = ref new SDLApplicationSource();
- CoreApplication::Run(direct3DApplicationSource);
- return 0;
-}
-
-static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
-{
- SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
-
- // Start with no orientation flags, then add each in as they're parsed
- // from newValue.
- unsigned int orientationFlags = 0;
- if (newValue) {
- std::istringstream tokenizer(newValue);
- while (!tokenizer.eof()) {
- std::string orientationName;
- std::getline(tokenizer, orientationName, ' ');
- if (orientationName == "LandscapeLeft") {
- orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
- } else if (orientationName == "LandscapeRight") {
- orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
- } else if (orientationName == "Portrait") {
- orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
- } else if (orientationName == "PortraitUpsideDown") {
- orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
- }
- }
- }
-
- // If no valid orientation flags were specified, use a reasonable set of defaults:
- if (!orientationFlags) {
- // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
- orientationFlags = (unsigned int) ( \
- DisplayOrientations::Landscape |
- DisplayOrientations::LandscapeFlipped |
- DisplayOrientations::Portrait |
- DisplayOrientations::PortraitFlipped);
- }
-
- // Set the orientation/rotation preferences. Please note that this does
- // not constitute a 100%-certain lock of a given set of possible
- // orientations. According to Microsoft's documentation on WinRT [1]
- // when a device is not capable of being rotated, Windows may ignore
- // the orientation preferences, and stick to what the device is capable of
- // displaying.
- //
- // [1] Documentation on the 'InitialRotationPreference' setting for a
- // Windows app's manifest file describes how some orientation/rotation
- // preferences may be ignored. See
- // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
- // for details. Microsoft's "Display orientation sample" also gives an
- // outline of how Windows treats device rotation
- // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
- DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
-}
-
-static void
-WINRT_ProcessWindowSizeChange()
-{
- // Make the new window size be the one true fullscreen mode.
- // This change was initially done, in part, to allow the Direct3D 11.1
- // renderer to receive window-resize events as a device rotates.
- // Before, rotating a device from landscape, to portrait, and then
- // back to landscape would cause the Direct3D 11.1 swap buffer to
- // not get resized appropriately. SDL would, on the rotation from
- // landscape to portrait, re-resize the SDL window to it's initial
- // size (landscape). On the subsequent rotation, SDL would drop the
- // window-resize event as it appeared the SDL window didn't change
- // size, and the Direct3D 11.1 renderer wouldn't resize its swap
- // chain.
- SDL_DisplayMode resizedDisplayMode = WINRT_CalcDisplayModeUsingNativeWindow();
- if (resizedDisplayMode.w == 0 || resizedDisplayMode.h == 0) {
- return;
- }
-
- SDL_DisplayMode oldDisplayMode;
- SDL_zero(oldDisplayMode);
- if (WINRT_GlobalSDLVideoDevice) {
- oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode;
- WINRT_GlobalSDLVideoDevice->displays[0].current_mode = resizedDisplayMode;
- WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
- WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
- }
-
- if (WINRT_GlobalSDLWindow) {
- // Send a window-resize event to the rest of SDL, and to apps:
- SDL_SendWindowEvent(
- WINRT_GlobalSDLWindow,
- SDL_WINDOWEVENT_RESIZED,
- resizedDisplayMode.w,
- resizedDisplayMode.h);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // HACK: On Windows Phone, make sure that orientation changes from
- // Landscape to LandscapeFlipped, Portrait to PortraitFlipped,
- // or vice-versa on either of those two, lead to the Direct3D renderer
- // getting updated.
- const DisplayOrientations oldOrientation = (DisplayOrientations) (unsigned int) oldDisplayMode.driverdata;
- const DisplayOrientations newOrientation = (DisplayOrientations) (unsigned int) resizedDisplayMode.driverdata;
-
- if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) ||
- (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) ||
- (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) ||
- (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait))
- {
- // One of the reasons this event is getting sent out is because SDL
- // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events
- // if and when the event size doesn't change (and the Direct3D 11.1
- // renderer doesn't get the memo).
- //
- // Make sure that the display/window size really didn't change. If
- // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and
- // the Direct3D 11.1 renderer picked it up, presumably.
- if (oldDisplayMode.w == resizedDisplayMode.w &&
- oldDisplayMode.h == resizedDisplayMode.h)
- {
- SDL_SendWindowEvent(
- WINRT_GlobalSDLWindow,
- SDL_WINDOWEVENT_SIZE_CHANGED,
- resizedDisplayMode.w,
- resizedDisplayMode.h);
- }
- }
-#endif
- }
-}
-
-SDL_WinRTApp::SDL_WinRTApp() :
- m_windowClosed(false),
- m_windowVisible(true)
-{
-}
-
-void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
-{
- applicationView->Activated +=
- ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
-
- CoreApplication::Suspending +=
- ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
-
- CoreApplication::Resuming +=
- ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
-
- DisplayProperties::OrientationChanged +=
- ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
-
- // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. This needs to be
- // done before the hint's callback is registered (as of Feb 22, 2013),
- // otherwise the hint callback won't get registered.
- //
- // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
- //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown"); // DavidL: this is no longer needed (for SDL_AddHintCallback)
- SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
-}
-
-void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
-{
-#if LOG_ORIENTATION_EVENTS==1
- CoreWindow^ window = CoreWindow::GetForCurrentThread();
- if (window) {
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- window->Bounds.Width,
- window->Bounds.Height);
- } else {
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences);
- }
-#endif
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // On Windows Phone, treat an orientation change as a change in window size.
- // The native window's size doesn't seem to change, however SDL will simulate
- // a window size change.
- WINRT_ProcessWindowSizeChange();
-#endif
-}
-
-void SDL_WinRTApp::SetWindow(CoreWindow^ window)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- window->Bounds.Width,
- window->Bounds.Height);
-#endif
-
- window->SizeChanged +=
- ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
-
- window->VisibilityChanged +=
- ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
-
- window->Closed +=
- ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
-
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
- window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
-#endif
-
- window->PointerPressed +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
-
- window->PointerMoved +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
-
- window->PointerReleased +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
-
- window->PointerWheelChanged +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
-
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
- // Retrieves relative-only mouse movements:
- Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
- ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
-#endif
-
- window->KeyDown +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
-
- window->KeyUp +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
-}
-
-void SDL_WinRTApp::Load(Platform::String^ entryPoint)
-{
-}
-
-void SDL_WinRTApp::Run()
-{
- SDL_SetMainReady();
- if (SDL_WinRT_main)
- {
- // TODO, WinRT: pass the C-style main() a reasonably realistic
- // representation of command line arguments.
- int argc = 0;
- char **argv = NULL;
- SDL_WinRT_main(argc, argv);
- }
-}
-
-void SDL_WinRTApp::PumpEvents()
-{
- if (!m_windowClosed)
- {
- if (m_windowVisible)
- {
- CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
- }
- else
- {
- CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
- }
- }
-}
-
-void SDL_WinRTApp::Uninitialize()
-{
-}
-
-void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
- __FUNCTION__,
- args->Size.Width, args->Size.Height,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- (WINRT_GlobalSDLWindow ? "yes" : "no"));
-#endif
-
- WINRT_ProcessWindowSizeChange();
-}
-
-void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
- __FUNCTION__,
- (args->Visible ? "yes" : "no"),
- (WINRT_GlobalSDLWindow ? "yes" : "no"));
-#endif
-
- m_windowVisible = args->Visible;
- if (WINRT_GlobalSDLWindow) {
- SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
-
- if (args->Visible) {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
- } else {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
- }
-
- // HACK: Prevent SDL's window-hide handling code, which currently
- // triggers a fake window resize (possibly erronously), from
- // marking the SDL window's surface as invalid.
- //
- // A better solution to this probably involves figuring out if the
- // fake window resize can be prevented.
- WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
- }
-}
-
-void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s\n", __FUNCTION__);
-#endif
- m_windowClosed = true;
-}
-
-void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
-{
- CoreWindow::GetForCurrentThread()->Activate();
-}
-
-static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
-{
- if (event->type == SDL_WINDOWEVENT)
- {
- switch (event->window.event)
- {
- case SDL_WINDOWEVENT_MINIMIZED:
- case SDL_WINDOWEVENT_RESTORED:
- // Return 0 to indicate that the event should be removed from the
- // event queue:
- return 0;
- default:
- break;
- }
- }
-
- // Return 1 to indicate that the event should stay in the event queue:
- return 1;
-}
-
-void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
-{
- // Save app state asynchronously after requesting a deferral. Holding a deferral
- // indicates that the application is busy performing suspending operations. Be
- // aware that a deferral may not be held indefinitely. After about five seconds,
- // the app will be forced to exit.
- SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
- create_task([this, deferral]()
- {
- // Send a window-minimized event immediately to observers.
- // CoreDispatcher::ProcessEvents, which is the backbone on which
- // SDL_WinRTApp::PumpEvents is built, will not return to its caller
- // once it sends out a suspend event. Any events posted to SDL's
- // event queue won't get received until the WinRT app is resumed.
- // SDL_AddEventWatch() may be used to receive app-suspend events on
- // WinRT.
- //
- // In order to prevent app-suspend events from being received twice:
- // first via a callback passed to SDL_AddEventWatch, and second via
- // SDL's event queue, the event will be sent to SDL, then immediately
- // removed from the queue.
- if (WINRT_GlobalSDLWindow)
- {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
- SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
- }
- deferral->Complete();
- });
-}
-
-void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
-{
- // Restore any data or state that was unloaded on suspend. By default, data
- // and state are persisted when resuming from suspend. Note that this event
- // does not occur if the app was previously terminated.
- if (WINRT_GlobalSDLWindow)
- {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
-
- // Remove the app-resume event from the queue, as is done with the
- // app-suspend event.
- //
- // TODO, WinRT: consider posting this event to the queue even though
- // its counterpart, the app-suspend event, effectively has to be
- // processed immediately.
- SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
- }
-}
-
-static void
-WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
-{
- Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
- SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
- header,
- pt->Position.X, pt->Position.Y,
- transformedPoint.X, transformedPoint.Y,
- pt->Properties->MouseWheelDelta,
- pt->FrameId,
- pt->PointerId,
- WINRT_GetSDLButtonForPointerPoint(pt));
-}
-
-void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
- WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
- WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
- WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
-#endif
-
- WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
-{
- WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
-}
-
-void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
- WINRT_ProcessKeyDownEvent(args);
-}
-
-void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
- WINRT_ProcessKeyUpEvent(args);
-}
--- a/src/core/winrt/SDL_winrtapp.h Fri Sep 06 21:00:52 2013 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#pragma once
-
-ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
-{
-public:
- SDL_WinRTApp();
-
- // IFrameworkView Methods.
- virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
- virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
- virtual void Load(Platform::String^ entryPoint);
- virtual void Run();
- virtual void Uninitialize();
-
-internal:
- // SDL-specific methods
- void PumpEvents();
-
-protected:
- // Event Handlers.
- void OnOrientationChanged(Platform::Object^ sender);
- void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
- void OnLogicalDpiChanged(Platform::Object^ sender);
- void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
- void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
- void OnResuming(Platform::Object^ sender, Platform::Object^ args);
- void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
- void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
- void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
- void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
- void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
-
-private:
- bool m_windowClosed;
- bool m_windowVisible;
-};
-
-extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp Fri Sep 06 21:13:15 2013 -0400
@@ -0,0 +1,549 @@
+
+/* Standard C++11 includes */
+#include <functional>
+#include <string>
+#include <sstream>
+using namespace std;
+
+
+/* Windows includes */
+#include "ppltasks.h"
+using namespace concurrency;
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Core;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::Devices::Input;
+using namespace Windows::Graphics::Display;
+using namespace Windows::Foundation;
+using namespace Windows::System;
+using namespace Windows::UI::Core;
+using namespace Windows::UI::Input;
+
+
+/* SDL includes */
+extern "C" {
+#include "SDL_assert.h"
+#include "SDL_events.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"
+#include "SDL_main.h"
+#include "SDL_stdinc.h"
+#include "SDL_render.h"
+#include "../../video/SDL_sysvideo.h"
+//#include "../../SDL_hints_c.h"
+#include "../../events/SDL_mouse_c.h"
+#include "../../events/SDL_windowevents_c.h"
+#include "../../render/SDL_sysrender.h"
+}
+
+#include "../../video/winrt/SDL_winrtevents_c.h"
+#include "../../video/winrt/SDL_winrtvideo_cpp.h"
+#include "SDL_winrtapp_direct3d.h"
+
+
+// Compile-time debugging options:
+// To enable, uncomment; to disable, comment them out.
+//#define LOG_POINTER_EVENTS 1
+//#define LOG_WINDOW_EVENTS 1
+//#define LOG_ORIENTATION_EVENTS 1
+
+
+// HACK, DLudwig: The C-style main() will get loaded via the app's
+// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
+// This seems wrong on some level, but does seem to work.
+typedef int (*SDL_WinRT_MainFunction)(int, char **);
+static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
+
+// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
+// SDL/WinRT will use this throughout its code.
+//
+// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
+// non-global, such as something created inside
+// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
+// SDL_CreateWindow().
+SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
+
+ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
+{
+public:
+ virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
+};
+
+IFrameworkView^ SDLApplicationSource::CreateView()
+{
+ // TODO, WinRT: see if this function (CreateView) can ever get called
+ // more than once. For now, just prevent it from ever assigning
+ // SDL_WinRTGlobalApp more than once.
+ SDL_assert(!SDL_WinRTGlobalApp);
+ SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
+ if (!SDL_WinRTGlobalApp)
+ {
+ SDL_WinRTGlobalApp = app;
+ }
+ return app;
+}
+
+__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
+{
+ SDL_WinRT_main = mainFunction;
+ auto direct3DApplicationSource = ref new SDLApplicationSource();
+ CoreApplication::Run(direct3DApplicationSource);
+ return 0;
+}
+
+static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
+{
+ SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
+
+ // Start with no orientation flags, then add each in as they're parsed
+ // from newValue.
+ unsigned int orientationFlags = 0;
+ if (newValue) {
+ std::istringstream tokenizer(newValue);
+ while (!tokenizer.eof()) {
+ std::string orientationName;
+ std::getline(tokenizer, orientationName, ' ');
+ if (orientationName == "LandscapeLeft") {
+ orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
+ } else if (orientationName == "LandscapeRight") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
+ } else if (orientationName == "Portrait") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
+ } else if (orientationName == "PortraitUpsideDown") {
+ orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
+ }
+ }
+ }
+
+ // If no valid orientation flags were specified, use a reasonable set of defaults:
+ if (!orientationFlags) {
+ // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
+ orientationFlags = (unsigned int) ( \
+ DisplayOrientations::Landscape |
+ DisplayOrientations::LandscapeFlipped |
+ DisplayOrientations::Portrait |
+ DisplayOrientations::PortraitFlipped);
+ }
+
+ // Set the orientation/rotation preferences. Please note that this does
+ // not constitute a 100%-certain lock of a given set of possible
+ // orientations. According to Microsoft's documentation on WinRT [1]
+ // when a device is not capable of being rotated, Windows may ignore
+ // the orientation preferences, and stick to what the device is capable of
+ // displaying.
+ //
+ // [1] Documentation on the 'InitialRotationPreference' setting for a
+ // Windows app's manifest file describes how some orientation/rotation
+ // preferences may be ignored. See
+ // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
+ // for details. Microsoft's "Display orientation sample" also gives an
+ // outline of how Windows treats device rotation
+ // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
+ DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
+}
+
+static void
+WINRT_ProcessWindowSizeChange()
+{
+ // Make the new window size be the one true fullscreen mode.
+ // This change was initially done, in part, to allow the Direct3D 11.1
+ // renderer to receive window-resize events as a device rotates.
+ // Before, rotating a device from landscape, to portrait, and then
+ // back to landscape would cause the Direct3D 11.1 swap buffer to
+ // not get resized appropriately. SDL would, on the rotation from
+ // landscape to portrait, re-resize the SDL window to it's initial
+ // size (landscape). On the subsequent rotation, SDL would drop the
+ // window-resize event as it appeared the SDL window didn't change
+ // size, and the Direct3D 11.1 renderer wouldn't resize its swap
+ // chain.
+ SDL_DisplayMode resizedDisplayMode = WINRT_CalcDisplayModeUsingNativeWindow();
+ if (resizedDisplayMode.w == 0 || resizedDisplayMode.h == 0) {
+ return;
+ }
+
+ SDL_DisplayMode oldDisplayMode;
+ SDL_zero(oldDisplayMode);
+ if (WINRT_GlobalSDLVideoDevice) {
+ oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode;
+ WINRT_GlobalSDLVideoDevice->displays[0].current_mode = resizedDisplayMode;
+ WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
+ WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
+ }
+
+ if (WINRT_GlobalSDLWindow) {
+ // Send a window-resize event to the rest of SDL, and to apps:
+ SDL_SendWindowEvent(
+ WINRT_GlobalSDLWindow,
+ SDL_WINDOWEVENT_RESIZED,
+ resizedDisplayMode.w,
+ resizedDisplayMode.h);
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // HACK: On Windows Phone, make sure that orientation changes from
+ // Landscape to LandscapeFlipped, Portrait to PortraitFlipped,
+ // or vice-versa on either of those two, lead to the Direct3D renderer
+ // getting updated.
+ const DisplayOrientations oldOrientation = (DisplayOrientations) (unsigned int) oldDisplayMode.driverdata;
+ const DisplayOrientations newOrientation = (DisplayOrientations) (unsigned int) resizedDisplayMode.driverdata;
+
+ if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) ||
+ (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) ||
+ (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) ||
+ (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait))
+ {
+ // One of the reasons this event is getting sent out is because SDL
+ // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events
+ // if and when the event size doesn't change (and the Direct3D 11.1
+ // renderer doesn't get the memo).
+ //
+ // Make sure that the display/window size really didn't change. If
+ // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and
+ // the Direct3D 11.1 renderer picked it up, presumably.
+ if (oldDisplayMode.w == resizedDisplayMode.w &&
+ oldDisplayMode.h == resizedDisplayMode.h)
+ {
+ SDL_SendWindowEvent(
+ WINRT_GlobalSDLWindow,
+ SDL_WINDOWEVENT_SIZE_CHANGED,
+ resizedDisplayMode.w,
+ resizedDisplayMode.h);
+ }
+ }
+#endif
+ }
+}
+
+SDL_WinRTApp::SDL_WinRTApp() :
+ m_windowClosed(false),
+ m_windowVisible(true)
+{
+}
+
+void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
+{
+ applicationView->Activated +=
+ ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
+
+ CoreApplication::Suspending +=
+ ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
+
+ CoreApplication::Resuming +=
+ ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
+
+ DisplayProperties::OrientationChanged +=
+ ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
+
+ // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. This needs to be
+ // done before the hint's callback is registered (as of Feb 22, 2013),
+ // otherwise the hint callback won't get registered.
+ //
+ // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
+ //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown"); // DavidL: this is no longer needed (for SDL_AddHintCallback)
+ SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
+}
+
+void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
+{
+#if LOG_ORIENTATION_EVENTS==1
+ CoreWindow^ window = CoreWindow::GetForCurrentThread();
+ if (window) {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+ } else {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences);
+ }
+#endif
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // On Windows Phone, treat an orientation change as a change in window size.
+ // The native window's size doesn't seem to change, however SDL will simulate
+ // a window size change.
+ WINRT_ProcessWindowSizeChange();
+#endif
+}
+
+void SDL_WinRTApp::SetWindow(CoreWindow^ window)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+#endif
+
+ window->SizeChanged +=
+ ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
+
+ window->VisibilityChanged +=
+ ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
+
+ window->Closed +=
+ ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
+#endif
+
+ window->PointerPressed +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
+
+ window->PointerMoved +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
+
+ window->PointerReleased +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
+
+ window->PointerWheelChanged +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ // Retrieves relative-only mouse movements:
+ Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
+ ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
+#endif
+
+ window->KeyDown +=
+ ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
+
+ window->KeyUp +=
+ ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
+}
+
+void SDL_WinRTApp::Load(Platform::String^ entryPoint)
+{
+}
+
+void SDL_WinRTApp::Run()
+{
+ SDL_SetMainReady();
+ if (SDL_WinRT_main)
+ {
+ // TODO, WinRT: pass the C-style main() a reasonably realistic
+ // representation of command line arguments.
+ int argc = 0;
+ char **argv = NULL;
+ SDL_WinRT_main(argc, argv);
+ }
+}
+
+void SDL_WinRTApp::PumpEvents()
+{
+ if (!m_windowClosed)
+ {
+ if (m_windowVisible)
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
+ }
+ else
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
+ }
+ }
+}
+
+void SDL_WinRTApp::Uninitialize()
+{
+}
+
+void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
+ __FUNCTION__,
+ args->Size.Width, args->Size.Height,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ (WINRT_GlobalSDLWindow ? "yes" : "no"));
+#endif
+
+ WINRT_ProcessWindowSizeChange();
+}
+
+void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
+ __FUNCTION__,
+ (args->Visible ? "yes" : "no"),
+ (WINRT_GlobalSDLWindow ? "yes" : "no"));
+#endif
+
+ m_windowVisible = args->Visible;
+ if (WINRT_GlobalSDLWindow) {
+ SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
+
+ if (args->Visible) {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ } else {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
+ }
+
+ // HACK: Prevent SDL's window-hide handling code, which currently
+ // triggers a fake window resize (possibly erronously), from
+ // marking the SDL window's surface as invalid.
+ //
+ // A better solution to this probably involves figuring out if the
+ // fake window resize can be prevented.
+ WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
+ }
+}
+
+void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s\n", __FUNCTION__);
+#endif
+ m_windowClosed = true;
+}
+
+void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
+{
+ CoreWindow::GetForCurrentThread()->Activate();
+}
+
+static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
+{
+ if (event->type == SDL_WINDOWEVENT)
+ {
+ switch (event->window.event)
+ {
+ case SDL_WINDOWEVENT_MINIMIZED:
+ case SDL_WINDOWEVENT_RESTORED:
+ // Return 0 to indicate that the event should be removed from the
+ // event queue:
+ return 0;
+ default:
+ break;
+ }
+ }
+
+ // Return 1 to indicate that the event should stay in the event queue:
+ return 1;
+}
+
+void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
+{
+ // Save app state asynchronously after requesting a deferral. Holding a deferral
+ // indicates that the application is busy performing suspending operations. Be
+ // aware that a deferral may not be held indefinitely. After about five seconds,
+ // the app will be forced to exit.
+ SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
+ create_task([this, deferral]()
+ {
+ // Send a window-minimized event immediately to observers.
+ // CoreDispatcher::ProcessEvents, which is the backbone on which
+ // SDL_WinRTApp::PumpEvents is built, will not return to its caller
+ // once it sends out a suspend event. Any events posted to SDL's
+ // event queue won't get received until the WinRT app is resumed.
+ // SDL_AddEventWatch() may be used to receive app-suspend events on
+ // WinRT.
+ //
+ // In order to prevent app-suspend events from being received twice:
+ // first via a callback passed to SDL_AddEventWatch, and second via
+ // SDL's event queue, the event will be sent to SDL, then immediately
+ // removed from the queue.
+ if (WINRT_GlobalSDLWindow)
+ {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+ deferral->Complete();
+ });
+}
+
+void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
+{
+ // Restore any data or state that was unloaded on suspend. By default, data
+ // and state are persisted when resuming from suspend. Note that this event
+ // does not occur if the app was previously terminated.
+ if (WINRT_GlobalSDLWindow)
+ {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+
+ // Remove the app-resume event from the queue, as is done with the
+ // app-suspend event.
+ //
+ // TODO, WinRT: consider posting this event to the queue even though
+ // its counterpart, the app-suspend event, effectively has to be
+ // processed immediately.
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+}
+
+static void
+WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
+{
+ Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
+ SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
+ header,
+ pt->Position.X, pt->Position.Y,
+ transformedPoint.X, transformedPoint.Y,
+ pt->Properties->MouseWheelDelta,
+ pt->FrameId,
+ pt->PointerId,
+ WINRT_GetSDLButtonForPointerPoint(pt));
+}
+
+void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+ WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+ WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+ WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position));
+#endif
+
+ WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
+{
+ WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
+}
+
+void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ WINRT_ProcessKeyDownEvent(args);
+}
+
+void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ WINRT_ProcessKeyUpEvent(args);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/winrt/SDL_winrtapp_direct3d.h Fri Sep 06 21:13:15 2013 -0400
@@ -0,0 +1,42 @@
+#pragma once
+
+ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
+{
+public:
+ SDL_WinRTApp();
+
+ // IFrameworkView Methods.
+ virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
+ virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
+ virtual void Load(Platform::String^ entryPoint);
+ virtual void Run();
+ virtual void Uninitialize();
+
+internal:
+ // SDL-specific methods
+ void PumpEvents();
+
+protected:
+ // Event Handlers.
+ void OnOrientationChanged(Platform::Object^ sender);
+ void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
+ void OnLogicalDpiChanged(Platform::Object^ sender);
+ void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
+ void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
+ void OnResuming(Platform::Object^ sender, Platform::Object^ args);
+ void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
+ void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
+ void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
+ void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+ void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+
+private:
+ bool m_windowClosed;
+ bool m_windowVisible;
+};
+
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/winrt/SDL_winrtapp_xaml.cpp Fri Sep 06 21:13:15 2013 -0400
@@ -0,0 +1,157 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/* Windows includes */
+#include <agile.h>
+#include <Windows.h>
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+#include <windows.ui.xaml.media.dxinterop.h>
+#endif
+
+
+/* SDL includes */
+#include "SDL.h"
+#include "../../video/winrt/SDL_winrtevents_c.h"
+#include "../../video/winrt/SDL_winrtvideo_cpp.h"
+#include "SDL_winrtapp_xaml.h"
+
+
+
+/* SDL-internal globals: */
+SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
+int (*WINRT_XAMLAppMainFunction)(int, char **) = NULL;
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
+static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
+#endif
+
+
+/*
+ * Input event handlers (XAML)
+ */
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+static void
+WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+
+/*
+ * XAML-to-SDL Rendering Callback
+ */
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+static void
+WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args)
+{
+ WINRT_CycleXAMLThread();
+}
+
+#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+
+/*
+ * SDL + XAML Initialization
+ */
+
+extern "C" int
+SDL_WinRTInitXAMLApp(Platform::Object ^backgroundPanel, int (*mainFunction)(int, char **))
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ return SDL_SetError("XAML support is not yet available in Windows Phone.");
+#else
+ // Declare C++/CX namespaces:
+ using namespace Platform;
+ using namespace Windows::Foundation;
+ using namespace Windows::UI::Core;
+ using namespace Windows::UI::Xaml;
+ using namespace Windows::UI::Xaml::Controls;
+ using namespace Windows::UI::Xaml::Input;
+ using namespace Windows::UI::Xaml::Media;
+
+ // Make sure we have a valid XAML element (to draw onto):
+ if ( ! backgroundPanel) {
+ return SDL_SetError("'backgroundPanel' can't be NULL");
+ }
+
+ SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast<SwapChainBackgroundPanel ^>(backgroundPanel);
+ if ( ! swapChainBackgroundPanel) {
+ return SDL_SetError("An unknown or unsupported type of XAML control was specified.");
+ }
+
+ // Setup event handlers:
+ swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML);
+ swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML);
+ swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML);
+ swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
+
+ // Setup for rendering:
+ IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
+ panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
+
+ WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));
+
+ // Make sure the app is ready to call the SDL-centric main() function:
+ WINRT_XAMLAppMainFunction = mainFunction;
+ SDL_SetMainReady();
+
+ // Make sure video-init knows that we're initializing XAML:
+ SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
+ WINRT_XAMLWasEnabled = SDL_TRUE;
+
+ // Make sure video modes are detected now, while we still have access to the WinRT
+ // CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the
+ // SDL/WinRT thread.
+ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
+ // SDL_InitSubSystem will, on error, set the SDL error. Let that propogate to
+ // the caller to here:
+ WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
+ return -1;
+ }
+
+ // All done, for now.
+ return 0;
+#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/winrt/SDL_winrtapp_xaml.h Fri Sep 06 21:13:15 2013 -0400
@@ -0,0 +1,33 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_winrtapp_xaml_h
+#define _SDL_winrtapp_xaml_h
+
+#include "SDL_types.h"
+
+#ifdef __cplusplus
+extern SDL_bool WINRT_XAMLWasEnabled;
+extern int (*WINRT_XAMLAppMainFunction)(int, char **);
+#endif // ifdef __cplusplus
+
+#endif // ifndef _SDL_winrtapp_xaml_h
--- a/src/core/winrt/SDL_winrtxaml.cpp Fri Sep 06 21:00:52 2013 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-
-/* Windows includes */
-#include <agile.h>
-#include <Windows.h>
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-#include <windows.ui.xaml.media.dxinterop.h>
-#endif
-
-
-/* SDL includes */
-#include "SDL.h"
-#include "../../video/winrt/SDL_winrtevents_c.h"
-#include "../../video/winrt/SDL_winrtvideo_cpp.h"
-#include "SDL_winrtxaml_cpp.h"
-
-
-
-/* SDL-internal globals: */
-SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
-int (*WINRT_XAMLAppMainFunction)(int, char **) = NULL;
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
-static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
-#endif
-
-
-/*
- * Input event handlers (XAML)
- */
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-static void
-WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-
-/*
- * XAML-to-SDL Rendering Callback
- */
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-static void
-WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args)
-{
- WINRT_CycleXAMLThread();
-}
-
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-
-/*
- * SDL + XAML Initialization
- */
-
-extern "C" int
-SDL_WinRTInitXAMLApp(Platform::Object ^backgroundPanel, int (*mainFunction)(int, char **))
-{
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- return SDL_SetError("XAML support is not yet available in Windows Phone.");
-#else
- // Declare C++/CX namespaces:
- using namespace Platform;
- using namespace Windows::Foundation;
- using namespace Windows::UI::Core;
- using namespace Windows::UI::Xaml;
- using namespace Windows::UI::Xaml::Controls;
- using namespace Windows::UI::Xaml::Input;
- using namespace Windows::UI::Xaml::Media;
-
- // Make sure we have a valid XAML element (to draw onto):
- if ( ! backgroundPanel) {
- return SDL_SetError("'backgroundPanel' can't be NULL");
- }
-
- SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast<SwapChainBackgroundPanel ^>(backgroundPanel);
- if ( ! swapChainBackgroundPanel) {
- return SDL_SetError("An unknown or unsupported type of XAML control was specified.");
- }
-
- // Setup event handlers:
- swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML);
- swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML);
- swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML);
- swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
-
- // Setup for rendering:
- IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
- panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
-
- WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));
-
- // Make sure the app is ready to call the SDL-centric main() function:
- WINRT_XAMLAppMainFunction = mainFunction;
- SDL_SetMainReady();
-
- // Make sure video-init knows that we're initializing XAML:
- SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
- WINRT_XAMLWasEnabled = SDL_TRUE;
-
- // Make sure video modes are detected now, while we still have access to the WinRT
- // CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the
- // SDL/WinRT thread.
- if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
- // SDL_InitSubSystem will, on error, set the SDL error. Let that propogate to
- // the caller to here:
- WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
- return -1;
- }
-
- // All done, for now.
- return 0;
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else
-}
--- a/src/core/winrt/SDL_winrtxaml_cpp.h Fri Sep 06 21:00:52 2013 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_winrtxaml_h
-#define _SDL_winrtxaml_h
-
-#include "SDL_types.h"
-
-#ifdef __cplusplus
-extern SDL_bool WINRT_XAMLWasEnabled;
-extern int (*WINRT_XAMLAppMainFunction)(int, char **);
-#endif // ifdef __cplusplus
-
-#endif // ifndef _SDL_winrtxaml_h
--- a/src/video/winrt/SDL_winrtevents.cpp Fri Sep 06 21:00:52 2013 -0400
+++ b/src/video/winrt/SDL_winrtevents.cpp Fri Sep 06 21:13:15 2013 -0400
@@ -33,8 +33,8 @@
* SDL includes:
*/
#include "SDL_winrtevents_c.h"
-#include "../../core/winrt/SDL_winrtapp.h"
-#include "../../core/winrt/SDL_winrtxaml_cpp.h"
+#include "../../core/winrt/SDL_winrtapp_direct3d.h"
+#include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_assert.h"
#include "SDL_system.h"
--- a/src/video/winrt/SDL_winrtmouse.cpp Fri Sep 06 21:00:52 2013 -0400
+++ b/src/video/winrt/SDL_winrtmouse.cpp Fri Sep 06 21:13:15 2013 -0400
@@ -42,7 +42,7 @@
#include "SDL_log.h"
}
-#include "../../core/winrt/SDL_winrtapp.h"
+#include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtmouse_c.h"
--- a/src/video/winrt/SDL_winrtvideo.cpp Fri Sep 06 21:00:52 2013 -0400
+++ b/src/video/winrt/SDL_winrtvideo.cpp Fri Sep 06 21:13:15 2013 -0400
@@ -44,8 +44,8 @@
#include "SDL_syswm.h"
}
-#include "../../core/winrt/SDL_winrtapp.h"
-#include "../../core/winrt/SDL_winrtxaml_cpp.h"
+#include "../../core/winrt/SDL_winrtapp_direct3d.h"
+#include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtevents_c.h"
#include "SDL_winrtmouse_c.h"
@@ -61,7 +61,7 @@
/* 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 SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
@@ -131,76 +131,76 @@
}
WINRT_InitMouse(_this);
WINRT_InitTouch(_this);
-
+
return 0;
}
-SDL_DisplayMode
-WINRT_CalcDisplayModeUsingNativeWindow()
-{
- using namespace Windows::Graphics::Display;
-
- // Create an empty, zeroed-out display mode:
- SDL_DisplayMode mode;
- SDL_zero(mode);
-
- // 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
- // the SDL/XAML thread.
- if (!CoreWindow::GetForCurrentThread()) {
- return mode;
- }
-
- // Fill in most fields:
- mode.format = SDL_PIXELFORMAT_RGB888;
- mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
- mode.driverdata = (void *) DisplayProperties::CurrentOrientation;
-
- // Calculate the display size given the window size, taking into account
- // the current display's DPI:
- const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
- const float dipsPerInch = 96.0f;
- mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
- mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // On Windows Phone, the native window's size is always in portrait,
- // regardless of the device's orientation. This is in contrast to
- // Windows 8/RT, which will resize the native window as the device's
- // orientation changes. In order to compensate for this behavior,
- // on Windows Phone, the mode's width and height will be swapped when
- // the device is in a landscape (non-portrait) mode.
- switch (DisplayProperties::CurrentOrientation) {
- case DisplayOrientations::Landscape:
- case DisplayOrientations::LandscapeFlipped:
- {
- const int tmp = mode.h;
- mode.h = mode.w;
- mode.w = tmp;
- break;
- }
-
- default:
- break;
- }
-
- // Attach the mode to te
-#endif
-
- return mode;
-}
+SDL_DisplayMode
+WINRT_CalcDisplayModeUsingNativeWindow()
+{
+ using namespace Windows::Graphics::Display;
+
+ // Create an empty, zeroed-out display mode:
+ SDL_DisplayMode mode;
+ SDL_zero(mode);
+
+ // 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
+ // the SDL/XAML thread.
+ if (!CoreWindow::GetForCurrentThread()) {
+ return mode;
+ }
+
+ // Fill in most fields:
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
+ mode.driverdata = (void *) DisplayProperties::CurrentOrientation;
+
+ // Calculate the display size given the window size, taking into account
+ // the current display's DPI:
+ const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
+ const float dipsPerInch = 96.0f;
+ mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
+ mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // On Windows Phone, the native window's size is always in portrait,
+ // regardless of the device's orientation. This is in contrast to
+ // Windows 8/RT, which will resize the native window as the device's
+ // orientation changes. In order to compensate for this behavior,
+ // on Windows Phone, the mode's width and height will be swapped when
+ // the device is in a landscape (non-portrait) mode.
+ switch (DisplayProperties::CurrentOrientation) {
+ case DisplayOrientations::Landscape:
+ case DisplayOrientations::LandscapeFlipped:
+ {
+ const int tmp = mode.h;
+ mode.h = mode.w;
+ mode.w = tmp;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ // Attach the mode to te
+#endif
+
+ return mode;
+}
int
WINRT_InitModes(_THIS)
{
// Retrieve the display mode:
- SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
- if (mode.w == 0 || mode.h == 0) {
- return SDL_SetError("Unable to calculate the WinRT window/display's size");
- }
-
- if (SDL_AddBasicVideoDisplay(&mode) < 0) {
- return -1;
+ SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
+ if (mode.w == 0 || mode.h == 0) {
+ return SDL_SetError("Unable to calculate the WinRT window/display's size");
+ }
+
+ if (SDL_AddBasicVideoDisplay(&mode) < 0) {
+ return -1;
}
SDL_AddDisplayMode(&_this->displays[0], &mode);
@@ -219,64 +219,64 @@
WINRT_QuitMouse(_this);
}
-int
-WINRT_CreateWindow(_THIS, SDL_Window * window)
-{
- // Make sure that only one window gets created, at least until multimonitor
- // support is added.
- if (WINRT_GlobalSDLWindow != NULL) {
- SDL_SetError("WinRT only supports one window");
- return -1;
- }
-
- SDL_WindowData *data = new SDL_WindowData;
- if (!data) {
- SDL_OutOfMemory();
- return -1;
- }
- window->driverdata = data;
- data->sdlWindow = window;
-
- /* 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
- 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
- enabled.
- */
- if (!WINRT_XAMLWasEnabled) {
- data->coreWindow = CoreWindow::GetForCurrentThread();
- }
-
- /* Make sure the window is considered to be positioned at {0,0},
- and is considered fullscreen, shown, and the like.
- */
- window->x = 0;
- window->y = 0;
- window->flags =
- SDL_WINDOW_FULLSCREEN |
- SDL_WINDOW_SHOWN |
- SDL_WINDOW_BORDERLESS |
- SDL_WINDOW_MAXIMIZED |
- SDL_WINDOW_INPUT_GRABBED;
-
- /* WinRT does not, as of this writing, appear to support app-adjustable
- window sizes. Set the window size to whatever the native WinRT
- 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.
- */
- window->w = _this->displays[0].current_mode.w;
- window->h = _this->displays[0].current_mode.h;
-
- /* Make sure the WinRT app's IFramworkView can post events on
- behalf of SDL:
- */
- WINRT_GlobalSDLWindow = window;
-
- /* All done! */
- return 0;
-}
-
+int
+WINRT_CreateWindow(_THIS, SDL_Window * window)
+{
+ // Make sure that only one window gets created, at least until multimonitor
+ // support is added.
+ if (WINRT_GlobalSDLWindow != NULL) {
+ SDL_SetError("WinRT only supports one window");
+ return -1;
+ }
+
+ SDL_WindowData *data = new SDL_WindowData;
+ if (!data) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ window->driverdata = data;
+ data->sdlWindow = window;
+
+ /* 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
+ 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
+ enabled.
+ */
+ if (!WINRT_XAMLWasEnabled) {
+ data->coreWindow = CoreWindow::GetForCurrentThread();
+ }
+
+ /* Make sure the window is considered to be positioned at {0,0},
+ and is considered fullscreen, shown, and the like.
+ */
+ window->x = 0;
+ window->y = 0;
+ window->flags =
+ SDL_WINDOW_FULLSCREEN |
+ SDL_WINDOW_SHOWN |
+ SDL_WINDOW_BORDERLESS |
+ SDL_WINDOW_MAXIMIZED |
+ SDL_WINDOW_INPUT_GRABBED;
+
+ /* WinRT does not, as of this writing, appear to support app-adjustable
+ window sizes. Set the window size to whatever the native WinRT
+ 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.
+ */
+ window->w = _this->displays[0].current_mode.w;
+ window->h = _this->displays[0].current_mode.h;
+
+ /* Make sure the WinRT app's IFramworkView can post events on
+ behalf of SDL:
+ */
+ WINRT_GlobalSDLWindow = window;
+
+ /* All done! */
+ return 0;
+}
+
void
WINRT_DestroyWindow(_THIS, SDL_Window * window)
{
@@ -293,21 +293,21 @@
}
}
-SDL_bool
-WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
-{
- SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
-
- if (info->version.major <= SDL_MAJOR_VERSION) {
- info->subsystem = SDL_SYSWM_WINRT;
- info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
- return SDL_TRUE;
- } else {
- SDL_SetError("Application not compiled with SDL %d.%d\n",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
- return SDL_FALSE;
- }
- return SDL_FALSE;
+SDL_bool
+WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
+{
+ SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
+
+ if (info->version.major <= SDL_MAJOR_VERSION) {
+ info->subsystem = SDL_SYSWM_WINRT;
+ info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
+ return SDL_TRUE;
+ } else {
+ SDL_SetError("Application not compiled with SDL %d.%d\n",
+ SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ return SDL_FALSE;
+ }
+ return SDL_FALSE;
}
#endif /* SDL_VIDEO_DRIVER_WINRT */