Skip to content

Commit

Permalink
Refactor|Client|libappfw: WindowSystem split to generic/client specific
Browse files Browse the repository at this point in the history
WindowSystem was moved to libappfw, with the client-specific portions
remaining as ClientWindowSystem.
  • Loading branch information
skyjake committed Feb 13, 2014
1 parent 84a54b7 commit 4f22873
Show file tree
Hide file tree
Showing 21 changed files with 319 additions and 133 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -368,6 +368,7 @@ DENG_HEADERS += \
include/ui/busyvisual.h \
include/ui/clientrootwidget.h \
include/ui/clientwindow.h \
include/ui/clientwindowsystem.h \
include/ui/commandaction.h \
include/ui/dd_input.h \
include/ui/dd_ui.h \
Expand Down Expand Up @@ -413,7 +414,6 @@ DENG_HEADERS += \
include/ui/ui2_main.h \
include/ui/ui_main.h \
include/ui/ui_panel.h \
include/ui/windowsystem.h \
include/ui/zonedebug.h \
include/updater.h \
include/updater/downloaddialog.h \
Expand Down Expand Up @@ -694,6 +694,7 @@ SOURCES += \
src/ui/busyvisual.cpp \
src/ui/clientrootwidget.cpp \
src/ui/clientwindow.cpp \
src/ui/clientwindowsystem.cpp \
src/ui/commandaction.cpp \
src/ui/dd_input.cpp \
src/ui/dialogs/aboutdialog.cpp \
Expand Down Expand Up @@ -736,7 +737,6 @@ SOURCES += \
src/ui/widgets/multiplayermenuwidget.cpp \
src/ui/widgets/profilepickerwidget.cpp \
src/ui/widgets/taskbarwidget.cpp \
src/ui/windowsystem.cpp \
src/ui/zonedebug.cpp \
src/updater/downloaddialog.cpp \
src/updater/processcheckdialog.cpp \
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/include/clientapp.h
Expand Up @@ -25,7 +25,7 @@
#include "settingsregister.h"
#include "network/serverlink.h"
#include "ui/inputsystem.h"
#include "ui/windowsystem.h"
#include "ui/clientwindowsystem.h"
#include "render/rendersystem.h"
#include "resource/resourcesystem.h"
#include "WidgetActions"
Expand Down Expand Up @@ -69,7 +69,7 @@ class ClientApp : public de::BaseGuiApp
static SettingsRegister &audioSettings(); ///< @todo Belongs in AudioSystem.
static ServerLink &serverLink();
static InputSystem &inputSystem();
static WindowSystem &windowSystem();
static ClientWindowSystem &windowSystem();
static RenderSystem &renderSystem();
static ResourceSystem &resourceSystem();
static WidgetActions &widgetActions();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/de_ui.h
Expand Up @@ -29,7 +29,7 @@

