X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fwindow.cpp;h=dde92491ee1a1ce8d3035ec7d3bbeaf2dc0ba3ca;hb=30cab36b531f6efddca07c3fe9a6b1b81ca42bde;hp=256ab2d470ace62169af6c938f42722482f76412;hpb=9bc0825e93b1385a4aaf9f90d666a1ac409ffb17;p=libs%2Fgui.git diff --git a/source/graphics/window.cpp b/source/graphics/window.cpp index 256ab2d..dde9249 100644 --- a/source/graphics/window.cpp +++ b/source/graphics/window.cpp @@ -1,6 +1,7 @@ -#include "display.h" #include "window.h" #include "window_private.h" +#include +#include "display.h" using namespace std; @@ -8,9 +9,14 @@ namespace Msp { namespace Graphics { WindowOptions::WindowOptions(): + x(0), + y(0), + user_position(false), width(640), height(480), fullscreen(false), + fullscreen_monitor(0), + fullscreen_exclusive(true), resizable(false) { } @@ -36,13 +42,22 @@ void Window::init() { visible = false; kbd_autorepeat = true; + touch_input = false; resizing = false; + moving = false; priv = new Private; + if(options.fullscreen && !options.fullscreen_monitor) + options.fullscreen_monitor = display.get_desktop_mode().monitor; + platform_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 +66,7 @@ Window::~Window() display.remove_window(*this); - if(options.fullscreen) + if(options.fullscreen && visible) display.restore_mode(); delete priv; @@ -60,18 +75,34 @@ Window::~Window() void Window::reconfigure(const WindowOptions &opts) { bool fullscreen_changed = (opts.fullscreen!=options.fullscreen); - resizing = (opts.width!=options.width || opts.height!=options.height); + if(opts.width!=options.width || opts.height!=options.height) + resizing = true; + if(opts.x!=options.x || opts.y!=options.y) + moving = true; options = opts; - platform_reconfigure(fullscreen_changed); if(visible) { if(options.fullscreen) - display.set_mode(VideoMode(options.width, options.height)); + set_fullscreen_mode(); else if(fullscreen_changed) display.restore_mode(); } + + platform_reconfigure(fullscreen_changed); +} + +void Window::set_fullscreen_mode() +{ + if(!options.fullscreen_monitor) + options.fullscreen_monitor = display.get_desktop_mode().monitor; + VideoMode mode(options.width, options.height); + mode.monitor = options.fullscreen_monitor; + mode.rotation = mode.monitor->desktop_settings.rotation; + if(mode.rotation==ROTATE_LEFT || mode.rotation==ROTATE_RIGHT) + swap(mode.width, mode.height); + display.set_mode(mode, options.fullscreen_exclusive); } void Window::set_keyboard_autorepeat(bool r) @@ -79,6 +110,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 +123,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); } }