From afccbe2f52eb950dd214a60f91d5ed7fb63826bc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Feb 2015 11:38:56 +0000 Subject: Save window size and position when closed via window manager. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5542 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 3 ++- src/Patchage.cpp | 26 +++++++++++++++++--------- src/main.cpp | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 890437c..72245d1 100644 --- a/NEWS +++ b/NEWS @@ -2,9 +2,10 @@ patchage (1.0.1) unstable; * Support Jack CV and OSC via metadata. * Configure based on compiler target OS for cross-compilation. + * Save window size and position when closed via window manager. * Fix compilation with Jack DBus. - -- David Robillard Wed, 19 Nov 2014 13:42:09 -0500 + -- David Robillard Sun, 08 Feb 2015 06:36:55 -0500 patchage (1.0.0) stable; diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 250704a..facc7bd 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -53,6 +53,10 @@ #include #endif +#ifdef HAVE_ALSA + #include "AlsaDriver.hpp" +#endif + #ifdef PATCHAGE_GTK_OSX #include @@ -72,18 +76,21 @@ terminate_cb(GtkosxApplication* app, gpointer data) #endif -#ifdef HAVE_ALSA - #include "AlsaDriver.hpp" -#endif - -using std::cout; -using std::endl; -using std::string; +static bool +configure_cb(GtkWindow* parentWindow, GdkEvent* event, gpointer data) +{ + ((Patchage*)data)->store_window_location(); + return FALSE; +} struct ProjectList_column_record : public Gtk::TreeModel::ColumnRecord { Gtk::TreeModelColumn label; }; +using std::cout; +using std::endl; +using std::string; + #define INIT_WIDGET(x) x(_xml, ((const char*)#x) + 1) Patchage::Patchage(int argc, char** argv) @@ -302,6 +309,9 @@ Patchage::Patchage(int argc, char** argv) _menu_view_sprung_layout->set_active(_conf->get_sprung_layout()); _main_paned->set_position(42); + g_signal_connect(_main_win->gobj(), "configure-event", + G_CALLBACK(configure_cb), this); + _canvas->widget().grab_focus(); // Idle callback, check if we need to refresh @@ -866,7 +876,6 @@ Patchage::on_legend_color_change(int id, const std::string& label, uint32_t rgba void Patchage::save() { - store_window_location(); _conf->set_zoom(_canvas->get_zoom()); // Can be changed by ganv _conf->save(); } @@ -874,7 +883,6 @@ Patchage::save() void Patchage::on_quit() { - save(); #ifdef HAVE_ALSA _alsa_driver->detach(); #endif diff --git a/src/main.cpp b/src/main.cpp index 715cb43..4a87bbb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,7 @@ main(int argc, char** argv) Patchage patchage(argc, argv); app.run(*patchage.window()); + patchage.save(); } catch (std::exception& e) { std::cerr << "patchage: error: " << e.what() << std::endl; -- cgit v1.2.1