#ifdef __CLIENT__
# include <de/gui/ddkey.h>
# include "ui/windowsystem.h"
# include "ui/clientwindowsystem.h"
# include "ui/clientwindow.h"
# include "ui/ui_main.h"
# include "ui/ui_panel.h"
Expand Down
63 changes: 63 additions & 0 deletions doomsday/client/include/ui/clientwindowsystem.h
@@ -0,0 +1,63 @@
/** @file clientwindowsystem.h
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENTWINDOWSYSTEM_H
#define DENG_CLIENTWINDOWSYSTEM_H

#include <de/WindowSystem>
#include "SettingsRegister"

class ClientWindow;

/**
* Client-side window system for managing ClientWindow instances.
*/
class ClientWindowSystem : public de::WindowSystem
{
public:
ClientWindowSystem();

SettingsRegister &settings();

/**
* 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 id Identifier of the window ("main" for the main window).
*
* @return ClientWindow instance. Ownership is retained by the window system.
*/
ClientWindow *createWindow(de::String const &id = "main");

static ClientWindow &main();
static ClientWindow *mainPtr();

protected:
void closingAllWindows();
bool rootProcessEvent(de::Event const &event);
void rootUpdate();

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENTWINDOWSYSTEM_H
10 changes: 5 additions & 5 deletions doomsday/client/src/busymode.cpp
Expand Up @@ -37,7 +37,7 @@

#ifdef __CLIENT__
#include "clientapp.h"
#include "ui/windowsystem.h"
#include "ui/clientwindowsystem.h"
#include "ui/widgets/busywidget.h"

static void BusyMode_Exit(void);
Expand Down Expand Up @@ -276,7 +276,7 @@ static void preBusySetup(int initialMode)
ClientApp::app().loop().setRate(60);

// Switch the window to busy mode UI.
WindowSystem::main().setMode(ClientWindow::Busy);
ClientWindowSystem::main().setMode(ClientWindow::Busy);

#else
DENG_UNUSED(initialMode);
Expand All @@ -296,7 +296,7 @@ static void postBusyCleanup()
ClientApp::app().loop().setRate(0);

// Switch the window to normal UI.
WindowSystem::main().setMode(ClientWindow::Normal);
ClientWindowSystem::main().setMode(ClientWindow::Normal);

if(!Con_TransitionInProgress())
{
Expand Down Expand Up @@ -473,7 +473,7 @@ void BusyMode_Loop(void)

if(canUpload)
{
WindowSystem::main().glActivate();
ClientWindowSystem::main().glActivate();

// Any deferred content needs to get uploaded.
GL_ProcessDeferredTasks(15);
Expand All @@ -496,7 +496,7 @@ void BusyMode_Loop(void)
!Con_IsProgressAnimationCompleted())
{
// Let's keep running the busy loop.
WindowSystem::main().draw();
ClientWindowSystem::main().draw();
return;
}

Expand Down
11 changes: 6 additions & 5 deletions doomsday/client/src/clientapp.cpp
Expand Up @@ -49,7 +49,7 @@
#include "gl/gl_main.h"
#include "gl/gl_texmanager.h"
#include "ui/inputsystem.h"
#include "ui/windowsystem.h"
#include "ui/clientwindowsystem.h"
#include "ui/clientwindow.h"
#include "ui/dialogs/alertdialog.h"
#include "ui/styledlogsinkformatter.h"
Expand All @@ -74,7 +74,7 @@ static void continueInitWithEventLoopRunning()
{
// Show the main window. This causes initialization to finish (in busy mode)
// as the canvas is visible and ready for initialization.
WindowSystem::main().show();
ClientWindowSystem::main().show();

ClientApp::updater().setupUI();
}
Expand Down Expand Up @@ -164,7 +164,7 @@ DENG2_PIMPL(ClientApp)
QScopedPointer<WidgetActions> widgetActions;
RenderSystem *renderSys;
ResourceSystem *resourceSys;
WindowSystem *winSys;
ClientWindowSystem *winSys;
ServerLink *svLink;
Games games;
WorldSystem *worldSys;
Expand Down Expand Up @@ -395,7 +395,8 @@ void ClientApp::initialize()
addSystem(*d->renderSys);

// Create the window system.
d->winSys = new WindowSystem;
d->winSys = new ClientWindowSystem;
WindowSystem::setAppWindowSystem(*d->winSys);
addSystem(*d->winSys);

// Check for updates automatically.
Expand Down Expand Up @@ -523,7 +524,7 @@ ResourceSystem &ClientApp::resourceSystem()
return *a.d->resourceSys;
}

WindowSystem &ClientApp::windowSystem()
ClientWindowSystem &ClientApp::windowSystem()
{
ClientApp &a = ClientApp::app();
DENG2_ASSERT(a.d->winSys != 0);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/con_main.cpp
Expand Up @@ -46,7 +46,7 @@
#ifdef __CLIENT__
# include <de/DisplayMode>
# include "clientapp.h"
# include "ui/windowsystem.h"
# include "ui/clientwindowsystem.h"
# include "ui/clientwindow.h"
# include "ui/widgets/consolewidget.h"
# include "ui/widgets/taskbarwidget.h"
Expand Down
30 changes: 13 additions & 17 deletions doomsday/client/src/gl/gl_main.cpp
Expand Up @@ -39,7 +39,7 @@
#include "world/p_object.h"
#include "gl/gl_texmanager.h"
#include "gl/texturecontent.h"
#include "ui/windowsystem.h"
#include "ui/clientwindowsystem.h"
#include "resource/hq2x.h"
#include "MaterialSnapshot"
#include "MaterialVariantSpec"
Expand Down Expand Up @@ -96,19 +96,15 @@ static viewport_t currentView;

static void videoFSAAChanged()
{
if(novideo || !WindowSystem::hasMain()) return;
WindowSystem::main().updateCanvasFormat();
if(novideo || !WindowSystem::mainExists()) return;
ClientWindowSystem::main().updateCanvasFormat();
}

static void videoVsyncChanged()
{
if(novideo || !WindowSystem::hasMain()) return;
if(novideo || !WindowSystem::mainExists()) return;

//#if defined(WIN32) || defined(MACOSX)
GL_SetVSync(Con_GetByte("vid-vsync") != 0);
//#else
// WindowSystem::main().updateCanvasFormat();
//#endif
}

void GL_Register()
Expand Down Expand Up @@ -1394,7 +1390,7 @@ D_CMD(SetRes)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1417,7 +1413,7 @@ D_CMD(SetFullRes)
{
DENG2_UNUSED2(src, argc);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1435,7 +1431,7 @@ D_CMD(SetWinRes)
{
DENG2_UNUSED2(src, argc);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1454,7 +1450,7 @@ D_CMD(ToggleFullscreen)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1470,7 +1466,7 @@ D_CMD(ToggleMaximized)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1486,7 +1482,7 @@ D_CMD(ToggleCentered)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1502,7 +1498,7 @@ D_CMD(CenterWindow)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1518,7 +1514,7 @@ D_CMD(SetBPP)
{
DENG2_UNUSED2(src, argc);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand All @@ -1534,7 +1530,7 @@ D_CMD(DisplayModeInfo)
{
DENG2_UNUSED3(src, argc, argv);

ClientWindow *win = WindowSystem::mainPtr();
ClientWindow *win = ClientWindowSystem::mainPtr();

if(!win)
return false;
Expand Down

0 comments on commit 4f22873

Please sign in to comment.