hrev51523 adds 1 changeset to branch 'master'
old head: 93596e8037d47bf865fec286977b9b37c7a75c87
new head: 9df5205c653cecdeefb1d948a9b33ef373e3af39
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=9df5205c653c+%5E93596e8037d4
----------------------------------------------------------------------------
9df5205c653c: Workspaces: Make sure settings is set only once
... fixing oversight in hrev51512.
Erase the file and write all settings to disk each time.
When Workspaces is running in a window WorkspacesSettings
is destroyed first, then WorkspacesView is destroyed.
WorkspacesSettings saves all settings except for 'switch on
wheel', then WorkspacesView reads the settings in from
disk, tacks the switch on wheel setting on, then writes
the settings back to disk.
If WorkspacesView is a (Deskbar) replicant instead the
WorkspacesSettings steps are skipped. WorkspacesView reads
in the settings from disk, tacks 'switch on wheel' on, erases the
file, then saves all settings back to disk. Use ReplaceBool to
ensure that the 'switch on wheel' settings is added just once.
Create the file if it doesn't exist in either case.
Don't check Unflatten status because will fail on empty file.
SaveSettings on the view before opening Deskbar replicant
so that 'switch on wheel' gets loaded.
[ John Scipione <jscipione@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev51523
Commit: 9df5205c653cecdeefb1d948a9b33ef373e3af39
URL: http://cgit.haiku-os.org/haiku/commit/?id=9df5205c653c
Author: John Scipione <jscipione@xxxxxxxxx>
Date: Sat Nov 4 06:32:14 2017 UTC
----------------------------------------------------------------------------
1 file changed, 18 insertions(+), 15 deletions(-)
src/apps/workspaces/Workspaces.cpp | 33 ++++++++++++++++++---------------
----------------------------------------------------------------------------
diff --git a/src/apps/workspaces/Workspaces.cpp
b/src/apps/workspaces/Workspaces.cpp
index af50020..eae4e3d 100644
--- a/src/apps/workspaces/Workspaces.cpp
+++ b/src/apps/workspaces/Workspaces.cpp
@@ -148,6 +148,8 @@ class WorkspacesView : public BView {
void _ExcludeFromParentClipping();
void _CleanupParentClipping();
+ friend class WorkspacesWindow;
+
void _LoadSettings();
void _SaveSettings();
@@ -260,18 +262,12 @@ WorkspacesSettings::WorkspacesSettings()
WorkspacesSettings::~WorkspacesSettings()
{
BFile file;
-
- // read switch on wheel setting from file
- bool switchOnWheel = false;
- if (OpenSettingsFile(file, B_READ_ONLY) == B_OK) {
- BMessage settings;
- if (settings.Unflatten(&file) == B_OK)
- settings.FindBool("switch on wheel", &switchOnWheel);
+ if (OpenSettingsFile(file, B_WRITE_ONLY | B_ERASE_FILE | B_CREATE_FILE)
+ != B_OK) {
+ return;
}
- // write settings file
- if (OpenSettingsFile(file, B_WRITE_ONLY | B_CREATE_FILE) != B_OK)
- return;
+ // switch on wheel saved by view later on
BMessage settings('wksp');
if (settings.AddRect("window", fWindowFrame) == B_OK
@@ -279,8 +275,7 @@ WorkspacesSettings::~WorkspacesSettings()
&& settings.AddBool("auto-raise", fAutoRaising) == B_OK
&& settings.AddBool("always on top", fAlwaysOnTop) == B_OK
&& settings.AddBool("has title", fHasTitle) == B_OK
- && settings.AddBool("has border", fHasBorder) == B_OK
- && settings.AddBool("switch on wheel", switchOnWheel) == B_OK) {
+ && settings.AddBool("has border", fHasBorder) == B_OK) {
settings.Flatten(&file);
}
}
@@ -511,13 +506,19 @@ void
WorkspacesView::_SaveSettings()
{
BFile file;
- if (OpenSettingsFile(file, B_READ_WRITE | B_CREATE_FILE) != B_OK)
+ if (OpenSettingsFile(file, B_READ_ONLY | B_CREATE_FILE) != B_OK)
return;
BMessage settings('wksp');
settings.Unflatten(&file);
- if (settings.AddBool("switch on wheel", fSwitchOnWheel) == B_OK)
- settings.Flatten(&file);
+
+ if (OpenSettingsFile(file, B_WRITE_ONLY | B_ERASE_FILE) != B_OK)
+ return;
+
+ if (settings.ReplaceBool("switch on wheel", fSwitchOnWheel) != B_OK)
+ settings.AddBool("switch on wheel", fSwitchOnWheel);
+
+ settings.Flatten(&file);
}
@@ -955,6 +956,8 @@ WorkspacesWindow::MessageReceived(BMessage *message)
if (deskbar.HasItem(kDeskbarItemName))
deskbar.RemoveItem(kDeskbarItemName);
else {
+ fWorkspacesView->_SaveSettings();
+ // save "switch on wheel" setting for
replicant to load
entry_ref ref;
be_roster->FindApp(kSignature, &ref);
deskbar.AddItem(&ref);