Index: src/apps/overlayimage/OverlayWindow.h
===================================================================
--- src/apps/overlayimage/OverlayWindow.h	(revision 37223)
+++ src/apps/overlayimage/OverlayWindow.h	(working copy)
@@ -16,11 +16,17 @@
 
 #include <Window.h>
 
+class OverlayView;
 
 class OverlayWindow : public BWindow {
 public:
-						OverlayWindow();
+						OverlayWindow(BRect frame, BMessage* settings);
+		virtual			~OverlayWindow();
+		void			SetFrame(BRect frame, bool forceCenter = false);
		virtual bool	QuitRequested();
+		status_t		SaveSettings(BMessage* archive) const;
+private:
+		OverlayView*	fOverlayView;
 };
 
 #endif // OVERLAY_WINDOW_H
Index: src/apps/overlayimage/OverlayView.h
===================================================================
--- src/apps/overlayimage/OverlayView.h (revision 37223)
+++ src/apps/overlayimage/OverlayView.h (working copy)
@@ -38,10 +38,12 @@
	static				BArchivable *Instantiate(BMessage *archive);
	virtual status_t	Archive(BMessage *data, bool deep = true) const;
	void				OverlayAboutRequested();
+	status_t			SaveSettings(BMessage* archive) const;
 
 private:
	BBitmap				*fBitmap;
	bool				fReplicated;
+	status_t			_LoadSettings(BMessage* archive);
 };
 
 #endif // OVERLAY_VIEW_H
Index: src/apps/overlayimage/OverlayApp.cpp
===================================================================
--- src/apps/overlayimage/OverlayApp.cpp	(revision 37223)
+++ src/apps/overlayimage/OverlayApp.cpp	(working copy)
@@ -11,6 +11,15 @@
  *			Humdinger		<humdingerb@gmail.com>
  */
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <Directory.h>
+#include <File.h>
+#include <FindDirectory.h>
+#include <Path.h>
+
 #include "OverlayApp.h"
 #include "OverlayWindow.h"
 
@@ -20,11 +29,107 @@
 {
	be_locale->GetAppCatalog(&fCatalog);
	
-	OverlayWindow *theWindow = new OverlayWindow();
-	theWindow->Show();
+	BMessage settings;
+	_LoadSettings(settings);
+
+	BRect frame(0, 0, 320.0 - 1, 200.0 - 1);
+	fOverlayWindow = new OverlayWindow(frame, &settings);
+
+	fOverlayWindow->Show();
 }
 
 
