WinRT: misc code cleanups
parent
f8e80edf09
commit
3e83fd784c
|
@ -286,7 +286,6 @@
|
||||||
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
|
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
|
||||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
|
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
|
||||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h" />
|
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h" />
|
||||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
||||||
|
|
|
@ -593,9 +593,6 @@
|
||||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h">
|
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
|
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
|
|
||||||
|
/* Standard C++11 includes */
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
/* Windows includes */
|
||||||
#include "ppltasks.h"
|
#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" {
|
extern "C" {
|
||||||
#include "SDL_assert.h"
|
#include "SDL_assert.h"
|
||||||
#include "SDL_events.h"
|
#include "SDL_events.h"
|
||||||
|
@ -21,20 +37,8 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "../../video/winrt/SDL_winrtevents_c.h"
|
#include "../../video/winrt/SDL_winrtevents_c.h"
|
||||||
#include "../../video/winrt/SDL_winrtvideo.h"
|
|
||||||
#include "SDL_winrtapp.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:
|
// Compile-time debugging options:
|
||||||
// To enable, uncomment; to disable, comment them out.
|
// 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() :
|
SDL_WinRTApp::SDL_WinRTApp() :
|
||||||
m_windowClosed(false),
|
m_windowClosed(false),
|
||||||
m_windowVisible(true),
|
m_windowVisible(true),
|
||||||
m_sdlWindowData(NULL),
|
m_sdlWindow(NULL),
|
||||||
m_sdlVideoDevice(NULL)
|
m_sdlVideoDevice(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -279,16 +283,16 @@ void SDL_WinRTApp::Uninitialize()
|
||||||
void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
|
void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
|
||||||
{
|
{
|
||||||
#if LOG_WINDOW_EVENTS==1
|
#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__,
|
__FUNCTION__,
|
||||||
args->Size.Width, args->Size.Height,
|
args->Size.Width, args->Size.Height,
|
||||||
(int)DisplayProperties::CurrentOrientation,
|
(int)DisplayProperties::CurrentOrientation,
|
||||||
(int)DisplayProperties::NativeOrientation,
|
(int)DisplayProperties::NativeOrientation,
|
||||||
(int)DisplayProperties::AutoRotationPreferences,
|
(int)DisplayProperties::AutoRotationPreferences,
|
||||||
(m_sdlWindowData ? "yes" : "no"));
|
(m_sdlWindow ? "yes" : "no"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_sdlWindowData) {
|
if (m_sdlWindow) {
|
||||||
// Make the new window size be the one true fullscreen mode.
|
// Make the new window size be the one true fullscreen mode.
|
||||||
// This change was initially done, in part, to allow the Direct3D 11.1
|
// This change was initially done, in part, to allow the Direct3D 11.1
|
||||||
// renderer to receive window-resize events as a device rotates.
|
// 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 windowWidth = (int) ceil(args->Size.Width);
|
||||||
const int windowHeight = (int) ceil(args->Size.Height);
|
const int windowHeight = (int) ceil(args->Size.Height);
|
||||||
SDL_SendWindowEvent(
|
SDL_SendWindowEvent(
|
||||||
m_sdlWindowData->sdlWindow,
|
m_sdlWindow,
|
||||||
SDL_WINDOWEVENT_RESIZED,
|
SDL_WINDOWEVENT_RESIZED,
|
||||||
windowWidth,
|
windowWidth,
|
||||||
windowHeight);
|
windowHeight);
|
||||||
|
@ -319,20 +323,20 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
|
||||||
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
|
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
|
||||||
{
|
{
|
||||||
#if LOG_WINDOW_EVENTS==1
|
#if LOG_WINDOW_EVENTS==1
|
||||||
SDL_Log("%s, visible?=%s, m_sdlWindowData?=%s\n",
|
SDL_Log("%s, visible?=%s, m_sdlWindow?=%s\n",
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
(args->Visible ? "yes" : "no"),
|
(args->Visible ? "yes" : "no"),
|
||||||
(m_sdlWindowData ? "yes" : "no"));
|
(m_sdlWindow ? "yes" : "no"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_windowVisible = args->Visible;
|
m_windowVisible = args->Visible;
|
||||||
if (m_sdlWindowData) {
|
if (m_sdlWindow) {
|
||||||
SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
|
SDL_bool wasSDLWindowSurfaceValid = m_sdlWindow->surface_valid;
|
||||||
|
|
||||||
if (args->Visible) {
|
if (args->Visible) {
|
||||||
SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
|
SDL_SendWindowEvent(m_sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
|
||||||
} else {
|
} 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
|
// 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
|
// A better solution to this probably involves figuring out if the
|
||||||
// fake window resize can be prevented.
|
// 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)
|
void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
WINRT_ProcessPointerPressedEvent(m_sdlWindow, args);
|
||||||
WINRT_ProcessPointerPressedEvent(window, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
|
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
WINRT_ProcessPointerReleasedEvent(m_sdlWindow, args);
|
||||||
WINRT_ProcessPointerReleasedEvent(window, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
|
void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
WINRT_ProcessPointerWheelChangedEvent(m_sdlWindow, args);
|
||||||
WINRT_ProcessPointerWheelChangedEvent(window, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
|
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
|
||||||
{
|
{
|
||||||
SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
WINRT_ProcessMouseMovedEvent(m_sdlWindow, args);
|
||||||
WINRT_ProcessMouseMovedEvent(window, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
|
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
|
||||||
{
|
{
|
||||||
SDL_Window * window = (m_sdlWindowData ? m_sdlWindowData->sdlWindow : nullptr);
|
WINRT_ProcessPointerMovedEvent(m_sdlWindow, args);
|
||||||
WINRT_ProcessPointerMovedEvent(window, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ 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
|
// first via a callback passed to SDL_AddEventWatch, and second via
|
||||||
// SDL's event queue, the event will be sent to SDL, then immediately
|
// SDL's event queue, the event will be sent to SDL, then immediately
|
||||||
// removed from the queue.
|
// 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);
|
SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
|
||||||
}
|
}
|
||||||
deferral->Complete();
|
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
|
// 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
|
// and state are persisted when resuming from suspend. Note that this event
|
||||||
// does not occur if the app was previously terminated.
|
// 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
|
// Remove the app-resume event from the queue, as is done with the
|
||||||
// app-suspend event.
|
// app-suspend event.
|
||||||
|
@ -488,19 +487,14 @@ SDL_DisplayMode SDL_WinRTApp::CalcCurrentDisplayMode()
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
|
SDL_Window * SDL_WinRTApp::GetSDLWindow()
|
||||||
{
|
{
|
||||||
return m_sdlWindowData;
|
return m_sdlWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_WinRTApp::HasSDLWindowData() const
|
void SDL_WinRTApp::SetSDLWindow(SDL_Window * window)
|
||||||
{
|
{
|
||||||
return (m_sdlWindowData != NULL);
|
m_sdlWindow = window;
|
||||||
}
|
|
||||||
|
|
||||||
void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData * windowData)
|
|
||||||
{
|
|
||||||
m_sdlWindowData = windowData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
|
void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct SDL_WindowData;
|
|
||||||
|
|
||||||
ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
|
ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -18,9 +16,8 @@ internal:
|
||||||
// SDL-specific methods
|
// SDL-specific methods
|
||||||
SDL_DisplayMode CalcCurrentDisplayMode();
|
SDL_DisplayMode CalcCurrentDisplayMode();
|
||||||
void PumpEvents();
|
void PumpEvents();
|
||||||
const SDL_WindowData * GetSDLWindowData() const;
|
SDL_Window * GetSDLWindow();
|
||||||
bool HasSDLWindowData() const;
|
void SetSDLWindow(SDL_Window * window);
|
||||||
void SetSDLWindowData(const SDL_WindowData * windowData);
|
|
||||||
void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
|
void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
|
||||||
Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
|
Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
|
||||||
|
|
||||||
|
@ -45,6 +42,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
bool m_windowClosed;
|
bool m_windowClosed;
|
||||||
bool m_windowVisible;
|
bool m_windowVisible;
|
||||||
const SDL_WindowData* m_sdlWindowData;
|
SDL_Window* m_sdlWindow;
|
||||||
const SDL_VideoDevice* m_sdlVideoDevice;
|
const SDL_VideoDevice* m_sdlVideoDevice;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,14 +22,20 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_WINRT
|
#if SDL_VIDEO_DRIVER_WINRT
|
||||||
|
|
||||||
#include "../../events/SDL_events_c.h"
|
/* SDL includes */
|
||||||
|
|
||||||
#include "SDL_winrtvideo.h"
|
|
||||||
#include "SDL_winrtevents_c.h"
|
#include "SDL_winrtevents_c.h"
|
||||||
#include "../../core/winrt/SDL_winrtapp.h"
|
#include "../../core/winrt/SDL_winrtapp.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
}
|
||||||
|
|
||||||
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
|
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
|
||||||
|
|
||||||
|
|
||||||
|
/* General event-management function(s) */
|
||||||
|
|
||||||
void
|
void
|
||||||
WINRT_PumpEvents(_THIS)
|
WINRT_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
#include "SDL_winrtvideo.h"
|
|
||||||
|
extern "C" {
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal-use, C-style functions:
|
* Internal-use, C-style functions:
|
||||||
|
|
|
@ -22,15 +22,16 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_WINRT
|
#if SDL_VIDEO_DRIVER_WINRT
|
||||||
|
|
||||||
// Standard C++11 headers:
|
/* Standard C++11 includes */
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
// Windows-specific headers:
|
/* Windows-specific includes */
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <agile.h>
|
||||||
|
|
||||||
|
|
||||||
// SDL-specific headers:
|
/* SDL-specific includes */
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "SDL_winrtevents_c.h"
|
#include "SDL_winrtevents_c.h"
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,12 @@
|
||||||
was based off of SDL's "dummy" video driver.
|
was based off of SDL's "dummy" video driver.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Windows includes */
|
||||||
|
#include <agile.h>
|
||||||
|
using namespace Windows::UI::Core;
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL includes */
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "SDL_video.h"
|
#include "SDL_video.h"
|
||||||
#include "SDL_mouse.h"
|
#include "SDL_mouse.h"
|
||||||
|
@ -39,20 +45,11 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "../../core/winrt/SDL_winrtapp.h"
|
#include "../../core/winrt/SDL_winrtapp.h"
|
||||||
#include "SDL_winrtvideo.h"
|
|
||||||
#include "SDL_winrtevents_c.h"
|
#include "SDL_winrtevents_c.h"
|
||||||
#include "SDL_winrtmouse.h"
|
#include "SDL_winrtmouse.h"
|
||||||
|
|
||||||
using namespace Windows::UI::Core;
|
|
||||||
|
|
||||||
/* On Windows, windows.h defines CreateWindow */
|
|
||||||
#ifdef CreateWindow
|
|
||||||
#undef CreateWindow
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
|
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
|
||||||
|
|
||||||
#define WINRTVID_DRIVER_NAME "winrt"
|
|
||||||
|
|
||||||
/* Initialization/Query functions */
|
/* Initialization/Query functions */
|
||||||
static int WINRT_VideoInit(_THIS);
|
static int WINRT_VideoInit(_THIS);
|
||||||
|
@ -60,11 +57,21 @@ static int WINRT_InitModes(_THIS);
|
||||||
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||||
static void WINRT_VideoQuit(_THIS);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
/* Internal window data */
|
||||||
|
struct SDL_WindowData
|
||||||
|
{
|
||||||
|
SDL_Window *sdlWindow;
|
||||||
|
Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* WinRT driver bootstrap functions */
|
/* WinRT driver bootstrap functions */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -102,17 +109,14 @@ WINRT_CreateDevice(int devindex)
|
||||||
device->DestroyWindow = WINRT_DestroyWindow;
|
device->DestroyWindow = WINRT_DestroyWindow;
|
||||||
device->SetDisplayMode = WINRT_SetDisplayMode;
|
device->SetDisplayMode = WINRT_SetDisplayMode;
|
||||||
device->PumpEvents = WINRT_PumpEvents;
|
device->PumpEvents = WINRT_PumpEvents;
|
||||||
//device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
|
|
||||||
//device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
|
|
||||||
//device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
|
|
||||||
device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
|
device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
|
||||||
device->free = WINRT_DeleteDevice;
|
device->free = WINRT_DeleteDevice;
|
||||||
|
|
||||||
SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
|
SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define WINRTVID_DRIVER_NAME "winrt"
|
||||||
VideoBootStrap WINRT_bootstrap = {
|
VideoBootStrap WINRT_bootstrap = {
|
||||||
WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
|
WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
|
||||||
WINRT_Available, WINRT_CreateDevice
|
WINRT_Available, WINRT_CreateDevice
|
||||||
|
@ -160,8 +164,7 @@ 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 (SDL_WinRTGlobalApp->HasSDLWindowData())
|
if (SDL_WinRTGlobalApp->GetSDLWindow() != NULL) {
|
||||||
{
|
|
||||||
SDL_SetError("WinRT only supports one window");
|
SDL_SetError("WinRT only supports one window");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +202,7 @@ WINRT_CreateWindow(_THIS, SDL_Window * window)
|
||||||
/* 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:
|
||||||
*/
|
*/
|
||||||
SDL_WinRTGlobalApp->SetSDLWindowData(data);
|
SDL_WinRTGlobalApp->SetSDLWindow(window);
|
||||||
|
|
||||||
/* All done! */
|
/* All done! */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -210,10 +213,8 @@ WINRT_DestroyWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
|
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
|
||||||
|
|
||||||
if (SDL_WinRTGlobalApp->HasSDLWindowData() &&
|
if (SDL_WinRTGlobalApp->GetSDLWindow() == window) {
|
||||||
SDL_WinRTGlobalApp->GetSDLWindowData()->sdlWindow == window)
|
SDL_WinRTGlobalApp->SetSDLWindow(NULL);
|
||||||
{
|
|
||||||
SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
|
@ -1,40 +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_winrtvideo_h
|
|
||||||
#define _SDL_winrtvideo_h
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "../SDL_sysvideo.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <agile.h>
|
|
||||||
|
|
||||||
struct SDL_WindowData
|
|
||||||
{
|
|
||||||
SDL_Window *sdlWindow;
|
|
||||||
Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _SDL_winrtvideo_h */
|
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
Loading…
Reference in New Issue