]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/window.cpp
Track window positions
[libs/gui.git] / source / graphics / window.cpp
index 166e49f716fc8f63944015360b8806068ff325b6..5bc9a358e2786d99e7ba7e4be1c63b6dce20afa8 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/application.h>
 #include "display.h"
 #include "window.h"
 #include "window_private.h"
@@ -8,6 +9,8 @@ namespace Msp {
 namespace Graphics {
 
 WindowOptions::WindowOptions():
+       x(0),
+       y(0),
        width(640),
        height(480),
        fullscreen(false),
@@ -36,6 +39,7 @@ void Window::init()
 {
        visible = false;
        kbd_autorepeat = true;
+       touch_input = false;
        resizing = false;
        priv = new Private;
 
@@ -43,6 +47,10 @@ void Window::init()
 
        display.add_window(*this);
        display.check_error();
+
+       const string &app_name = Application::get_name();
+       if(!app_name.empty())
+               set_title(app_name);
 }
 
 Window::~Window()
@@ -51,7 +59,7 @@ Window::~Window()
 
        display.remove_window(*this);
 
-       if(options.fullscreen)
+       if(options.fullscreen && visible)
                display.restore_mode();
 
        delete priv;
@@ -60,18 +68,19 @@ Window::~Window()
 void Window::reconfigure(const WindowOptions &opts)
 {
        bool fullscreen_changed = (opts.fullscreen!=options.fullscreen);
-       resizing = (opts.width!=options.width || opts.height!=options.height);
-
-       options = opts;
-       platform_reconfigure(fullscreen_changed);
+       if(opts.width!=options.width || opts.height!=options.height)
+               resizing = true;
 
        if(visible)
        {
-               if(options.fullscreen)
-                       display.set_mode(VideoMode(options.width, options.height));
+               if(opts.fullscreen)
+                       display.set_mode(VideoMode(opts.width, opts.height));
                else if(fullscreen_changed)
                        display.restore_mode();
        }
+
+       options = opts;
+       platform_reconfigure(fullscreen_changed);
 }
 
 void Window::set_keyboard_autorepeat(bool r)
@@ -79,6 +88,12 @@ 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();
@@ -86,7 +101,7 @@ void Window::show()
 
        if(options.fullscreen)
        {
-               display.set_mode(VideoMode(options.width, options.height));
+               display.set_mode(VideoMode(options.width, options.height), true);
                warp_pointer(options.width/2, options.height/2);
        }
 }