From: Mikko Rasa Date: Sun, 12 Jan 2014 10:58:39 +0000 (+0200) Subject: Expose functions for finding video modes from Display X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=eb81125a81735eceef4a8be54a0bafcae6901e18;p=libs%2Fgui.git Expose functions for finding video modes from Display --- diff --git a/source/graphics/display.cpp b/source/graphics/display.cpp index 22dd705..de5a069 100644 --- a/source/graphics/display.cpp +++ b/source/graphics/display.cpp @@ -31,7 +31,7 @@ void Display::restore_mode() set_mode(*i->desktop_mode, false); } -const VideoMode *Display::find_matching_mode(const VideoMode &mode) const +const VideoMode *Display::find_mode(const VideoMode &mode) const { for(list::const_iterator i=modes.begin(); i!=modes.end(); ++i) { @@ -46,6 +46,11 @@ const VideoMode *Display::find_matching_mode(const VideoMode &mode) const return 0; } +const VideoMode *Display::find_mode(unsigned width, unsigned height) const +{ + return find_mode(VideoMode(width, height)); +} + void Display::tick() { check_error(); diff --git a/source/graphics/display.h b/source/graphics/display.h index bff17c3..03912de 100644 --- a/source/graphics/display.h +++ b/source/graphics/display.h @@ -39,10 +39,9 @@ public: const VideoMode &get_desktop_mode() const; void set_mode(const VideoMode &, bool = false); void restore_mode(); -private: - const VideoMode *find_matching_mode(const VideoMode &) const; + const VideoMode *find_mode(const VideoMode &) const; + const VideoMode *find_mode(unsigned, unsigned) const; -public: void tick(); private: bool process_events(); diff --git a/source/graphics/windows/display.cpp b/source/graphics/windows/display.cpp index 7b61666..4c89333 100644 --- a/source/graphics/windows/display.cpp +++ b/source/graphics/windows/display.cpp @@ -44,7 +44,7 @@ Display::Display(const string &): mode.index = modes.size(); mode.monitor = &monitor; mode.rate = info.dmDisplayFrequency; - if(find_matching_mode(mode)) + if(find_mode(mode)) continue; modes.push_back(mode); @@ -62,7 +62,7 @@ Display::~Display() void Display::set_mode(const VideoMode &requested_mode, bool) { - const VideoMode *mode = find_matching_mode(requested_mode); + const VideoMode *mode = find_mode(requested_mode); if(!mode) throw unsupported_video_mode(requested_mode); diff --git a/source/graphics/x11/display.cpp b/source/graphics/x11/display.cpp index 70b77c6..fe489ec 100644 --- a/source/graphics/x11/display.cpp +++ b/source/graphics/x11/display.cpp @@ -146,7 +146,7 @@ Display::Display(const string &disp_name): mode.index = modes.size(); mode.monitor = &monitor; mode.rate = info->dotClock/(info->hTotal*info->vTotal); - if(find_matching_mode(mode)) + if(find_mode(mode)) continue; modes.push_back(mode); @@ -208,7 +208,7 @@ Display::~Display() void Display::set_mode(const VideoMode &requested_mode, bool exclusive) { #ifdef WITH_XRANDR - const VideoMode *mode = find_matching_mode(requested_mode); + const VideoMode *mode = find_mode(requested_mode); if(!mode) throw unsupported_video_mode(requested_mode);