|
@@ -1,10 +1,26 @@
|
|
|
|
|
|
+/* 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"
|
|
@@ -21,20 +37,8 @@ extern "C" {
|
|
|
}
|
|
|
|
|
|
#include "../../video/winrt/SDL_winrtevents_c.h"
|
|
|
-#include "../../video/winrt/SDL_winrtvideo.h"
|
|
|
#include "SDL_winrtapp.h"
|
|
|
|
|
|
-using namespace concurrency;
|
|
|
-using namespace std;
|
|
|
-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;
|
|
|
|
|
|
// Compile-time debugging options:
|
|
|
// To enable, uncomment; to disable, comment them out.
|
|
@@ -140,7 +144,7 @@ static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *n
|
|
|
SDL_WinRTApp::SDL_WinRTApp() :
|
|
|
m_windowClosed(false),
|
|
|
m_windowVisible(true),
|
|
|
- m_sdlWindowData(NULL),
|
|
|
+ m_sdlWindow(NULL),
|
|
|
m_sdlVideoDevice(NULL)
|
|
|
{
|
|
|
}
|
|
@@ -279,16 +283,16 @@ 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, m_sdlWindowData?=%s\n",
|
|
|
+ SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, m_sdlWindow?=%s\n",
|
|
|
__FUNCTION__,
|
|
|
args->Size.Width, args->Size.Height,
|
|
|
(int)DisplayProperties::CurrentOrientation,
|
|
|
(int)DisplayProperties::NativeOrientation,
|
|
|
(int)DisplayProperties::AutoRotationPreferences,
|
|
|
- (m_sdlWindowData ? "yes" : "no"));
|
|
|
+ (m_sdlWindow ? "yes" : "no"));
|
|
|
#endif
|
|
|
|
|
|
- if (m_sdlWindowData) {
|
|
|
+ if (m_sdlWindow) {
|
|
|
// 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.
|
|
@@ -309,7 +313,7 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
|
|
|
const int windowWidth = (int) ceil(args->Size.Width);
|
|
|
const int windowHeight = (int) ceil(args->Size.Height);
|
|
|
SDL_SendWindowEvent(
|
|
|
- m_sdlWindowData->sdlWindow,
|
|
|
+ m_sdlWindow,
|
|
|
SDL_WINDOWEVENT_RESIZED,
|
|
|
windowWidth,
|
|
|
windowHeight);
|
|
@@ -319,20 +323,20 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
|
|
|
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
|
|
|
{
|
|
|
#if LOG_WINDOW_EVENTS==1
|
|
|
- SDL_Log("%s, visible?=%s, m_sdlWindowData?=%s\n",
|
|
|
+ SDL_Log("%s, visible?=%s, m_sdlWindow?=%s\n",
|
|
|
__FUNCTION__,
|
|
|
(args->Visible ? "yes" : "no"),
|
|
|
- (m_sdlWindowData ? "yes" : "no"));
|
|
|
+ (m_sdlWindow ? "yes" : "no"));
|
|
|
#endif
|
|
|
|
|
|
m_windowVisible = args->Visible;
|
|
|
- if (m_sdlWindowData) {
|
|
|
- SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
|
|
|
+ if (m_sdlWindow) {
|
|
|
+ SDL_bool wasSDLWindowSurfaceValid = m_sdlWindow->surface_valid;
|
|
|
|
|
|
if (args->Visible) {
|
|
|
- SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
|
|
|
+ SDL_SendWindowEvent(m_sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
|
|
|
} else {
|
|
|
- SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
|
|
|
+ SDL_SendWindowEvent(m_sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
|
|
|
}
|
|
|
|
|
|
// HACK: Prevent SDL's window-hide handling code, which currently
|
|
@@ -341,7 +345,7 @@ void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEven
|
|
|
//
|
|
|
// A better solution to this probably involves figuring out if the
|
|
|
// fake window resize can be prevented.
|
|
|
- m_sdlWindowData->sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
|
|
|
+ m_sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -355,32 +359,27 @@ void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
|
|
|
|
|
|
void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
|
|
|
{
|
|
|
- SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
|
|
- WINRT_ProcessPointerPressedEvent(window, args);
|
|
|
+ WINRT_ProcessPointerPressedEvent(m_sdlWindow, args);
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
|
|
|
{
|
|
|
- SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
|
|
- WINRT_ProcessPointerReleasedEvent(window, args);
|
|
|
+ WINRT_ProcessPointerReleasedEvent(m_sdlWindow, args);
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
|
|
|
{
|
|
|
- SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
|
|
- WINRT_ProcessPointerWheelChangedEvent(window, args);
|
|
|
+ WINRT_ProcessPointerWheelChangedEvent(m_sdlWindow, args);
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
|
|
|
{
|
|
|
- SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
|
|
- WINRT_ProcessMouseMovedEvent(window, args);
|
|
|
+ WINRT_ProcessMouseMovedEvent(m_sdlWindow, args);
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
|
|
|
{
|
|
|
- SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
|
|
- WINRT_ProcessPointerMovedEvent(window, args);
|
|
|
+ WINRT_ProcessPointerMovedEvent(m_sdlWindow, args);
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
|
|
@@ -439,9 +438,9 @@ void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ a
|
|
|
// 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 (m_sdlWindowData)
|
|
|
+ if (m_sdlWindow)
|
|
|
{
|
|
|
- SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
|
|
|
+ SDL_SendWindowEvent(m_sdlWindow, 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();
|
|
@@ -453,9 +452,9 @@ 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 (m_sdlWindowData)
|
|
|
+ if (m_sdlWindow)
|
|
|
{
|
|
|
- SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
|
|
|
+ SDL_SendWindowEvent(m_sdlWindow, 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.
|
|
@@ -488,19 +487,14 @@ SDL_DisplayMode SDL_WinRTApp::CalcCurrentDisplayMode()
|
|
|
return mode;
|
|
|
}
|
|
|
|
|
|
-const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
|
|
|
-{
|
|
|
- return m_sdlWindowData;
|
|
|
-}
|
|
|
-
|
|
|
-bool SDL_WinRTApp::HasSDLWindowData() const
|
|
|
+SDL_Window * SDL_WinRTApp::GetSDLWindow()
|
|
|
{
|
|
|
- return (m_sdlWindowData != NULL);
|
|
|
+ return m_sdlWindow;
|
|
|
}
|
|
|
|
|
|
-void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData * windowData)
|
|
|
+void SDL_WinRTApp::SetSDLWindow(SDL_Window * window)
|
|
|
{
|
|
|
- m_sdlWindowData = windowData;
|
|
|
+ m_sdlWindow = window;
|
|
|
}
|
|
|
|
|
|
void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
|