+OverlayApp::~OverlayApp()
+{
+}
+
+
+bool
+OverlayApp::QuitRequested()
+{
+	// save current user preferences
+	_SaveSettings();
+
+	return true;
+}
+
+
+void
+OverlayApp::_LoadSettings(BMessage& archive)
+{
+	// locate preferences file
+	BFile prefsFile;
+	if (_InitSettingsFile(&prefsFile, false) < B_OK) {
+		printf("no preference file found.\n");
+		return;
+	}
+
+	// unflatten settings data
+	if (archive.Unflatten(&prefsFile) < B_OK) {
+		printf("error unflattening settings.\n");
+	}
+}
+
+
+void
+OverlayApp::_SaveSettings()
+{
+	if (!fOverlayWindow->Lock())
+		return;
+
+	BMessage archive;
+	status_t ret = fOverlayWindow->SaveSettings(&archive);
+
+	fOverlayWindow->Unlock();
+
+	if (ret < B_OK) {
+		fprintf(stderr, "_SaveSettings() - "
+						"error from window: %s\n", strerror(ret));
+		return;
+	}
+
+	// flatten entire acrhive and write to settings file
+	BFile prefsFile;
+	ret = _InitSettingsFile(&prefsFile, true);
+	if (ret < B_OK) {
+		fprintf(stderr, "_SaveSettings() - "
+						"error creating file: %s\n", strerror(ret));
+		return;
+	}
+
+	ret = archive.Flatten(&prefsFile);
+	if (ret < B_OK) {
+		fprintf(stderr, "_SaveSettings() - "
+						"error flattening to file: %s\n", strerror(ret));
+		return;
+	}
+}
+
+
+status_t
+OverlayApp::_InitSettingsFile(BFile* file, bool write)
+{
+	// find user settings directory
+	BPath prefsPath;
+	status_t ret = find_directory(B_USER_SETTINGS_DIRECTORY, &prefsPath);
+
+	if (ret < B_OK)
+		return ret;
+
+	ret = prefsPath.Append("OverlayImage_settings");
+	if (ret < B_OK)
+		return ret;
+
+	if (write)
+		ret = file->SetTo(prefsPath.Path(),
+			B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
+	else
+		ret = file->SetTo(prefsPath.Path(), B_READ_ONLY);
+
+	return ret;
+}
+
+
 int
 main()
 {
Index: src/apps/overlayimage/OverlayApp.h
===================================================================
--- src/apps/overlayimage/OverlayApp.h	(revision 37223)
+++ src/apps/overlayimage/OverlayApp.h	(working copy)
@@ -18,12 +18,19 @@
 #include <Catalog.h>
 #include <Locale.h>
 
+class OverlayWindow;
 
 class OverlayApp : public BApplication {
 public:
					OverlayApp();
+	virtual			~OverlayApp();
+	virtual bool	QuitRequested();
 private:
-		BCatalog	fCatalog;				
+	void			_LoadSettings(BMessage& settings);
+	void			_SaveSettings();
+	status_t		_InitSettingsFile(BFile* file, bool write);
+	BCatalog		fCatalog;				
+	OverlayWindow*	fOverlayWindow;
 };
 
 #endif // OVERLAY_APP_H
Index: src/apps/overlayimage/OverlayWindow.cpp
===================================================================
--- src/apps/overlayimage/OverlayWindow.cpp (revision 37223)
+++ src/apps/overlayimage/OverlayWindow.cpp (working copy)
@@ -17,6 +17,7 @@
 #include <Application.h>
 #include <Catalog.h>
 #include <Locale.h>
+#include <Screen.h>
 #include <String.h>
 #include <TextView.h>
 
@@ -24,17 +25,18 @@
 #define B_TRANSLATE_CONTEXT "Main window"
 
 
-OverlayWindow::OverlayWindow() 
+OverlayWindow::OverlayWindow(BRect frame, BMessage* settings) 
	:
-	BWindow(BRect(100, 100, 450, 350), "OverlayImage", 
+	BWindow(frame, "OverlayImage", 
		B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
 {
-	OverlayView *replView = new OverlayView(Bounds());
-	AddChild(replView);
+	fOverlayView = new OverlayView(Bounds());
 
	BView *bgView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW);
	bgView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-	AddChild(bgView);
+
+	AddChild(fOverlayView);
+	fOverlayView->AddChild(bgView);
	
	BString text;
	text << B_TRANSLATE("Enable \"Show replicants\" in Deskbar.");
@@ -42,13 +44,59 @@
	text << B_TRANSLATE("Drag & drop an image.");
	text << "\n";
	text << B_TRANSLATE("Drag the replicant to the Desktop.");
-	replView->SetToolTip(text);
+	fOverlayView->SetToolTip(text);
+
+	BRect rect;
+	if (settings->FindRect("window frame", &rect) == B_OK)
+		SetFrame(rect);
+	else
+		SetFrame(frame, true);
 }
 
 
+OverlayWindow::~OverlayWindow()
+{
+}
+
+
 bool
 OverlayWindow::QuitRequested()
 {
	be_app->PostMessage(B_QUIT_REQUESTED);
-	return true;
+
+	// NOTE: don't quit, since the app needs us
+	// for saving settings yet...
+	return false;
 }
+
+
+status_t
+OverlayWindow::SaveSettings(BMessage* archive) const
+{
+	status_t ret = archive->AddRect("window frame", Frame());
+	if (ret < B_OK)
+		return ret;
+
+	return fOverlayView->SaveSettings(archive);
+}
+
+
+void
+OverlayWindow::SetFrame(BRect frame, bool forceCenter)
+{
+	// make sure window frame is on screen (center, if not)
+	BScreen screen(this);
+
+	BRect screenFrame = screen.Frame();
+	if (forceCenter || !screenFrame.Contains(frame)) {
+		float left = (screenFrame.Width() - frame.Width()) / 2.0;
+		float top = (screenFrame.Height() - frame.Height()) / 2.0;
+		left += screenFrame.left;
+		top += screenFrame.top;
+		frame.OffsetTo(left, top);
+	}
+
+	MoveTo(frame.left, frame.top);
+	ResizeTo(frame.Width(), frame.Height());
+}
+
Index: src/apps/overlayimage/OverlayView.cpp
===================================================================
--- src/apps/overlayimage/OverlayView.cpp	(revision 37223)
+++ src/apps/overlayimage/OverlayView.cpp	(working copy)
@@ -110,6 +110,13 @@
 {
	BView::Archive(archive, deep);
 
+	// passed on request to parent
+	status_t ret = BView::Archive(archive);
+
+	// save all the options
+	if (ret == B_OK)
+		ret = SaveSettings(archive);
+
	archive->AddString("add_on", "application/x-vnd.Haiku-OverlayImage");
	archive->AddString("class", "OverlayImage");
 
@@ -120,7 +127,7 @@
	}			
	//archive->PrintToStream();
 
-	return B_OK;
+	return ret;
 }
 
 
@@ -144,3 +151,24 @@
	view->SetFontAndColor(0, 12, &font);
	alert->Go();
 }
+
+
+status_t
+OverlayView::_LoadSettings(BMessage* archive)
+{
+	if (!archive)
+		return B_BAD_VALUE;
+
+	return B_OK;
+}
+
+
+status_t
+OverlayView::SaveSettings(BMessage* archive) const
+{
+	status_t ret = archive ? B_OK : B_BAD_VALUE;
+
+	return ret;
+}
+
+
