Changed the way DesktopSettings work:
* Removed the DesktopSettings lock itself - it's not really needed at all, and causes some trouble with a clean locking design. This may even have fixed bug #757, at least I couldn't reproduce it anymore. * There is now a class for read-only access that requires you to have locked the desktop (either read or write). * There is now another class LockedDesktopSettings that allows you to set settings (and only that) - when you're changing the settings, you must not have read locked the desktop (ie. hold the single window lock). The class will obtain a write lock, but write locks can be nested. * Moved SetWorkspacesCount() into the Desktop class. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
DesktopSettings::Private::Private(server_read_only_memory* shared)
|
||||
: BLocker("DesktopSettings_Private"),
|
||||
DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
|
||||
:
|
||||
fShared(*shared)
|
||||
{
|
||||
// if the on-disk settings are not complete, the defaults will be kept
|
||||
@@ -33,13 +33,13 @@ DesktopSettings::Private::Private(server_read_only_memory* shared)
|
||||
}
|
||||
|
||||
|
||||
DesktopSettings::Private::~Private()
|
||||
DesktopSettingsPrivate::~DesktopSettingsPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::_SetDefaults()
|
||||
DesktopSettingsPrivate::_SetDefaults()
|
||||
{
|
||||
fPlainFont = *gFontManager->DefaultPlainFont();
|
||||
fBoldFont = *gFontManager->DefaultBoldFont();
|
||||
@@ -73,7 +73,7 @@ DesktopSettings::Private::_SetDefaults()
|
||||
|
||||
|
||||
status_t
|
||||
DesktopSettings::Private::_GetPath(BPath& path)
|
||||
DesktopSettingsPrivate::_GetPath(BPath& path)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status < B_OK)
|
||||
@@ -88,7 +88,7 @@ DesktopSettings::Private::_GetPath(BPath& path)
|
||||
|
||||
|
||||
status_t
|
||||
DesktopSettings::Private::_Load()
|
||||
DesktopSettingsPrivate::_Load()
|
||||
{
|
||||
// TODO: add support for old app_server_settings file as well
|
||||
|
||||
@@ -224,7 +224,7 @@ DesktopSettings::Private::_Load()
|
||||
|
||||
|
||||
status_t
|
||||
DesktopSettings::Private::Save(uint32 mask)
|
||||
DesktopSettingsPrivate::Save(uint32 mask)
|
||||
{
|
||||
BPath basePath;
|
||||
status_t status = _GetPath(basePath);
|
||||
@@ -314,7 +314,7 @@ DesktopSettings::Private::Save(uint32 mask)
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultPlainFont(const ServerFont &font)
|
||||
DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
|
||||
{
|
||||
fPlainFont = font;
|
||||
Save(kFontSettings);
|
||||
@@ -322,14 +322,14 @@ DesktopSettings::Private::SetDefaultPlainFont(const ServerFont &font)
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultPlainFont() const
|
||||
DesktopSettingsPrivate::DefaultPlainFont() const
|
||||
{
|
||||
return fPlainFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultBoldFont(const ServerFont &font)
|
||||
DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
|
||||
{
|
||||
fBoldFont = font;
|
||||
Save(kFontSettings);
|
||||
@@ -337,14 +337,14 @@ DesktopSettings::Private::SetDefaultBoldFont(const ServerFont &font)
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultBoldFont() const
|
||||
DesktopSettingsPrivate::DefaultBoldFont() const
|
||||
{
|
||||
return fBoldFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetDefaultFixedFont(const ServerFont &font)
|
||||
DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
|
||||
{
|
||||
fFixedFont = font;
|
||||
Save(kFontSettings);
|
||||
@@ -352,14 +352,14 @@ DesktopSettings::Private::SetDefaultFixedFont(const ServerFont &font)
|
||||
|
||||
|
||||
const ServerFont &
|
||||
DesktopSettings::Private::DefaultFixedFont() const
|
||||
DesktopSettingsPrivate::DefaultFixedFont() const
|
||||
{
|
||||
return fFixedFont;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
{
|
||||
fScrollBarInfo = info;
|
||||
Save(kAppearanceSettings);
|
||||
@@ -367,14 +367,14 @@ DesktopSettings::Private::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
|
||||
|
||||
const scroll_bar_info&
|
||||
DesktopSettings::Private::ScrollBarInfo() const
|
||||
DesktopSettingsPrivate::ScrollBarInfo() const
|
||||
{
|
||||
return fScrollBarInfo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetMenuInfo(const menu_info& info)
|
||||
DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
|
||||
{
|
||||
fMenuInfo = info;
|
||||
Save(kAppearanceSettings);
|
||||
@@ -382,14 +382,14 @@ DesktopSettings::Private::SetMenuInfo(const menu_info& info)
|
||||
|
||||
|
||||
const menu_info&
|
||||
DesktopSettings::Private::MenuInfo() const
|
||||
DesktopSettingsPrivate::MenuInfo() const
|
||||
{
|
||||
return fMenuInfo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetMouseMode(const mode_mouse mode)
|
||||
DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
|
||||
{
|
||||
fMouseMode = mode;
|
||||
Save(kMouseSettings);
|
||||
@@ -397,21 +397,21 @@ DesktopSettings::Private::SetMouseMode(const mode_mouse mode)
|
||||
|
||||
|
||||
mode_mouse
|
||||
DesktopSettings::Private::MouseMode() const
|
||||
DesktopSettingsPrivate::MouseMode() const
|
||||
{
|
||||
return fMouseMode;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DesktopSettings::Private::FocusFollowsMouse() const
|
||||
DesktopSettingsPrivate::FocusFollowsMouse() const
|
||||
{
|
||||
return MouseMode() != B_NORMAL_MOUSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetWorkspacesCount(int32 number)
|
||||
DesktopSettingsPrivate::SetWorkspacesCount(int32 number)
|
||||
{
|
||||
if (number < 1)
|
||||
number = 1;
|
||||
@@ -423,14 +423,14 @@ DesktopSettings::Private::SetWorkspacesCount(int32 number)
|
||||
|
||||
|
||||
int32
|
||||
DesktopSettings::Private::WorkspacesCount() const
|
||||
DesktopSettingsPrivate::WorkspacesCount() const
|
||||
{
|
||||
return fWorkspacesCount;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::Private::SetWorkspacesMessage(int32 index, BMessage& message)
|
||||
DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
|
||||
{
|
||||
if (index < 0 || index > kMaxWorkspaces)
|
||||
return;
|
||||
@@ -440,7 +440,7 @@ DesktopSettings::Private::SetWorkspacesMessage(int32 index, BMessage& message)
|
||||
|
||||
|
||||
const BMessage*
|
||||
DesktopSettings::Private::WorkspacesMessage(int32 index) const
|
||||
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
|
||||
{
|
||||
if (index < 0 || index > kMaxWorkspaces)
|
||||
return NULL;
|
||||
@@ -449,27 +449,15 @@ DesktopSettings::Private::WorkspacesMessage(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
// #pragma mark - read access
|
||||
|
||||
|
||||
DesktopSettings::DesktopSettings(Desktop* desktop)
|
||||
:
|
||||
fSettings(desktop->fSettings)
|
||||
{
|
||||
fSettings = desktop->fSettings;
|
||||
fSettings->Lock();
|
||||
}
|
||||
|
||||
|
||||
DesktopSettings::~DesktopSettings()
|
||||
{
|
||||
fSettings->Unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultPlainFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultPlainFont(font);
|
||||
if (!desktop->fWindowLock.IsReadLocked() && !desktop->fWindowLock.IsWriteLocked())
|
||||
debugger("desktop not locked when trying to access settings");
|
||||
}
|
||||
|
||||
|
||||
@@ -480,13 +468,6 @@ DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultBoldFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultBoldFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
|
||||
{
|
||||
@@ -494,13 +475,6 @@ DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetDefaultFixedFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultFixedFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
|
||||
{
|
||||
@@ -508,13 +482,6 @@ DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
{
|
||||
fSettings->SetScrollBarInfo(info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
|
||||
{
|
||||
@@ -522,13 +489,6 @@ DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetMenuInfo(const menu_info& info)
|
||||
{
|
||||
fSettings->SetMenuInfo(info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::GetMenuInfo(menu_info& info) const
|
||||
{
|
||||
@@ -536,13 +496,6 @@ DesktopSettings::GetMenuInfo(menu_info& info) const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetMouseMode(const mode_mouse mode)
|
||||
{
|
||||
fSettings->SetMouseMode(mode);
|
||||
}
|
||||
|
||||
|
||||
mode_mouse
|
||||
DesktopSettings::MouseMode() const
|
||||
{
|
||||
@@ -557,13 +510,6 @@ DesktopSettings::FocusFollowsMouse() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetWorkspacesCount(int32 number)
|
||||
{
|
||||
fSettings->SetWorkspacesCount(number);
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
DesktopSettings::WorkspacesCount() const
|
||||
{
|
||||
@@ -571,16 +517,76 @@ DesktopSettings::WorkspacesCount() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DesktopSettings::SetWorkspacesMessage(int32 index, BMessage& message)
|
||||
{
|
||||
fSettings->SetWorkspacesMessage(index, message);
|
||||
}
|
||||
|
||||
|
||||
const BMessage*
|
||||
DesktopSettings::WorkspacesMessage(int32 index) const
|
||||
{
|
||||
return fSettings->WorkspacesMessage(index);
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - write access
|
||||
|
||||
|
||||
LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
|
||||
:
|
||||
fSettings(desktop->fSettings),
|
||||
fDesktop(desktop)
|
||||
{
|
||||
// TODO: this only works in MultiLocker's DEBUG mode
|
||||
#if 0
|
||||
if (desktop->fWindowLock.IsReadLocked())
|
||||
debugger("desktop read locked when trying to change settings");
|
||||
#endif
|
||||
|
||||
fDesktop->LockAllWindows();
|
||||
}
|
||||
|
||||
|
||||
LockedDesktopSettings::~LockedDesktopSettings()
|
||||
{
|
||||
fDesktop->UnlockAllWindows();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultPlainFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultBoldFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
|
||||
{
|
||||
fSettings->SetDefaultFixedFont(font);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
|
||||
{
|
||||
fSettings->SetScrollBarInfo(info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetMenuInfo(const menu_info& info)
|
||||
{
|
||||
fSettings->SetMenuInfo(info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
|
||||
{
|
||||
fSettings->SetMouseMode(mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user