From 009b9e4a5722056a2497fc07cf55ad64f6489747 Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 30 Mar 2013 19:06:57 +0000 Subject: [PATCH] Window|Refactor: Cleaned up Window destruction --- doomsday/client/include/ui/window.h | 53 ++++++++++++++--------------- doomsday/client/src/dd_main.cpp | 6 ++-- doomsday/client/src/dd_pinit.cpp | 2 +- doomsday/client/src/ui/window.cpp | 7 ++-- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/doomsday/client/include/ui/window.h b/doomsday/client/include/ui/window.h index 867eddd602..271a62d5bf 100644 --- a/doomsday/client/include/ui/window.h +++ b/doomsday/client/include/ui/window.h @@ -67,17 +67,6 @@ enum windowattribute_e /// Determines whether @a x is a valid window attribute id. #define VALID_WINDOW_ATTRIBUTE(x) ((x) >= DDWA_X && (x) <= DDWA_VISIBLE) -/** - * Initialize the window manager. - * Tasks include; checking the system environment for feature enumeration. - */ -void Sys_InitWindowManager(); - -/** - * Shutdown the window manager. - */ -void Sys_ShutdownWindowManager(); - /** * Window and window management. * @@ -85,29 +74,18 @@ void Sys_ShutdownWindowManager(); */ class Window { -private: +public: /** - * Constructs a new window using the default configuration. Note that the - * default configuration is saved persistently when the engine shuts down and - * is restored when the engine is restarted. - * - * Command line options (e.g., -xpos) can be used to modify the window - * configuration. - * - * @param title Text for the window title. + * Initialize the window manager. + * Tasks include; checking the system environment for feature enumeration. */ - Window(char const *title = ""); + static void initialize(); -public: /** - * Close and destroy the window. Its state is saved persistently and used as - * the default configuration the next time the same window is created. - * - * @todo Should be private + * Shutdown the window manager. */ - ~Window(); + static void shutdown(); -public: /** * Constructs a new window using the default configuration. Note that the * default configuration is saved persistently when the engine shuts down @@ -293,6 +271,25 @@ class Window */ void updateAfterResize(); +private: + /** + * Constructs a new window using the default configuration. Note that the + * default configuration is saved persistently when the engine shuts down and + * is restored when the engine is restarted. + * + * Command line options (e.g., -xpos) can be used to modify the window + * configuration. + * + * @param title Text for the window title. + */ + Window(char const *title = ""); + + /** + * Close and destroy the window. Its state is saved persistently and used as + * the default configuration the next time the same window is created. + */ + ~Window(); + private: DENG2_PRIVATE(d) }; diff --git a/doomsday/client/src/dd_main.cpp b/doomsday/client/src/dd_main.cpp index eb236c6536..10d5e833d2 100644 --- a/doomsday/client/src/dd_main.cpp +++ b/doomsday/client/src/dd_main.cpp @@ -1726,7 +1726,7 @@ de::Game* DD_AutoselectGame(void) return NULL; } -int DD_EarlyInit(void) +int DD_EarlyInit() { // Determine the requested degree of verbosity. verbose = CommandLine_Exists("-verbose"); @@ -1747,11 +1747,11 @@ int DD_EarlyInit(void) #ifdef __CLIENT__ // Bring the window manager online. - Sys_InitWindowManager(); + Window::intialize(); #endif // Instantiate the Games collection. - games = new de::Games(); + games = new Games(); return true; } diff --git a/doomsday/client/src/dd_pinit.cpp b/doomsday/client/src/dd_pinit.cpp index 6892536e31..0c3ef47eae 100644 --- a/doomsday/client/src/dd_pinit.cpp +++ b/doomsday/client/src/dd_pinit.cpp @@ -193,6 +193,6 @@ void DD_ShutdownAll(void) DD_ClearResourceClasses(); Libdeng_Shutdown(); #ifdef __CLIENT__ - Sys_ShutdownWindowManager(); + Window::shutdown(); #endif } diff --git a/doomsday/client/src/ui/window.cpp b/doomsday/client/src/ui/window.cpp index ee2b3c33b1..1a5de6f7a0 100644 --- a/doomsday/client/src/ui/window.cpp +++ b/doomsday/client/src/ui/window.cpp @@ -360,7 +360,6 @@ DENG2_PIMPL(Window) LegacyCore_Timer(WAIT_MILLISECS_AFTER_MODE_CHANGE * 20, endWindowWait); bool modeChanged = applyDisplayMode(); - if(modeChanged) { // Others might be interested to hear about the mode change. @@ -850,9 +849,9 @@ DENG2_PIMPL(Window) } }; -void Sys_InitWindowManager() +void Window::initialize() { - LOG_AS("Sys_InitWindowManager"); + LOG_AS("Window::initialize"); // Already been here? if(winManagerInited) @@ -866,7 +865,7 @@ void Sys_InitWindowManager() theWindow = 0; } -void Sys_ShutdownWindowManager() +void Window::shutdown() { // Presently initialized? if(!winManagerInited)