#include <X11/extensions/xf86vmode.h>
#endif
#endif
-#include <msp/core/except.h>
#include <msp/strings/format.h>
#include <msp/strings/lexicalcast.h>
#include "display.h"
namespace Msp {
namespace Graphics {
+unsupported_video_mode::unsupported_video_mode(const VideoMode &mode):
+ runtime_error(format("%dx%d", mode.width, mode.height))
+{ }
+
+
Display::Display(const string &disp_name):
priv(new Private)
{
else
priv->display = XOpenDisplay(disp_name.c_str());
if(!priv->display)
- throw Exception("Couldn't open X display");
+ throw runtime_error("XOpenDisplay");
XSetErrorHandler(x_error_handler);
info.dmDisplayFrequency = mode.rate;
}
- ChangeDisplaySettings(&info, CDS_FULLSCREEN);
+ LONG ret = ChangeDisplaySettings(&info, CDS_FULLSCREEN);
+ if(ret!=DISP_CHANGE_SUCCESSFUL)
+ throw unsupported_video_mode(mode);
#elif defined(WITH_XF86VIDMODE)
int screen = DefaultScreen(priv->display);
}
}
- throw InvalidParameterValue("Requested mode not supported");
+ throw unsupported_video_mode(mode);
#else
(void)mode;
- throw Exception("Video mode switching not supported");
+ throw runtime_error("no xf86vidmode support");
#endif
}
if(error_flag)
{
error_flag = false;
- throw Exception(error_msg);
+ throw runtime_error(error_msg);
}
}