WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
authorDavid Ludwig <dludwig@pobox.com>
Sun, 28 Oct 2012 23:20:18 -0400
changeset 8334 09b0670fece4
parent 8333 49973bfb8d23
child 8335 4f41add2ff00
WinRT: explicitly allowed only one window at a time, pending multimonitor support (in SDL/WinRT)
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtvideo.cpp
--- a/src/video/windowsrt/SDL_WinRTApp.cpp	Sun Oct 28 23:01:31 2012 -0400
+++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Sun Oct 28 23:20:18 2012 -0400
@@ -198,6 +198,11 @@
     return mode;
 }
 
+bool SDL_WinRTApp::HasSDLWindowData() const
+{
+    return (m_sdlWindowData != NULL);
+}
+
 void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData* windowData)
 {
     m_sdlWindowData = windowData;
--- a/src/video/windowsrt/SDL_WinRTApp.h	Sun Oct 28 23:01:31 2012 -0400
+++ b/src/video/windowsrt/SDL_WinRTApp.h	Sun Oct 28 23:20:18 2012 -0400
@@ -23,6 +23,7 @@
     // SDL-specific methods
     SDL_DisplayMode GetMainDisplayMode();
     void PumpEvents();
+    bool HasSDLWindowData() const;
     void SetSDLWindowData(const SDL_WindowData* windowData);
 
 protected:
--- a/src/video/windowsrt/SDL_winrtvideo.cpp	Sun Oct 28 23:01:31 2012 -0400
+++ b/src/video/windowsrt/SDL_winrtvideo.cpp	Sun Oct 28 23:20:18 2012 -0400
@@ -137,8 +137,13 @@
 int
 WINRT_CreateWindow(_THIS, SDL_Window * window)
 {
-    // TODO, WinRT: modify WINRT_Createwindow to ensure that, for now, only one window gets created
-    // (until multimonitor support is added to the WinRT port).
+    // Make sure that only one window gets created, at least until multimonitor
+    // support is added.
+    if (SDL_WinRTGlobalApp->HasSDLWindowData())
+    {
+        SDL_SetError("WinRT only supports one window");
+        return -1;
+    }
 
     SDL_WindowData *data;
     data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
@@ -163,7 +168,10 @@
 void
 WINRT_DestroyWindow(_THIS, SDL_Window * window)
 {
-    SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
+    if (SDL_WinRTGlobalApp->HasSDLWindowData())
+    {
+        SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
+    }
 }