Files
haiku-beta6/src/servers/app/DesktopSettings.cpp
T

921 lines
18 KiB
C++
Raw Normal View History

/*
2008-03-08 11:36:10 +00:00
* Copyright 2005-2008, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
* Axel Dörfler, [email protected]
2008-07-10 08:29:50 +00:00
* Andrej Spielmann, <[email protected]>
*/
#include "DesktopSettings.h"
#include "DesktopSettingsPrivate.h"
#include "Desktop.h"
2008-07-10 08:29:50 +00:00
#include "FontCache.h"
#include "FontCacheEntry.h"
#include "FontManager.h"
2008-08-03 13:40:41 +00:00
#include "GlobalSubpixelSettings.h"
#include "ServerConfig.h"
#include <DefaultColors.h>
#include <ServerReadOnlyMemory.h>
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
:
fShared(*shared)
{
// if the on-disk settings are not complete, the defaults will be kept
_SetDefaults();
_Load();
}
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::~DesktopSettingsPrivate()
{
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::_SetDefaults()
{
fPlainFont = *gFontManager->DefaultPlainFont();
fBoldFont = *gFontManager->DefaultBoldFont();
fFixedFont = *gFontManager->DefaultFixedFont();
fMouseMode = B_NORMAL_MOUSE;
fShowAllDraggers = true;
// init scrollbar info
fScrollBarInfo.proportional = true;
fScrollBarInfo.double_arrows = false;
fScrollBarInfo.knob = 1;
// look of the knob (R5: (0, 1, 2), 1 = default)
fScrollBarInfo.min_knob_size = 15;
// init menu info
strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
fMenuInfo.font_size = fPlainFont.Size();
fMenuInfo.background_color.set_to(216, 216, 216);
2008-07-10 08:29:50 +00:00
fMenuInfo.separator = 0;
// look of the separator (R5: (0, 1, 2), default 0)
fMenuInfo.click_to_open = true; // always true
fMenuInfo.triggers_always_shown = false;
fWorkspacesColumns = 2;
fWorkspacesRows = 2;
memcpy(fShared.colors, BPrivate::kDefaultColors,
sizeof(rgb_color) * kNumColors);
2008-07-10 08:29:50 +00:00
2008-08-03 13:40:41 +00:00
gSubpixelAntialiasing = false;
gDefaultHintingMode = HINTING_MODE_ON;
2008-08-03 13:40:41 +00:00
gSubpixelAverageWeight = 120;
gSubpixelOrderingRGB = true;
}
status_t
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::_GetPath(BPath& path)
{
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK)
return status;
status = path.Append("system/app_server");
if (status < B_OK)
return status;
return create_directory(path.Path(), 0755);
}
status_t
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::_Load()
{
// TODO: add support for old app_server_settings file as well
BPath basePath;
status_t status = _GetPath(basePath);
if (status < B_OK)
return status;
// read workspaces settings
BPath path(basePath);
path.Append("workspaces");
2008-07-10 08:29:50 +00:00
BFile file;
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
status = settings.Unflatten(&file);
if (status == B_OK) {
int32 columns;
int32 rows;
if (settings.FindInt32("columns", &columns) == B_OK
&& settings.FindInt32("rows", &rows) == B_OK) {
_ValidateWorkspacesLayout(columns, rows);
fWorkspacesColumns = columns;
fWorkspacesRows = rows;
}
int32 i = 0;
while (i < kMaxWorkspaces && settings.FindMessage("workspace",
i, &fWorkspaceMessages[i]) == B_OK) {
i++;
}
}
}
2006-04-01 22:03:44 +00:00
// read font settings
path = basePath;
path.Append("fonts");
2008-07-10 08:29:50 +00:00
2006-04-01 22:03:44 +00:00
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
status = settings.Unflatten(&file);
if (status == B_OK && gFontManager->Lock()) {
const char* family;
const char* style;
float size;
2009-07-29 11:21:59 +00:00
2006-04-01 22:03:44 +00:00
if (settings.FindString("plain family", &family) == B_OK
&& settings.FindString("plain style", &style) == B_OK
&& settings.FindFloat("plain size", &size) == B_OK) {
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
fPlainFont.SetStyle(fontStyle);
fPlainFont.SetSize(size);
}
2009-07-29 11:21:59 +00:00
2006-04-01 22:03:44 +00:00
if (settings.FindString("bold family", &family) == B_OK
&& settings.FindString("bold style", &style) == B_OK
&& settings.FindFloat("bold size", &size) == B_OK) {
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
fBoldFont.SetStyle(fontStyle);
fBoldFont.SetSize(size);
}
2009-07-29 11:21:59 +00:00
2006-04-01 22:03:44 +00:00
if (settings.FindString("fixed family", &family) == B_OK
&& settings.FindString("fixed style", &style) == B_OK
&& settings.FindFloat("fixed size", &size) == B_OK) {
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
if (fontStyle != NULL && fontStyle->IsFixedWidth())
2006-04-01 22:03:44 +00:00
fFixedFont.SetStyle(fontStyle);
fFixedFont.SetSize(size);
}
2009-07-29 11:21:59 +00:00
int32 hinting;
if (settings.FindInt32("hinting", &hinting) == B_OK)
gDefaultHintingMode = hinting;
2009-07-29 11:21:59 +00:00
2006-04-01 22:03:44 +00:00
gFontManager->Unlock();
}
}
// read mouse settings
path = basePath;
path.Append("mouse");
2008-07-10 08:29:50 +00:00
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
status = settings.Unflatten(&file);
if (status == B_OK) {
int32 mode;
if (settings.FindInt32("mode", &mode) == B_OK) {
fMouseMode = (mode_mouse)mode;
}
}
}
// read appearance settings
path = basePath;
path.Append("appearance");
2008-07-10 08:29:50 +00:00
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
status = settings.Unflatten(&file);
if (status == B_OK) {
float fontSize;
if (settings.FindFloat("font size", &fontSize) == B_OK)
fMenuInfo.font_size = fontSize;
2008-07-10 08:29:50 +00:00
const char* fontFamily;
if (settings.FindString("font family", &fontFamily) == B_OK)
strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
const char* fontStyle;
if (settings.FindString("font style", &fontStyle) == B_OK)
strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
rgb_color bgColor;
if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
fMenuInfo.background_color = bgColor;
int32 separator;
if (settings.FindInt32("separator", &separator) == B_OK)
fMenuInfo.separator = separator;
bool clickToOpen;
if (settings.FindBool("click to open", &clickToOpen) == B_OK)
fMenuInfo.click_to_open = clickToOpen;
bool triggersAlwaysShown;
2008-08-03 13:40:41 +00:00
if (settings.FindBool("triggers always shown", &triggersAlwaysShown)
== B_OK) {
fMenuInfo.triggers_always_shown = triggersAlwaysShown;
2008-08-03 13:40:41 +00:00
}
bool subpix;
if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK)
gSubpixelAntialiasing = subpix;
2008-08-03 13:40:41 +00:00
int8 averageWeight;
if (settings.FindInt8("subpixel average weight", &averageWeight)
== B_OK) {
gSubpixelAverageWeight = averageWeight;
}
2008-08-03 13:40:41 +00:00
bool subpixelOrdering;
if (settings.FindBool("subpixel ordering", &subpixelOrdering)
== B_OK) {
gSubpixelOrderingRGB = subpixelOrdering;
}
2008-03-08 11:36:10 +00:00
for (int32 i = 0; i < kNumColors; i++) {
2008-03-08 11:36:10 +00:00
char colorName[12];
snprintf(colorName, sizeof(colorName), "color%ld",
(int32)index_to_color_which(i));
settings.FindInt32(colorName, (int32*)&fShared.colors[i]);
}
}
}
// read dragger settings
path = basePath;
path.Append("dragger");
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
BMessage settings;
status = settings.Unflatten(&file);
if (status == B_OK) {
if (settings.FindBool("show", &fShowAllDraggers) != B_OK)
fShowAllDraggers = true;
}
}
2006-04-01 22:03:44 +00:00
return B_OK;
}
status_t
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::Save(uint32 mask)
{
BPath basePath;
status_t status = _GetPath(basePath);
if (status < B_OK)
return status;
if (mask & kWorkspacesSettings) {
BPath path(basePath);
if (path.Append("workspaces") == B_OK) {
BMessage settings('asws');
settings.AddInt32("columns", fWorkspacesColumns);
settings.AddInt32("rows", fWorkspacesRows);
for (int32 i = 0; i < kMaxWorkspaces; i++) {
settings.AddMessage("workspace", &fWorkspaceMessages[i]);
}
BFile file;
2008-08-03 13:40:41 +00:00
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
2006-04-01 22:03:44 +00:00
if (mask & kFontSettings) {
BPath path(basePath);
if (path.Append("fonts") == B_OK) {
BMessage settings('asfn');
settings.AddString("plain family", fPlainFont.Family());
settings.AddString("plain style", fPlainFont.Style());
settings.AddFloat("plain size", fPlainFont.Size());
settings.AddString("bold family", fBoldFont.Family());
settings.AddString("bold style", fBoldFont.Style());
settings.AddFloat("bold size", fBoldFont.Size());
settings.AddString("fixed family", fFixedFont.Family());
settings.AddString("fixed style", fFixedFont.Style());
settings.AddFloat("fixed size", fFixedFont.Size());
settings.AddInt32("hinting", gDefaultHintingMode);
2008-07-10 08:29:50 +00:00
2006-04-01 22:03:44 +00:00
BFile file;
2008-08-03 13:40:41 +00:00
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
2006-04-01 22:03:44 +00:00
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
if (mask & kMouseSettings) {
BPath path(basePath);
if (path.Append("mouse") == B_OK) {
BMessage settings('asms');
settings.AddInt32("mode", (int32)fMouseMode);
BFile file;
2008-08-03 13:40:41 +00:00
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
if (mask & kDraggerSettings) {
BPath path(basePath);
if (path.Append("dragger") == B_OK) {
BMessage settings('asdg');
settings.AddBool("show", fShowAllDraggers);
BFile file;
2008-08-03 13:40:41 +00:00
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
if (mask & kAppearanceSettings) {
BPath path(basePath);
if (path.Append("appearance") == B_OK) {
BMessage settings('aslk');
settings.AddFloat("font size", fMenuInfo.font_size);
settings.AddString("font family", fMenuInfo.f_family);
settings.AddString("font style", fMenuInfo.f_style);
2008-08-03 13:40:41 +00:00
settings.AddInt32("bg color",
(const int32&)fMenuInfo.background_color);
settings.AddInt32("separator", fMenuInfo.separator);
settings.AddBool("click to open", fMenuInfo.click_to_open);
2008-08-03 13:40:41 +00:00
settings.AddBool("triggers always shown",
fMenuInfo.triggers_always_shown);
settings.AddBool("subpixel antialiasing", gSubpixelAntialiasing);
settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
settings.AddBool("subpixel ordering", gSubpixelOrderingRGB);
for (int32 i = 0; i < kNumColors; i++) {
2008-03-08 11:36:10 +00:00
char colorName[12];
snprintf(colorName, sizeof(colorName), "color%ld",
(int32)index_to_color_which(i));
settings.AddInt32(colorName, (const int32&)fShared.colors[i]);
}
BFile file;
2008-08-03 13:40:41 +00:00
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
| B_READ_WRITE);
if (status == B_OK) {
status = settings.Flatten(&file, NULL);
}
}
}
return status;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
{
fPlainFont = font;
2006-04-01 22:03:44 +00:00
Save(kFontSettings);
}
const ServerFont &
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::DefaultPlainFont() const
{
return fPlainFont;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
{
fBoldFont = font;
2006-04-01 22:03:44 +00:00
Save(kFontSettings);
}
const ServerFont &
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::DefaultBoldFont() const
{
return fBoldFont;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
{
fFixedFont = font;
2006-04-01 22:03:44 +00:00
Save(kFontSettings);
}
const ServerFont &
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::DefaultFixedFont() const
{
return fFixedFont;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
{
fScrollBarInfo = info;
2006-04-01 22:03:44 +00:00
Save(kAppearanceSettings);
}
const scroll_bar_info&
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::ScrollBarInfo() const
{
return fScrollBarInfo;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
{
fMenuInfo = info;
// Also update the ui_color
SetUIColor(B_MENU_BACKGROUND_COLOR, info.background_color);
// SetUIColor already saves the settings
}
const menu_info&
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::MenuInfo() const
{
return fMenuInfo;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
{
fMouseMode = mode;
Save(kMouseSettings);
}
mode_mouse
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::MouseMode() const
{
return fMouseMode;
}
bool
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::FocusFollowsMouse() const
{
return MouseMode() != B_NORMAL_MOUSE;
}
void
DesktopSettingsPrivate::SetShowAllDraggers(bool show)
{
fShowAllDraggers = show;
Save(kDraggerSettings);
}
bool
DesktopSettingsPrivate::ShowAllDraggers() const
{
return fShowAllDraggers;
}
void
DesktopSettingsPrivate::SetWorkspacesLayout(int32 columns, int32 rows)
{
_ValidateWorkspacesLayout(columns, rows);
fWorkspacesColumns = columns;
fWorkspacesRows = rows;
Save(kWorkspacesSettings);
}
int32
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::WorkspacesCount() const
{
return fWorkspacesColumns * fWorkspacesRows;
}
int32
DesktopSettingsPrivate::WorkspacesColumns() const
{
return fWorkspacesColumns;
}
int32
DesktopSettingsPrivate::WorkspacesRows() const
{
return fWorkspacesRows;
}
void
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
{
if (index < 0 || index > kMaxWorkspaces)
return;
fWorkspaceMessages[index] = message;
}
const BMessage*
2006-08-26 15:13:08 +00:00
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
{
if (index < 0 || index > kMaxWorkspaces)
return NULL;
return &fWorkspaceMessages[index];
}
void
DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
{
//
int32 index = color_which_to_index(which);
if (index < 0 || index >= kNumColors)
return;
fShared.colors[index] = color;
// TODO: deprecate the background_color member of the menu_info struct,
// otherwise we have to keep this duplication...
if (which == B_MENU_BACKGROUND_COLOR)
fMenuInfo.background_color = color;
Save(kAppearanceSettings);
}
rgb_color
DesktopSettingsPrivate::UIColor(color_which which) const
{
static const rgb_color invalidColor = {0, 0, 0, 0};
int32 index = color_which_to_index(which);
if (index < 0 || index >= kNumColors)
return invalidColor;
return fShared.colors[index];
}
2008-07-10 08:29:50 +00:00
void
2008-08-03 13:40:41 +00:00
DesktopSettingsPrivate::SetSubpixelAntialiasing(bool subpix)
2008-07-10 08:29:50 +00:00
{
2008-08-03 13:40:41 +00:00
gSubpixelAntialiasing = subpix;
Save(kAppearanceSettings);
2008-07-10 08:29:50 +00:00
}
bool
2008-08-03 13:40:41 +00:00
DesktopSettingsPrivate::SubpixelAntialiasing() const
2008-07-10 08:29:50 +00:00
{
2008-08-03 13:40:41 +00:00
return gSubpixelAntialiasing;
2008-07-10 08:29:50 +00:00
}
void
DesktopSettingsPrivate::SetHinting(uint8 hinting)
2008-07-10 08:29:50 +00:00
{
gDefaultHintingMode = hinting;
2008-08-03 13:40:41 +00:00
Save(kFontSettings);
2008-07-10 08:29:50 +00:00
}
uint8
2008-07-10 08:29:50 +00:00
DesktopSettingsPrivate::Hinting() const
{
return gDefaultHintingMode;
2008-08-03 13:40:41 +00:00
}
void
DesktopSettingsPrivate::SetSubpixelAverageWeight(uint8 averageWeight)
{
gSubpixelAverageWeight = averageWeight;
Save(kAppearanceSettings);
}
uint8
DesktopSettingsPrivate::SubpixelAverageWeight() const
{
return gSubpixelAverageWeight;
}
void
DesktopSettingsPrivate::SetSubpixelOrderingRegular(bool subpixelOrdering)
{
gSubpixelOrderingRGB = subpixelOrdering;
Save(kAppearanceSettings);
}
bool
DesktopSettingsPrivate::IsSubpixelOrderingRegular() const
{
return gSubpixelOrderingRGB;
2008-07-10 08:29:50 +00:00
}
void
DesktopSettingsPrivate::_ValidateWorkspacesLayout(int32& columns,
int32& rows) const
{
if (columns < 1)
columns = 1;
if (rows < 1)
rows = 1;
if (columns * rows > kMaxWorkspaces) {
// Revert to defaults in case of invalid settings
columns = 2;
rows = 2;
}
}
2006-08-26 15:13:08 +00:00
// #pragma mark - read access
DesktopSettings::DesktopSettings(Desktop* desktop)
2006-08-26 15:13:08 +00:00
:
fSettings(desktop->fSettings)
{
#if DEBUG
if (!desktop->fWindowLock.IsWriteLocked()
&& !desktop->fWindowLock.IsReadLocked())
2006-08-26 15:13:08 +00:00
debugger("desktop not locked when trying to access settings");
#endif
}
2006-08-26 15:13:08 +00:00
void
DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
{
2006-08-26 15:13:08 +00:00
font = fSettings->DefaultPlainFont();
}
void
2006-08-26 15:13:08 +00:00
DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
{
2006-08-26 15:13:08 +00:00
font = fSettings->DefaultBoldFont();
}
void
2006-08-26 15:13:08 +00:00
DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
{
2006-08-26 15:13:08 +00:00
font = fSettings->DefaultFixedFont();
}
void
2006-08-26 15:13:08 +00:00
DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
{
2006-08-26 15:13:08 +00:00
info = fSettings->ScrollBarInfo();
}
void
2006-08-26 15:13:08 +00:00
DesktopSettings::GetMenuInfo(menu_info& info) const
{
2006-08-26 15:13:08 +00:00
info = fSettings->MenuInfo();
}
2006-08-26 15:13:08 +00:00
mode_mouse
DesktopSettings::MouseMode() const
{
2006-08-26 15:13:08 +00:00
return fSettings->MouseMode();
}
2006-08-26 15:13:08 +00:00
bool
DesktopSettings::FocusFollowsMouse() const
{
2006-08-26 15:13:08 +00:00
return fSettings->FocusFollowsMouse();
}
bool
DesktopSettings::ShowAllDraggers() const
{
return fSettings->ShowAllDraggers();
}
2006-08-26 15:13:08 +00:00
int32
DesktopSettings::WorkspacesCount() const
{
2006-08-26 15:13:08 +00:00
return fSettings->WorkspacesCount();
}
int32
DesktopSettings::WorkspacesColumns() const
{
return fSettings->WorkspacesColumns();
}
int32
DesktopSettings::WorkspacesRows() const
{
return fSettings->WorkspacesRows();
}
2006-08-26 15:13:08 +00:00
const BMessage*
DesktopSettings::WorkspacesMessage(int32 index) const
{
2006-08-26 15:13:08 +00:00
return fSettings->WorkspacesMessage(index);
}
rgb_color
DesktopSettings::UIColor(color_which which) const
{
return fSettings->UIColor(which);
}
2008-07-10 08:29:50 +00:00
bool
2008-08-03 13:40:41 +00:00
DesktopSettings::SubpixelAntialiasing() const
2008-07-10 08:29:50 +00:00
{
2008-08-03 13:40:41 +00:00
return fSettings->SubpixelAntialiasing();
2008-07-10 08:29:50 +00:00
}
uint8
2008-07-10 08:29:50 +00:00
DesktopSettings::Hinting() const
{
return fSettings->Hinting();
}
2008-08-03 13:40:41 +00:00
uint8
DesktopSettings::SubpixelAverageWeight() const
{
return fSettings->SubpixelAverageWeight();
}
bool
DesktopSettings::IsSubpixelOrderingRegular() const
{
// True corresponds to RGB, false means BGR
return fSettings->IsSubpixelOrderingRegular();
}
2006-08-26 15:13:08 +00:00
// #pragma mark - write access
2006-08-26 15:13:08 +00:00
LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
: DesktopSettings(desktop),
2006-08-26 15:13:08 +00:00
fDesktop(desktop)
{
#if DEBUG
2006-08-26 15:13:08 +00:00
if (desktop->fWindowLock.IsReadLocked())
debugger("desktop read locked when trying to change settings");
#endif
fDesktop->LockAllWindows();
}
2006-08-26 15:13:08 +00:00
LockedDesktopSettings::~LockedDesktopSettings()
{
2006-08-26 15:13:08 +00:00
fDesktop->UnlockAllWindows();
}
2006-08-26 15:13:08 +00:00
void
LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
{
2006-08-26 15:13:08 +00:00
fSettings->SetDefaultPlainFont(font);
}
2006-08-26 15:13:08 +00:00
void
LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
{
2006-08-26 15:13:08 +00:00
fSettings->SetDefaultBoldFont(font);
fDesktop->BroadcastToAllWindows(AS_SYSTEM_FONT_CHANGED);
}
void
2006-08-26 15:13:08 +00:00
LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
{
2006-08-26 15:13:08 +00:00
fSettings->SetDefaultFixedFont(font);
}
2006-08-26 15:13:08 +00:00
void
LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
{
2006-08-26 15:13:08 +00:00
fSettings->SetScrollBarInfo(info);
}
void
2006-08-26 15:13:08 +00:00
LockedDesktopSettings::SetMenuInfo(const menu_info& info)
{
2006-08-26 15:13:08 +00:00
fSettings->SetMenuInfo(info);
}
2006-08-26 15:13:08 +00:00
void
LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
{
2006-08-26 15:13:08 +00:00
fSettings->SetMouseMode(mode);
}
2006-08-26 15:13:08 +00:00
void
LockedDesktopSettings::SetShowAllDraggers(bool show)
{
fSettings->SetShowAllDraggers(show);
}
void
LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
{
fSettings->SetUIColor(which, color);
}
2008-07-10 08:29:50 +00:00
void
2008-08-03 13:40:41 +00:00
LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
2008-07-10 08:29:50 +00:00
{
2008-08-03 13:40:41 +00:00
fSettings->SetSubpixelAntialiasing(subpix);
2008-07-10 08:29:50 +00:00
}
void
LockedDesktopSettings::SetHinting(uint8 hinting)
2008-07-10 08:29:50 +00:00
{
fSettings->SetHinting(hinting);
}
2008-08-03 13:40:41 +00:00
void
LockedDesktopSettings::SetSubpixelAverageWeight(uint8 averageWeight)
{
fSettings->SetSubpixelAverageWeight(averageWeight);
}
void
LockedDesktopSettings::SetSubpixelOrderingRegular(bool subpixelOrdering)
{
fSettings->SetSubpixelOrderingRegular(subpixelOrdering);
}