]> git.tdb.fi Git - libs/gui.git/commitdiff
Expose functions for finding video modes from Display
authorMikko Rasa <tdb@tdb.fi>
Sun, 12 Jan 2014 10:58:39 +0000 (12:58 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 12 Jan 2014 10:58:39 +0000 (12:58 +0200)
source/graphics/display.cpp
source/graphics/display.h
source/graphics/windows/display.cpp
source/graphics/x11/display.cpp

index 22dd705df90c772e6901ae30f618f87db787077a..de5a06952a58e8efa8f3e956ee0f949126775426 100644 (file)
@@ -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<VideoMode>::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();
index bff17c3ffe69e8a819bf6b9872c77dc8ddab06bc..03912de864dbdc95d7d3181406554853316fad0c 100644 (file)
@@ -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();
index 7b616662ae9e06585c874f4e36c24af027d3f808..4c893335c9ec06cd3fafbef01f5c7618c482159e 100644 (file)
@@ -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);
 
index 70b77c60ff6239c46041b2821a9c39777f6f0628..fe489ec86cf27760daecbb843497360759e87583 100644 (file)
@@ -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);