X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fwindow.cpp;h=6cadf3ec9f4becb047c35033b7d70be5f919a770;hb=eddae342dd069589319029b48986b14dbbe5165b;hp=5bc9a358e2786d99e7ba7e4be1c63b6dce20afa8;hpb=f6ca714e2258f4cad433801c88264947d4c2d14c;p=libs%2Fgui.git diff --git a/source/graphics/window.cpp b/source/graphics/window.cpp index 5bc9a35..6cadf3e 100644 --- a/source/graphics/window.cpp +++ b/source/graphics/window.cpp @@ -11,9 +11,12 @@ 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) { } @@ -41,8 +44,12 @@ void Window::init() 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); @@ -70,19 +77,34 @@ 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() +{ + 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) { kbd_autorepeat = r; @@ -101,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); } }