]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/window.cpp
Swap fullscreen mode dimensions if the desktop is rotated
[libs/gui.git] / source / graphics / window.cpp
index ebdc578e14d44524f982c74e29beb2503a7c0c99..073cd8d5c819311277bfeb6e0ff0444521a4eeb9 100644 (file)
@@ -9,6 +9,9 @@ namespace Msp {
 namespace Graphics {
 
 WindowOptions::WindowOptions():
+       x(0),
+       y(0),
+       user_position(false),
        width(640),
        height(480),
        fullscreen(false),
@@ -37,7 +40,9 @@ void Window::init()
 {
        visible = false;
        kbd_autorepeat = true;
+       touch_input = false;
        resizing = false;
+       moving = false;
        priv = new Private;
 
        platform_init();
@@ -67,24 +72,42 @@ void Window::reconfigure(const WindowOptions &opts)
        bool fullscreen_changed = (opts.fullscreen!=options.fullscreen);
        if(opts.width!=options.width || opts.height!=options.height)
                resizing = true;
+       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;
 }
 
+void Window::set_touch_input(bool t)
+{
+       touch_input = t;
+       platform_set_touch_input();
+}
+
 void Window::show()
 {
        platform_show();
@@ -92,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);
        }
 }