Skip to content

Commit

Permalink
Window|Refactor: Cleaned up Window destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Mar 30, 2013
1 parent 2026e3e commit 009b9e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
53 changes: 25 additions & 28 deletions doomsday/client/include/ui/window.h
Expand Up @@ -67,47 +67,25 @@ 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.
*
* @deprecated Windows will be represented by CanvasWindow instances.
*/
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
Expand Down Expand Up @@ -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)
};
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -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");
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_pinit.cpp
Expand Up @@ -193,6 +193,6 @@ void DD_ShutdownAll(void)
DD_ClearResourceClasses();
Libdeng_Shutdown();
#ifdef __CLIENT__
Sys_ShutdownWindowManager();
Window::shutdown();
#endif
}
7 changes: 3 additions & 4 deletions doomsday/client/src/ui/window.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -866,7 +865,7 @@ void Sys_InitWindowManager()
theWindow = 0;
}

void Sys_ShutdownWindowManager()
void Window::shutdown()
{
// Presently initialized?
if(!winManagerInited)
Expand Down

0 comments on commit 009b9e4

Please sign in to comment.