]> git.tdb.fi Git - libs/gui.git/commitdiff
Support reconfiguring Windows on the fly
authorMikko Rasa <tdb@tdb.fi>
Wed, 26 Dec 2007 13:56:05 +0000 (13:56 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 26 Dec 2007 13:56:05 +0000 (13:56 +0000)
source/window.cpp
source/window.h

index 224195605225f16a33427cec2762e3f77f690cb1..f916d1c9e5312e4290d40224e076b0e9e776b5e1 100644 (file)
@@ -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);
index 1047038366917854f776f22fae72de60e87ad480..2999a783fc137a1c3e1e67e6d01464c19286d530 100644 (file)
@@ -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; }