X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fwindow.cpp;h=073cd8d5c819311277bfeb6e0ff0444521a4eeb9;hb=787d1982dceae67b9b934a9b74e08a096c0c1830;hp=166e49f716fc8f63944015360b8806068ff325b6;hpb=1aca77b93853ee127ac3bbf6886f7f04920542ef;p=libs%2Fgui.git diff --git a/source/graphics/window.cpp b/source/graphics/window.cpp index 166e49f..073cd8d 100644 --- a/source/graphics/window.cpp +++ b/source/graphics/window.cpp @@ -1,3 +1,4 @@ +#include #include "display.h" #include "window.h" #include "window_private.h" @@ -8,6 +9,9 @@ namespace Msp { namespace Graphics { WindowOptions::WindowOptions(): + x(0), + y(0), + user_position(false), width(640), height(480), fullscreen(false), @@ -36,13 +40,19 @@ void Window::init() { visible = false; kbd_autorepeat = true; + touch_input = false; resizing = false; + moving = false; priv = new Private; 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 +61,7 @@ Window::~Window() display.remove_window(*this); - if(options.fullscreen) + if(options.fullscreen && visible) display.restore_mode(); delete priv; @@ -60,18 +70,31 @@ 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() +{ + 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) @@ -79,6 +102,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 +115,7 @@ void Window::show() if(options.fullscreen) { - display.set_mode(VideoMode(options.width, options.height)); + set_fullscreen_mode(); warp_pointer(options.width/2, options.height/2); } }