diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index a9dfe95f3f..ba7abc1019 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -4297,6 +4297,30 @@ ARDOUR_UI::mixer_settings () const return node; } +XMLNode* +ARDOUR_UI::main_window_settings () const +{ + XMLNode* node = 0; + + if (_session) { + node = _session->instant_xml(X_("Main")); + } else { + node = Config->instant_xml(X_("Main")); + } + + if (!node) { + if (getenv("ARDOUR_INSTANT_XML_PATH")) { + node = Config->instant_xml(getenv("ARDOUR_INSTANT_XML_PATH")); + } + } + + if (!node) { + node = new XMLNode (X_("Main")); + } + + return node; +} + XMLNode* ARDOUR_UI::editor_settings () const { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 7b6c6f9e21..a18703249f 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -220,6 +220,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr static void close_all_dialogs () { CloseAllDialogs(); } static sigc::signal CloseAllDialogs; + XMLNode* main_window_settings() const; XMLNode* editor_settings() const; XMLNode* mixer_settings () const; XMLNode* keyboard_settings () const; diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 6205272c4b..b7ec0ed0e9 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -142,8 +142,46 @@ ARDOUR_UI::setup_windows () _main_window.add (main_vpacker); transport_frame.show_all (); - _main_window.show_all (); + const XMLNode* mnode = main_window_settings (); + + if (mnode) { + const XMLProperty* prop; + gint x = -1; + gint y = -1; + gint w = -1; + gint h = -1; + + if ((prop = mnode->property (X_("x"))) != 0) { + x = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("y"))) != 0) { + y = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("w"))) != 0) { + w = atoi (prop->value()); + } + + if ((prop = mnode->property (X_("h"))) != 0) { + h = atoi (prop->value()); + } + + if (x >= 0 && y >= 0 && w >= 0 && h >= 0) { + _main_window.set_position (Gtk::WIN_POS_NONE); + } + + if (x >= 0 && y >= 0) { + _main_window.move (x, y); + } + + if (w > 0 && h > 0) { + _main_window.set_default_size (w, h); + } + } + + _main_window.show_all (); setup_toplevel_window (_main_window, "", this); rc_option_editor = new RCOptionEditor; diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 20d2153005..8564cf1f1d 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -637,6 +637,18 @@ ARDOUR_UI::save_ardour_state () XMLNode* window_node = new XMLNode (X_("UI")); window_node->add_property (_status_bar_visibility.get_state_name().c_str(), _status_bar_visibility.get_state_value ()); + /* main window */ + + gint mx, my, mw, mh; + _main_window.get_position (mx, my); + _main_window.get_size (mw, mh); + + XMLNode main_window_node (X_("Main")); + main_window_node.add_property (X_("x"), PBD::to_string (mx, std::dec)); + main_window_node.add_property (X_("y"), PBD::to_string (my, std::dec)); + main_window_node.add_property (X_("w"), PBD::to_string (mw, std::dec)); + main_window_node.add_property (X_("h"), PBD::to_string (mh, std::dec)); + /* Windows */ WM::Manager::instance().add_state (*window_node); @@ -677,6 +689,7 @@ ARDOUR_UI::save_ardour_state () UIConfiguration::instance().save_state (); if (_session) { + _session->add_instant_xml (main_window_node); _session->add_instant_xml (enode); _session->add_instant_xml (mnode); _session->add_instant_xml (bnode); @@ -684,6 +697,7 @@ ARDOUR_UI::save_ardour_state () _session->add_instant_xml (location_ui->ui().get_state ()); } } else { + Config->add_instant_xml (main_window_node); Config->add_instant_xml (enode); Config->add_instant_xml (mnode); Config->add_instant_xml (bnode);