From: Mikko Rasa Date: Wed, 26 Dec 2007 13:56:05 +0000 (+0000) Subject: Support reconfiguring Windows on the fly X-Git-Tag: 0.9~13 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=78b7a839c4084f7a6cef80cd7d59621460fe5f53;p=libs%2Fgui.git Support reconfiguring Windows on the fly --- diff --git a/source/window.cpp b/source/window.cpp index 2241956..f916d1c 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -65,6 +65,31 @@ void Window::set_title(const string &title) display.check_error(); } +void Window::reconfigure(const WindowOptions &opts) +{ + bool fullscreen_changed=(opts.fullscreen!=options.fullscreen); + + options=opts; + + ::Display *dpy=display.get_display(); + + XMoveResizeWindow(dpy, window, 0, 0, options.width, options.height); + + if(fullscreen_changed) + { + hide(); + XSetWindowAttributes attr; + attr.override_redirect=options.fullscreen; + XChangeWindowAttributes(dpy, window, CWOverrideRedirect, &attr); + show(); + } + + if(options.fullscreen) + display.set_mode(VideoMode(options.width, options.height)); + else if(fullscreen_changed) + display.restore_mode(); +} + void Window::show() { XMapRaised(display.get_display(), window); diff --git a/source/window.h b/source/window.h index 1047038..2999a78 100644 --- a/source/window.h +++ b/source/window.h @@ -50,7 +50,9 @@ public: ~Window(); void set_title(const std::string &); + void reconfigure(const WindowOptions &); + const WindowOptions &get_options() const { return options; } unsigned get_width() const { return options.width; } unsigned get_height() const { return options.height; } WindowHandle get_handle() const { return window; }