Skip to content

Commit

Permalink
libdeng2|libdeng: App notifies about mode changes using a signal
Browse files Browse the repository at this point in the history
When the window manager changes the display mode, de::App will emit
a signal notifying about it (after a short delay).
  • Loading branch information
skyjake committed Aug 31, 2012
1 parent 13e1936 commit c549b6b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doomsday/engine/portable/src/window.cpp
Expand Up @@ -49,6 +49,7 @@
#include "fs_util.h"

#include <de/c_wrapper.h>
#include <de/App>
#include <de/Log>
#include <QDebug>

Expand Down Expand Up @@ -76,6 +77,12 @@ static QRect desktopValidRect()

static void updateMainWindowLayout(void);

static void notifyAboutModeChange()
{
LOG_MSG("Display mode has changed.");
DENG2_APP->notifyDisplayModeChanged();
}

struct ddwindow_s
{
CanvasWindow* widget; ///< The widget this window represents.
Expand Down Expand Up @@ -219,6 +226,12 @@ struct ddwindow_s

bool modeChanged = applyDisplayMode();

if(modeChanged)
{
// Others might be interested to hear about the mode change.
LegacyCore_Timer(POST_MODE_CHANGE_WAIT_BEFORE_UPDATE, notifyAboutModeChange);
}

if(flags & DDWF_FULLSCREEN)
{
LOG_DEBUG("fullscreen mode (mode changed? %b)") << modeChanged;
Expand Down
12 changes: 12 additions & 0 deletions doomsday/libdeng2/include/de/core/app.h
Expand Up @@ -54,9 +54,21 @@ namespace de
*/
de::String executablePath() const;

/**
* Emits the displayModeChanged() signal.
*
* @todo In the future when de::App (or a sub-object owned by it) is
* responsible for display modes, this should be handled internally and
* not via this public interface where anybody can call it.
*/
void notifyDisplayModeChanged();

signals:
void uncaughtException(QString message);

/// Emitted when the display mode has changed.
void displayModeChanged();

private:
CommandLine _cmdLine;

Expand Down
5 changes: 5 additions & 0 deletions doomsday/libdeng2/src/core/app.cpp
Expand Up @@ -56,3 +56,8 @@ String App::executablePath() const
{
return _appPath;
}

void App::notifyDisplayModeChanged()
{
emit displayModeChanged();
}

0 comments on commit c549b6b

Please sign in to comment.