]> git.tdb.fi Git - libs/gui.git/commitdiff
Swap fullscreen mode dimensions if the desktop is rotated
authorMikko Rasa <tdb@tdb.fi>
Tue, 2 Aug 2016 21:00:51 +0000 (00:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 2 Aug 2016 21:07:25 +0000 (00:07 +0300)
source/graphics/window.cpp
source/graphics/window.h

index d116b691c14bcbf11592bca91d9edcb647eca792..073cd8d5c819311277bfeb6e0ff0444521a4eeb9 100644 (file)
@@ -75,18 +75,28 @@ void Window::reconfigure(const WindowOptions &opts)
        if(opts.x!=options.x || opts.y!=options.y)
                moving = true;
 
+       options = opts;
+
        if(visible)
        {
-               if(opts.fullscreen)
-                       display.set_mode(VideoMode(opts.width, opts.height));
+               if(options.fullscreen)
+                       set_fullscreen_mode();
                else if(fullscreen_changed)
                        display.restore_mode();
        }
 
-       options = opts;
        platform_reconfigure(fullscreen_changed);
 }
 
+void Window::set_fullscreen_mode()
+{
+       VideoMode mode(options.width, options.height);
+       mode.rotation = display.get_desktop_mode().monitor->desktop_rotation;
+       if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT)
+               swap(mode.width, mode.height);
+       display.set_mode(mode, true);
+}
+
 void Window::set_keyboard_autorepeat(bool r)
 {
        kbd_autorepeat = r;
@@ -105,7 +115,7 @@ void Window::show()
 
        if(options.fullscreen)
        {
-               display.set_mode(VideoMode(options.width, options.height), true);
+               set_fullscreen_mode();
                warp_pointer(options.width/2, options.height/2);
        }
 }
index 2d4376e1761baf82c7e59316b7823e5436721d9b..443cac79210afe3904b5cbc2008daceabc907197 100644 (file)
@@ -64,6 +64,7 @@ public:
        void set_title(const std::string &);
        void reconfigure(const WindowOptions &);
 private:
+       void set_fullscreen_mode();
        void platform_reconfigure(bool);
 public:
        void set_keyboard_autorepeat(bool);