GHost: Code cleanup, prepare for strict C++ flags
[blender.git] / intern / ghost / intern / GHOST_System.cpp
index 944ade3f22b1e819504fc5bc2c0dd49f3153fd00..baa1bdff79ad450ae52e0ef23fff69f5eeefa288 100644 (file)
 
 
 GHOST_System::GHOST_System()
-    : m_displayManager(0),
-      m_timerManager(0),
-      m_windowManager(0),
-      m_eventManager(0)
+    : m_nativePixel(false),
+      m_displayManager(NULL),
+      m_timerManager(NULL),
+      m_windowManager(NULL),
+      m_eventManager(NULL)
 #ifdef WITH_INPUT_NDOF
       , m_ndofManager(0)
 #endif
@@ -73,13 +74,13 @@ GHOST_TUns64 GHOST_System::getMilliSeconds() const
 }
 
 
-GHOST_ITimerTaskGHOST_System::installTimer(GHOST_TUns64 delay,
+GHOST_ITimerTask *GHOST_System::installTimer(GHOST_TUns64 delay,
                                              GHOST_TUns64 interval,
                                              GHOST_TimerProcPtr timerProc,
                                              GHOST_TUserDataPtr userData)
 {
        GHOST_TUns64 millis = getMilliSeconds();
-       GHOST_TimerTask* timer = new GHOST_TimerTask(millis+delay, interval, timerProc, userData);
+       GHOST_TimerTask *timer = new GHOST_TimerTask(millis + delay, interval, timerProc, userData);
        if (timer) {
                if (m_timerManager->addTimer(timer) == GHOST_kSuccess) {
                        // Check to see whether we need to fire the timer right away
@@ -94,17 +95,17 @@ GHOST_ITimerTask* GHOST_System::installTimer(GHOST_TUns64 delay,
 }
 
 
-GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTasktimerTask)
+GHOST_TSuccess GHOST_System::removeTimer(GHOST_ITimerTask *timerTask)
 {
        GHOST_TSuccess success = GHOST_kFailure;
        if (timerTask) {
-               success = m_timerManager->removeTimer((GHOST_TimerTask*)timerTask);
+               success = m_timerManager->removeTimer((GHOST_TimerTask *)timerTask);
        }
        return success;
 }
 
 
-GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindowwindow)
+GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow *window)
 {
        GHOST_TSuccess success;
 
@@ -132,17 +133,17 @@ GHOST_TSuccess GHOST_System::disposeWindow(GHOST_IWindow* window)
 }
 
 
-bool GHOST_System::validWindow(GHOST_IWindowwindow)
+bool GHOST_System::validWindow(GHOST_IWindow *window)
 {
        return m_windowManager->getWindowFound(window);
 }
 
 
-GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
-                                                                                        const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
+GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow **window,
+                                             const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 {
        GHOST_TSuccess success = GHOST_kFailure;
-       GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager")
+       GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager");
        if (m_displayManager) {
                if (!m_windowManager->getFullScreen()) {
                        m_displayManager->getCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, m_preFullScreenSetting);
@@ -151,7 +152,7 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting
                        success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
                        if (success == GHOST_kSuccess) {
                                //GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
-                               success = createFullScreenWindow((GHOST_Window**)window, stereoVisual, numOfAASamples);
+                               success = createFullScreenWindow((GHOST_Window **)window, setting, stereoVisual, numOfAASamples);
                                if (success == GHOST_kSuccess) {
                                        m_windowManager->beginFullScreen(*window, stereoVisual);
                                }
@@ -168,11 +169,11 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting
 }
 
 
-GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window)
+GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow ** /*window*/)
 {
        GHOST_TSuccess success = GHOST_kFailure;
        GHOST_ASSERT(m_windowManager, "GHOST_System::updateFullScreen(): invalid window manager");
-       if(m_displayManager) {
+       if (m_displayManager) {
                if (m_windowManager->getFullScreen()) {
                        success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
                }
@@ -184,12 +185,12 @@ GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& settin
 GHOST_TSuccess GHOST_System::endFullScreen(void)
 {
        GHOST_TSuccess success = GHOST_kFailure;
-       GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager")
+       GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager");
        if (m_windowManager->getFullScreen()) {
                //GHOST_IWindow* window = m_windowManager->getFullScreenWindow();
                //GHOST_PRINT("GHOST_System::endFullScreen(): leaving window manager full-screen mode\n");
                success = m_windowManager->endFullScreen();
-               GHOST_ASSERT(m_displayManager, "GHOST_System::endFullScreen(): invalid display manager")
+               GHOST_ASSERT(m_displayManager, "GHOST_System::endFullScreen(): invalid display manager");
                //GHOST_PRINT("GHOST_System::endFullScreen(): leaving full-screen mode\n");
                success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, m_preFullScreenSetting);
        }
@@ -233,7 +234,7 @@ bool GHOST_System::dispatchEvents()
 }
 
 
-GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumerconsumer)
+GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer *consumer)
 {
        GHOST_TSuccess success;
        if (m_eventManager) {
@@ -245,7 +246,7 @@ GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer* consumer)
        return success;
 }
 
-GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumerconsumer)
+GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer *consumer)
 {
        GHOST_TSuccess success;
        if (m_eventManager) {
@@ -257,7 +258,7 @@ GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer* consumer)
        return success;
 }
 
-GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEventevent)
+GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent *event)
 {
        GHOST_TSuccess success;
        if (m_eventManager) {
@@ -296,9 +297,9 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown
 
 GHOST_TSuccess GHOST_System::init()
 {
-       m_timerManager = new GHOST_TimerManager ();
-       m_windowManager = new GHOST_WindowManager ();
-       m_eventManager = new GHOST_EventManager ();
+       m_timerManager = new GHOST_TimerManager();
+       m_windowManager = new GHOST_WindowManager();
+       m_eventManager = new GHOST_EventManager();
        
 #ifdef GHOST_DEBUG
        if (m_eventManager) {
@@ -309,7 +310,8 @@ GHOST_TSuccess GHOST_System::init()
 
        if (m_timerManager && m_windowManager && m_eventManager) {
                return GHOST_kSuccess;
-       } else {
+       }
+       else {
                return GHOST_kFailure;
        }
 }
@@ -322,19 +324,19 @@ GHOST_TSuccess GHOST_System::exit()
        }
        if (m_displayManager) {
                delete m_displayManager;
-               m_displayManager = 0;
+               m_displayManager = NULL;
        }
        if (m_windowManager) {
                delete m_windowManager;
-               m_windowManager = 0;
+               m_windowManager = NULL;
        }
        if (m_timerManager) {
                delete m_timerManager;
-               m_timerManager = 0;
+               m_timerManager = NULL;
        }
        if (m_eventManager) {
                delete m_eventManager;
-               m_eventManager = 0;
+               m_eventManager = NULL;
        }
 #ifdef WITH_INPUT_NDOF
        if (m_ndofManager) {
@@ -345,24 +347,38 @@ GHOST_TSuccess GHOST_System::exit()
        return GHOST_kSuccess;
 }
 
+GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, const GHOST_DisplaySetting &settings,
+                                                    const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
+{
+       GHOST_GLSettings glSettings = {0};
+
+       if (stereoVisual)
+               glSettings.flags |= GHOST_glStereoVisual;
+       glSettings.numOfAASamples = numOfAASamples;
+
+       /* note: don't use getCurrentDisplaySetting() because on X11 we may
+        * be zoomed in and the desktop may be bigger then the viewport. */
+       GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager");
+       //GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
+       *window = (GHOST_Window *)createWindow(
+           STR_String(""),
+           0, 0, settings.xPixels, settings.yPixels,
+           GHOST_kWindowStateNormal,
+           GHOST_kDrawingContextTypeOpenGL,
+           glSettings,
+           true  /* exclusive */);
+       return (*window == NULL) ? GHOST_kFailure : GHOST_kSuccess;
+}
+
 
-GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
+int GHOST_System::confirmQuit(GHOST_IWindow * /*window*/) const
 {
-       GHOST_TSuccess success;
-       GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager")
-       GHOST_DisplaySetting settings;
+       return 1;
+}
 
-       success = m_displayManager->getCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, settings);
-       if (success) {
-               //GHOST_PRINT("GHOST_System::createFullScreenWindow(): creating full-screen window\n");
-               *window = (GHOST_Window*)createWindow(
-                                       STR_String (""),
-                                       0, 0, settings.xPixels, settings.yPixels,
-                                       GHOST_kWindowStateFullScreen,
-                                       GHOST_kDrawingContextTypeOpenGL,
-                                       stereoVisual,
-                                       numOfAASamples);
-               success = *window == 0 ? GHOST_kFailure : GHOST_kSuccess;
-       }
-       return success;
+bool GHOST_System::useNativePixel(void)
+{
+       m_nativePixel = true;
+       return 1;
 }
+