X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fwindow_manager.cc;h=01baf3e1fde9486e349c487209396cf3fb3784a5;hb=e3dd226ffa562d28758555d67961d95723e2a2f0;hp=2a195ac90f7819b78024e78be91c9372ab424104;hpb=31d234b48c36bddb4d5228a3abee9c4419403879;p=ardour.git diff --git a/gtk2_ardour/window_manager.cc b/gtk2_ardour/window_manager.cc index 2a195ac90f..01baf3e1fd 100644 --- a/gtk2_ardour/window_manager.cc +++ b/gtk2_ardour/window_manager.cc @@ -34,6 +34,7 @@ using std::string; using namespace WM; +using namespace PBD; Manager* Manager::_instance = 0; @@ -51,6 +52,10 @@ Manager::Manager () { } +Manager::~Manager () +{ +} + void Manager::register_window (ProxyBase* info) { @@ -119,11 +124,9 @@ Manager::add_state (XMLNode& root) const void Manager::set_session (ARDOUR::Session* s) { + SessionHandlePtr::set_session (s); for (Windows::const_iterator i = _windows.begin(); i != _windows.end(); ++i) { - ARDOUR::SessionHandlePtr* sp = (*i)->session_handle (); - if (sp) { - sp->set_session (s); - } + (*i)->set_session(s); } } @@ -191,6 +194,7 @@ ProxyBase::ProxyBase (const string& name, const std::string& menu_name, const XM ProxyBase::~ProxyBase () { delete vistracker; + delete _window; } void @@ -218,16 +222,16 @@ ProxyBase::set_state (const XMLNode& node) } if ((prop = (*i)->property (X_("x-off"))) != 0) { - _x_off = atoi (prop->value().c_str()); + _x_off = atoi (prop->value()); } if ((prop = (*i)->property (X_("y-off"))) != 0) { - _y_off = atoi (prop->value().c_str()); + _y_off = atoi (prop->value()); } if ((prop = (*i)->property (X_("x-size"))) != 0) { - _width = atoi (prop->value().c_str()); + _width = atoi (prop->value()); } if ((prop = (*i)->property (X_("y-size"))) != 0) { - _height = atoi (prop->value().c_str()); + _height = atoi (prop->value()); } } @@ -262,8 +266,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); + } + } } } @@ -280,8 +303,10 @@ ProxyBase::get_state () const /* we have a window, so use current state */ _visible = vistracker->partially_visible (); - _window->get_position (_x_off, _y_off); - _window->get_size (_width, _height); + if (_visible) { + _window->get_position (_x_off, _y_off); + _window->get_size (_width, _height); + } } node->add_property (X_("visible"), _visible? X_("yes") : X_("no")); @@ -324,6 +349,7 @@ ProxyBase::setup () assert (_window); vistracker = new Gtkmm2ext::VisibilityTracker (*_window); + _window->signal_delete_event().connect (sigc::mem_fun (*this, &ProxyBase::delete_event_handler)); if (_width != -1 || _height != -1 || _x_off != -1 || _y_off != -1) { /* cancel any mouse-based positioning */ @@ -337,13 +363,15 @@ ProxyBase::setup () if (_x_off != -1 && _y_off != -1) { _window->move (_x_off, _y_off); } + set_session(_session); } void ProxyBase::show () { - Gtk::Window* win = get (true); - win->show (); + get (true); + assert (_window); + _window->show (); } void @@ -357,17 +385,19 @@ ProxyBase::maybe_show () void ProxyBase::show_all () { - Gtk::Window* win = get (true); - win->show_all (); + get (true); + assert (_window); + _window->show_all (); } - void ProxyBase::present () { - Gtk::Window* win = get (true); - win->show_all (); - win->present (); + get (true); + assert (_window); + + _window->show_all (); + _window->present (); /* turn off any mouse-based positioning */ _window->set_position (Gtk::WIN_POS_NONE); @@ -376,12 +406,27 @@ ProxyBase::present () void ProxyBase::hide () { - Gtk::Window* win = get (false); - if (win) { - win->hide (); + if (_window) { + save_pos_and_size(); + _window->hide (); } } +bool +ProxyBase::delete_event_handler (GdkEventAny* /*ev*/) +{ + hide(); + return true; +} + +void +ProxyBase::save_pos_and_size () +{ + if (_window) { + _window->get_position (_x_off, _y_off); + _window->get_size (_width, _height); + } +} /*-----------------------*/ ProxyTemporary::ProxyTemporary (const string& name, Gtk::Window* win) @@ -394,6 +439,7 @@ ProxyTemporary::~ProxyTemporary () { } + ARDOUR::SessionHandlePtr* ProxyTemporary::session_handle() {