fix save/restore [plugin] window pos&size (without save)
authorRobin Gareus <robin@gareus.org>
Sun, 7 Jul 2013 17:29:42 +0000 (19:29 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 7 Jul 2013 17:29:42 +0000 (19:29 +0200)
gtk2_ardour/window_manager.cc
gtk2_ardour/window_manager.h

index b76958d4d48d910841fa1b49c2cc34d75c861bf5..730668d7e439bac92896d6acd17e9f04e447c848 100644 (file)
@@ -263,8 +263,27 @@ ProxyBase::toggle()
                _window->show_all();
                /* we'd like to just call this and nothing else */
                _window->present ();
+
+               if (_width != -1 && _height != -1) {
+                       _window->set_default_size (_width, _height);
+               }
+               if (_x_off != -1 && _y_off != -1) {
+                       _window->move (_x_off, _y_off);
+               }
+
        } else {
+               if (_window->is_mapped()) {
+                       save_pos_and_size();
+               }
                vistracker->cycle_visibility ();
+               if (_window->is_mapped()) {
+                       if (_width != -1 && _height != -1) {
+                               _window->set_default_size (_width, _height);
+                       }
+                       if (_x_off != -1 && _y_off != -1) {
+                               _window->move (_x_off, _y_off);
+                       }
+               }
        }
 }
 
@@ -325,6 +344,7 @@ ProxyBase::setup ()
        assert (_window);
 
        vistracker = new Gtkmm2ext::VisibilityTracker (*_window);
+       _window->signal_delete_event().connect (sigc::mem_fun (*this, &ProxyBase::handle_win_event));
 
        if (_width != -1 || _height != -1 || _x_off != -1 || _y_off != -1) {
                /* cancel any mouse-based positioning */
@@ -379,10 +399,17 @@ ProxyBase::hide ()
 {
        Gtk::Window* win = get (false);
        if (win) {
+               save_pos_and_size();
                win->hide ();
        }
 }
 
+void
+ProxyBase::save_pos_and_size ()
+{
+       _window->get_position (_x_off, _y_off);
+       _window->get_size (_width, _height);
+}
 /*-----------------------*/
 
 ProxyTemporary::ProxyTemporary (const string& name, Gtk::Window* win)
index 7138a95e7b6674793f71bb7bea7df6b1b9db3e9b..404bfd69d361a7290a3dfa254b26c8c190820fbb 100644 (file)
@@ -120,6 +120,8 @@ class ProxyBase : public sigc::trackable {
     mutable int  _width; ///< width
     mutable int  _height; ///< height
     Gtkmm2ext::VisibilityTracker* vistracker;
+
+    void save_pos_and_size ();
     
     void setup ();
 };