Skip to content

Commit

Permalink
DisplayMode|X11: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 24, 2012
1 parent 89b4966 commit 53b4974
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions doomsday/engine/unix/src/displaymode_x11.cpp
Expand Up @@ -31,21 +31,23 @@
#include <assert.h>
#include <vector>

#if 0
static std::vector<DEVMODE> devModes;
static DEVMODE currentDevMode;
#endif

typedef std::vector<DisplayMode> DisplayModes;

static int displayDepth;
static Rotation displayRotation;
static DisplayModes availableModes;
static DisplayMode currentMode;

/**
* Wrapper for the Xrandr configuration info. The config is kept in memory only
* for the lifetime of an RRInfo instance.
*/
class RRInfo
{
public:
/**
* Queries all the available modes in the display configuration.
*/
RRInfo() : _numSizes(0)
{
_conf = XRRGetScreenInfo(QX11Info::display(), QX11Info::appRootWindow());
Expand Down Expand Up @@ -73,14 +75,22 @@ class RRInfo
_confTime = XRRConfigTimes(_conf, &prevConfTime);
}

~RRInfo()
{
if(_conf) XRRFreeScreenConfigInfo(_conf);
}

/**
* Returns the currently active mode as specified in the Xrandr config.
* Also determines the display's current rotation angle.
*/
DisplayMode currentMode() const
{
DisplayMode mode;
memset(&mode, 0, sizeof(mode));

if(!_conf) return mode;

// Also updates the display's current rotation.
SizeID currentSize = XRRConfigCurrentConfiguration(_conf, &displayRotation);

// Update the current mode.
Expand Down Expand Up @@ -140,14 +150,6 @@ class RRInfo
return true;
}

~RRInfo()
{
if(_conf)
{
XRRFreeScreenConfigInfo(_conf);
}
}

private:
XRRScreenConfiguration* _conf;
XRRScreenSize* _sizes;
Expand Down

0 comments on commit 53b4974

Please sign in to comment.