summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-08 11:38:56 +0000
committerDavid Robillard <d@drobilla.net>2015-02-08 11:38:56 +0000
commitafccbe2f52eb950dd214a60f91d5ed7fb63826bc (patch)
tree5581c9b743c859a25e969ba4e2f1f5e817a3fd7c /src
parent8e9ed4b7ddeea6f48fe31dfaa911ac46a727973a (diff)
downloadpatchage-afccbe2f52eb950dd214a60f91d5ed7fb63826bc.tar.gz
patchage-afccbe2f52eb950dd214a60f91d5ed7fb63826bc.tar.bz2
patchage-afccbe2f52eb950dd214a60f91d5ed7fb63826bc.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/Patchage.cpp26
-rw-r--r--src/main.cpp1
2 files changed, 18 insertions, 9 deletions
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 <jack/session.h>
#endif
+#ifdef HAVE_ALSA
+ #include "AlsaDriver.hpp"
+#endif
+
#ifdef PATCHAGE_GTK_OSX
#include <gtkosxapplication.h>
@@ -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<Glib::ustring> 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;