X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fwindow.cpp;h=79cfb7d99833029a0827064c5f74bde8fd3f8899;hb=b99a9eb342d0f6ba5509c6d9f8ab0b0b5d5d2979;hp=d2fb37f893d23379a1df46914b175f3a7312bdc5;hpb=1d7113259625a91f5f6d2f53365aad22ae744689;p=libs%2Fgui.git diff --git a/source/graphics/window.cpp b/source/graphics/window.cpp index d2fb37f..79cfb7d 100644 --- a/source/graphics/window.cpp +++ b/source/graphics/window.cpp @@ -1,21 +1,13 @@ -#include -#include "display.h" #include "window.h" #include "window_private.h" +#include +#include "display.h" using namespace std; namespace Msp { namespace Graphics { -WindowOptions::WindowOptions(): - width(640), - height(480), - fullscreen(false), - resizable(false) -{ } - - Window::Window(Display &dpy, unsigned w, unsigned h, bool fs): display(dpy) { @@ -35,12 +27,11 @@ Window::Window(Display &dpy, const WindowOptions &opts): void Window::init() { - visible = false; - kbd_autorepeat = true; - touch_input = false; - resizing = false; priv = new Private; + if(options.fullscreen && !options.fullscreen_monitor) + options.fullscreen_monitor = display.get_desktop_mode().monitor; + platform_init(); display.add_window(*this); @@ -68,19 +59,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; @@ -99,7 +105,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); } }