usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / servers / app / DesktopSettings.cpp
blobae261b9a88510949aec61c9efb7528594b37cfa1
1 /*
2 * Copyright 2005-2015, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 * Axel Dörfler, axeld@pinc-software.de
8 * Andrej Spielmann, <andrej.spielmann@seh.ox.ac.uk>
9 * Joseph Groover <looncraz@looncraz.net>
13 #include "DesktopSettings.h"
14 #include "DesktopSettingsPrivate.h"
16 #include <Directory.h>
17 #include <File.h>
18 #include <FindDirectory.h>
19 #include <Path.h>
21 #include <DefaultColors.h>
22 #include <InterfaceDefs.h>
23 #include <ServerReadOnlyMemory.h>
25 #include "Desktop.h"
26 #include "FontCache.h"
27 #include "FontCacheEntry.h"
28 #include "FontManager.h"
29 #include "GlobalSubpixelSettings.h"
30 #include "ServerConfig.h"
33 DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
35 fShared(*shared)
37 // if the on-disk settings are not complete, the defaults will be kept
38 _SetDefaults();
39 _Load();
43 DesktopSettingsPrivate::~DesktopSettingsPrivate()
48 void
49 DesktopSettingsPrivate::_SetDefaults()
51 fPlainFont = *gFontManager->DefaultPlainFont();
52 fBoldFont = *gFontManager->DefaultBoldFont();
53 fFixedFont = *gFontManager->DefaultFixedFont();
55 fMouseMode = B_NORMAL_MOUSE;
56 fFocusFollowsMouseMode = B_NORMAL_FOCUS_FOLLOWS_MOUSE;
57 fAcceptFirstClick = false;
58 fShowAllDraggers = true;
60 // init scrollbar info
61 fScrollBarInfo.proportional = true;
62 fScrollBarInfo.double_arrows = false;
63 fScrollBarInfo.knob = 1;
64 // look of the knob (R5: (0, 1, 2), 1 = default)
65 fScrollBarInfo.min_knob_size = 15;
67 // init menu info
68 strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
69 strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
70 fMenuInfo.font_size = fPlainFont.Size();
71 fMenuInfo.background_color.set_to(216, 216, 216);
73 fMenuInfo.separator = 0;
74 // look of the separator (R5: (0, 1, 2), default 0)
75 fMenuInfo.click_to_open = true; // always true
76 fMenuInfo.triggers_always_shown = false;
78 fWorkspacesColumns = 2;
79 fWorkspacesRows = 2;
81 memcpy(fShared.colors, BPrivate::kDefaultColors,
82 sizeof(rgb_color) * kColorWhichCount);
84 gSubpixelAntialiasing = false;
85 gDefaultHintingMode = HINTING_MODE_ON;
86 gSubpixelAverageWeight = 120;
87 gSubpixelOrderingRGB = true;
91 status_t
92 DesktopSettingsPrivate::_GetPath(BPath& path)
94 status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
95 if (status < B_OK)
96 return status;
98 status = path.Append("system/app_server");
99 if (status < B_OK)
100 return status;
102 return create_directory(path.Path(), 0755);
106 status_t
107 DesktopSettingsPrivate::_Load()
109 // TODO: add support for old app_server_settings file as well
111 BPath basePath;
112 status_t status = _GetPath(basePath);
113 if (status < B_OK)
114 return status;
116 // read workspaces settings
118 BPath path(basePath);
119 path.Append("workspaces");
121 BFile file;
122 status = file.SetTo(path.Path(), B_READ_ONLY);
123 if (status == B_OK) {
124 BMessage settings;
125 status = settings.Unflatten(&file);
126 if (status == B_OK) {
127 int32 columns;
128 int32 rows;
129 if (settings.FindInt32("columns", &columns) == B_OK
130 && settings.FindInt32("rows", &rows) == B_OK) {
131 _ValidateWorkspacesLayout(columns, rows);
132 fWorkspacesColumns = columns;
133 fWorkspacesRows = rows;
136 int32 i = 0;
137 while (i < kMaxWorkspaces && settings.FindMessage("workspace",
138 i, &fWorkspaceMessages[i]) == B_OK) {
139 i++;
144 // read font settings
146 path = basePath;
147 path.Append("fonts");
149 status = file.SetTo(path.Path(), B_READ_ONLY);
150 if (status == B_OK) {
151 BMessage settings;
152 status = settings.Unflatten(&file);
153 if (status == B_OK && gFontManager->Lock()) {
154 const char* family;
155 const char* style;
156 float size;
158 if (settings.FindString("plain family", &family) == B_OK
159 && settings.FindString("plain style", &style) == B_OK
160 && settings.FindFloat("plain size", &size) == B_OK) {
161 FontStyle* fontStyle = gFontManager->GetStyle(family, style);
162 fPlainFont.SetStyle(fontStyle);
163 fPlainFont.SetSize(size);
166 if (settings.FindString("bold family", &family) == B_OK
167 && settings.FindString("bold style", &style) == B_OK
168 && settings.FindFloat("bold size", &size) == B_OK) {
169 FontStyle* fontStyle = gFontManager->GetStyle(family, style);
170 fBoldFont.SetStyle(fontStyle);
171 fBoldFont.SetSize(size);
174 if (settings.FindString("fixed family", &family) == B_OK
175 && settings.FindString("fixed style", &style) == B_OK
176 && settings.FindFloat("fixed size", &size) == B_OK) {
177 FontStyle* fontStyle = gFontManager->GetStyle(family, style);
178 if (fontStyle != NULL && fontStyle->IsFixedWidth())
179 fFixedFont.SetStyle(fontStyle);
180 fFixedFont.SetSize(size);
183 int32 hinting;
184 if (settings.FindInt32("hinting", &hinting) == B_OK)
185 gDefaultHintingMode = hinting;
187 gFontManager->Unlock();
191 // read mouse settings
193 path = basePath;
194 path.Append("mouse");
196 status = file.SetTo(path.Path(), B_READ_ONLY);
197 if (status == B_OK) {
198 BMessage settings;
199 status = settings.Unflatten(&file);
200 if (status == B_OK) {
201 int32 mode;
202 if (settings.FindInt32("mode", &mode) == B_OK)
203 fMouseMode = (mode_mouse)mode;
205 int32 focusFollowsMouseMode;
206 if (settings.FindInt32("focus follows mouse mode",
207 &focusFollowsMouseMode) == B_OK) {
208 fFocusFollowsMouseMode
209 = (mode_focus_follows_mouse)focusFollowsMouseMode;
212 bool acceptFirstClick;
213 if (settings.FindBool("accept first click", &acceptFirstClick)
214 == B_OK) {
215 fAcceptFirstClick = acceptFirstClick;
220 // read appearance settings
222 path = basePath;
223 path.Append("appearance");
225 status = file.SetTo(path.Path(), B_READ_ONLY);
226 if (status == B_OK) {
227 BMessage settings;
228 status = settings.Unflatten(&file);
229 if (status == B_OK) {
230 // menus
231 float fontSize;
232 if (settings.FindFloat("font size", &fontSize) == B_OK)
233 fMenuInfo.font_size = fontSize;
235 const char* fontFamily;
236 if (settings.FindString("font family", &fontFamily) == B_OK)
237 strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
239 const char* fontStyle;
240 if (settings.FindString("font style", &fontStyle) == B_OK)
241 strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
243 rgb_color bgColor;
244 if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
245 fMenuInfo.background_color = bgColor;
247 int32 separator;
248 if (settings.FindInt32("separator", &separator) == B_OK)
249 fMenuInfo.separator = separator;
251 bool clickToOpen;
252 if (settings.FindBool("click to open", &clickToOpen) == B_OK)
253 fMenuInfo.click_to_open = clickToOpen;
255 bool triggersAlwaysShown;
256 if (settings.FindBool("triggers always shown", &triggersAlwaysShown)
257 == B_OK) {
258 fMenuInfo.triggers_always_shown = triggersAlwaysShown;
261 // scrollbars
262 bool proportional;
263 if (settings.FindBool("proportional", &proportional) == B_OK)
264 fScrollBarInfo.proportional = proportional;
266 bool doubleArrows;
267 if (settings.FindBool("double arrows", &doubleArrows) == B_OK)
268 fScrollBarInfo.double_arrows = doubleArrows;
270 int32 knob;
271 if (settings.FindInt32("knob", &knob) == B_OK)
272 fScrollBarInfo.knob = knob;
274 int32 minKnobSize;
275 if (settings.FindInt32("min knob size", &minKnobSize) == B_OK)
276 fScrollBarInfo.min_knob_size = minKnobSize;
278 // subpixel font rendering
279 bool subpix;
280 if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK)
281 gSubpixelAntialiasing = subpix;
283 int8 averageWeight;
284 if (settings.FindInt8("subpixel average weight", &averageWeight)
285 == B_OK) {
286 gSubpixelAverageWeight = averageWeight;
289 bool subpixelOrdering;
290 if (settings.FindBool("subpixel ordering", &subpixelOrdering)
291 == B_OK) {
292 gSubpixelOrderingRGB = subpixelOrdering;
295 // colors
296 for (int32 i = 0; i < kColorWhichCount; i++) {
297 char colorName[12];
298 snprintf(colorName, sizeof(colorName), "color%" B_PRId32,
299 (int32)index_to_color_which(i));
301 if (settings.FindInt32(colorName, (int32*)&fShared.colors[i]) != B_OK) {
302 // Set obviously bad value so the Appearance app can detect it
303 fShared.colors[i] = B_TRANSPARENT_COLOR;
309 // read dragger settings
311 path = basePath;
312 path.Append("dragger");
314 status = file.SetTo(path.Path(), B_READ_ONLY);
315 if (status == B_OK) {
316 BMessage settings;
317 status = settings.Unflatten(&file);
318 if (status == B_OK) {
319 if (settings.FindBool("show", &fShowAllDraggers) != B_OK)
320 fShowAllDraggers = true;
324 return B_OK;
328 status_t
329 DesktopSettingsPrivate::Save(uint32 mask)
331 #if TEST_MODE
332 return B_OK;
333 #endif
335 BPath basePath;
336 status_t status = _GetPath(basePath);
337 if (status != B_OK)
338 return status;
340 if (mask & kWorkspacesSettings) {
341 BPath path(basePath);
342 if (path.Append("workspaces") == B_OK) {
343 BMessage settings('asws');
344 settings.AddInt32("columns", fWorkspacesColumns);
345 settings.AddInt32("rows", fWorkspacesRows);
347 for (int32 i = 0; i < kMaxWorkspaces; i++) {
348 settings.AddMessage("workspace", &fWorkspaceMessages[i]);
351 BFile file;
352 status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
353 | B_READ_WRITE);
354 if (status == B_OK) {
355 status = settings.Flatten(&file, NULL);
360 if (mask & kFontSettings) {
361 BPath path(basePath);
362 if (path.Append("fonts") == B_OK) {
363 BMessage settings('asfn');
365 settings.AddString("plain family", fPlainFont.Family());
366 settings.AddString("plain style", fPlainFont.Style());
367 settings.AddFloat("plain size", fPlainFont.Size());
369 settings.AddString("bold family", fBoldFont.Family());
370 settings.AddString("bold style", fBoldFont.Style());
371 settings.AddFloat("bold size", fBoldFont.Size());
373 settings.AddString("fixed family", fFixedFont.Family());
374 settings.AddString("fixed style", fFixedFont.Style());
375 settings.AddFloat("fixed size", fFixedFont.Size());
377 settings.AddInt32("hinting", gDefaultHintingMode);
379 BFile file;
380 status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
381 | B_READ_WRITE);
382 if (status == B_OK) {
383 status = settings.Flatten(&file, NULL);
388 if (mask & kMouseSettings) {
389 BPath path(basePath);
390 if (path.Append("mouse") == B_OK) {
391 BMessage settings('asms');
392 settings.AddInt32("mode", (int32)fMouseMode);
393 settings.AddInt32("focus follows mouse mode",
394 (int32)fFocusFollowsMouseMode);
395 settings.AddBool("accept first click", fAcceptFirstClick);
397 BFile file;
398 status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
399 | B_READ_WRITE);
400 if (status == B_OK) {
401 status = settings.Flatten(&file, NULL);
406 if (mask & kDraggerSettings) {
407 BPath path(basePath);
408 if (path.Append("dragger") == B_OK) {
409 BMessage settings('asdg');
410 settings.AddBool("show", fShowAllDraggers);
412 BFile file;
413 status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
414 | B_READ_WRITE);
415 if (status == B_OK) {
416 status = settings.Flatten(&file, NULL);
421 if (mask & kAppearanceSettings) {
422 BPath path(basePath);
423 if (path.Append("appearance") == B_OK) {
424 BMessage settings('aslk');
425 settings.AddFloat("font size", fMenuInfo.font_size);
426 settings.AddString("font family", fMenuInfo.f_family);
427 settings.AddString("font style", fMenuInfo.f_style);
428 settings.AddInt32("bg color",
429 (const int32&)fMenuInfo.background_color);
430 settings.AddInt32("separator", fMenuInfo.separator);
431 settings.AddBool("click to open", fMenuInfo.click_to_open);
432 settings.AddBool("triggers always shown",
433 fMenuInfo.triggers_always_shown);
435 settings.AddBool("proportional", fScrollBarInfo.proportional);
436 settings.AddBool("double arrows", fScrollBarInfo.double_arrows);
437 settings.AddInt32("knob", fScrollBarInfo.knob);
438 settings.AddInt32("min knob size", fScrollBarInfo.min_knob_size);
440 settings.AddBool("subpixel antialiasing", gSubpixelAntialiasing);
441 settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
442 settings.AddBool("subpixel ordering", gSubpixelOrderingRGB);
444 for (int32 i = 0; i < kColorWhichCount; i++) {
445 char colorName[12];
446 snprintf(colorName, sizeof(colorName), "color%" B_PRId32,
447 (int32)index_to_color_which(i));
448 settings.AddInt32(colorName, (const int32&)fShared.colors[i]);
451 BFile file;
452 status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
453 | B_READ_WRITE);
454 if (status == B_OK) {
455 status = settings.Flatten(&file, NULL);
460 return status;
464 void
465 DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
467 fPlainFont = font;
468 Save(kFontSettings);
472 const ServerFont &
473 DesktopSettingsPrivate::DefaultPlainFont() const
475 return fPlainFont;
479 void
480 DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
482 fBoldFont = font;
483 Save(kFontSettings);
487 const ServerFont &
488 DesktopSettingsPrivate::DefaultBoldFont() const
490 return fBoldFont;
494 void
495 DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
497 fFixedFont = font;
498 Save(kFontSettings);
502 const ServerFont &
503 DesktopSettingsPrivate::DefaultFixedFont() const
505 return fFixedFont;
509 void
510 DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
512 fScrollBarInfo = info;
513 Save(kAppearanceSettings);
517 const scroll_bar_info&
518 DesktopSettingsPrivate::ScrollBarInfo() const
520 return fScrollBarInfo;
524 void
525 DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
527 fMenuInfo = info;
528 // Also update the ui_color
529 SetUIColor(B_MENU_BACKGROUND_COLOR, info.background_color);
530 // SetUIColor already saves the settings
534 const menu_info&
535 DesktopSettingsPrivate::MenuInfo() const
537 return fMenuInfo;
541 void
542 DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
544 fMouseMode = mode;
545 Save(kMouseSettings);
549 void
550 DesktopSettingsPrivate::SetFocusFollowsMouseMode(mode_focus_follows_mouse mode)
552 fFocusFollowsMouseMode = mode;
553 Save(kMouseSettings);
557 mode_mouse
558 DesktopSettingsPrivate::MouseMode() const
560 return fMouseMode;
564 mode_focus_follows_mouse
565 DesktopSettingsPrivate::FocusFollowsMouseMode() const
567 return fFocusFollowsMouseMode;
571 void
572 DesktopSettingsPrivate::SetAcceptFirstClick(const bool acceptFirstClick)
574 fAcceptFirstClick = acceptFirstClick;
575 Save(kMouseSettings);
579 bool
580 DesktopSettingsPrivate::AcceptFirstClick() const
582 return fAcceptFirstClick;
586 void
587 DesktopSettingsPrivate::SetShowAllDraggers(bool show)
589 fShowAllDraggers = show;
590 Save(kDraggerSettings);
594 bool
595 DesktopSettingsPrivate::ShowAllDraggers() const
597 return fShowAllDraggers;
601 void
602 DesktopSettingsPrivate::SetWorkspacesLayout(int32 columns, int32 rows)
604 _ValidateWorkspacesLayout(columns, rows);
605 fWorkspacesColumns = columns;
606 fWorkspacesRows = rows;
608 Save(kWorkspacesSettings);
612 int32
613 DesktopSettingsPrivate::WorkspacesCount() const
615 return fWorkspacesColumns * fWorkspacesRows;
619 int32
620 DesktopSettingsPrivate::WorkspacesColumns() const
622 return fWorkspacesColumns;
626 int32
627 DesktopSettingsPrivate::WorkspacesRows() const
629 return fWorkspacesRows;
633 void
634 DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
636 if (index < 0 || index >= kMaxWorkspaces)
637 return;
639 fWorkspaceMessages[index] = message;
643 const BMessage*
644 DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
646 if (index < 0 || index >= kMaxWorkspaces)
647 return NULL;
649 return &fWorkspaceMessages[index];
653 void
654 DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color,
655 bool* changed)
657 int32 index = color_which_to_index(which);
658 if (index < 0 || index >= kColorWhichCount)
659 return;
661 if (changed != NULL)
662 *changed = fShared.colors[index] != color;
664 fShared.colors[index] = color;
665 // TODO: deprecate the background_color member of the menu_info struct,
666 // otherwise we have to keep this duplication...
667 if (which == B_MENU_BACKGROUND_COLOR)
668 fMenuInfo.background_color = color;
670 Save(kAppearanceSettings);
674 void
675 DesktopSettingsPrivate::SetUIColors(const BMessage& colors, bool* changed)
677 int32 count = colors.CountNames(B_RGB_32_BIT_TYPE);
678 if (count <= 0)
679 return;
681 int32 index = 0;
682 int32 colorIndex = 0;
683 char* name = NULL;
684 type_code type;
685 rgb_color color;
686 color_which which = B_NO_COLOR;
688 while (colors.GetInfo(B_RGB_32_BIT_TYPE, index, &name, &type) == B_OK) {
689 which = which_ui_color(name);
690 colorIndex = color_which_to_index(which);
691 if (colorIndex < 0 || colorIndex >= kColorWhichCount
692 || colors.FindColor(name, &color) != B_OK) {
693 if (changed != NULL)
694 changed[index] = false;
696 ++index;
697 continue;
700 if (changed != NULL)
701 changed[index] = fShared.colors[colorIndex] != color;
703 fShared.colors[colorIndex] = color;
705 if (which == (int32)B_MENU_BACKGROUND_COLOR)
706 fMenuInfo.background_color = color;
708 ++index;
711 Save(kAppearanceSettings);
715 rgb_color
716 DesktopSettingsPrivate::UIColor(color_which which) const
718 static const rgb_color invalidColor = {0, 0, 0, 0};
719 int32 index = color_which_to_index(which);
720 if (index < 0 || index >= kColorWhichCount)
721 return invalidColor;
723 return fShared.colors[index];
727 void
728 DesktopSettingsPrivate::SetSubpixelAntialiasing(bool subpix)
730 gSubpixelAntialiasing = subpix;
731 Save(kAppearanceSettings);
735 bool
736 DesktopSettingsPrivate::SubpixelAntialiasing() const
738 return gSubpixelAntialiasing;
742 void
743 DesktopSettingsPrivate::SetHinting(uint8 hinting)
745 gDefaultHintingMode = hinting;
746 Save(kFontSettings);
750 uint8
751 DesktopSettingsPrivate::Hinting() const
753 return gDefaultHintingMode;
757 void
758 DesktopSettingsPrivate::SetSubpixelAverageWeight(uint8 averageWeight)
760 gSubpixelAverageWeight = averageWeight;
761 Save(kAppearanceSettings);
765 uint8
766 DesktopSettingsPrivate::SubpixelAverageWeight() const
768 return gSubpixelAverageWeight;
772 void
773 DesktopSettingsPrivate::SetSubpixelOrderingRegular(bool subpixelOrdering)
775 gSubpixelOrderingRGB = subpixelOrdering;
776 Save(kAppearanceSettings);
780 bool
781 DesktopSettingsPrivate::IsSubpixelOrderingRegular() const
783 return gSubpixelOrderingRGB;
787 void
788 DesktopSettingsPrivate::_ValidateWorkspacesLayout(int32& columns,
789 int32& rows) const
791 if (columns < 1)
792 columns = 1;
793 if (rows < 1)
794 rows = 1;
796 if (columns * rows > kMaxWorkspaces) {
797 // Revert to defaults in case of invalid settings
798 columns = 2;
799 rows = 2;
804 // #pragma mark - read access
807 DesktopSettings::DesktopSettings(Desktop* desktop)
809 fSettings(desktop->fSettings)
815 void
816 DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
818 font = fSettings->DefaultPlainFont();
822 void
823 DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
825 font = fSettings->DefaultBoldFont();
829 void
830 DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
832 font = fSettings->DefaultFixedFont();
836 void
837 DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
839 info = fSettings->ScrollBarInfo();
843 void
844 DesktopSettings::GetMenuInfo(menu_info& info) const
846 info = fSettings->MenuInfo();
850 mode_mouse
851 DesktopSettings::MouseMode() const
853 return fSettings->MouseMode();
857 mode_focus_follows_mouse
858 DesktopSettings::FocusFollowsMouseMode() const
860 return fSettings->FocusFollowsMouseMode();
864 bool
865 DesktopSettings::AcceptFirstClick() const
867 return fSettings->AcceptFirstClick();
871 bool
872 DesktopSettings::ShowAllDraggers() const
874 return fSettings->ShowAllDraggers();
878 int32
879 DesktopSettings::WorkspacesCount() const
881 return fSettings->WorkspacesCount();
885 int32
886 DesktopSettings::WorkspacesColumns() const
888 return fSettings->WorkspacesColumns();
892 int32
893 DesktopSettings::WorkspacesRows() const
895 return fSettings->WorkspacesRows();
899 const BMessage*
900 DesktopSettings::WorkspacesMessage(int32 index) const
902 return fSettings->WorkspacesMessage(index);
906 rgb_color
907 DesktopSettings::UIColor(color_which which) const
909 return fSettings->UIColor(which);
913 bool
914 DesktopSettings::SubpixelAntialiasing() const
916 return fSettings->SubpixelAntialiasing();
920 uint8
921 DesktopSettings::Hinting() const
923 return fSettings->Hinting();
927 uint8
928 DesktopSettings::SubpixelAverageWeight() const
930 return fSettings->SubpixelAverageWeight();
934 bool
935 DesktopSettings::IsSubpixelOrderingRegular() const
937 // True corresponds to RGB, false means BGR
938 return fSettings->IsSubpixelOrderingRegular();
941 // #pragma mark - write access
944 LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
946 DesktopSettings(desktop),
947 fDesktop(desktop)
949 #if DEBUG
950 if (desktop->fWindowLock.IsReadLocked())
951 debugger("desktop read locked when trying to change settings");
952 #endif
954 fDesktop->LockAllWindows();
958 LockedDesktopSettings::~LockedDesktopSettings()
960 fDesktop->UnlockAllWindows();
964 void
965 LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
967 fSettings->SetDefaultPlainFont(font);
971 void
972 LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
974 fSettings->SetDefaultBoldFont(font);
975 fDesktop->BroadcastToAllWindows(AS_SYSTEM_FONT_CHANGED);
979 void
980 LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
982 fSettings->SetDefaultFixedFont(font);
986 void
987 LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
989 fSettings->SetScrollBarInfo(info);
993 void
994 LockedDesktopSettings::SetMenuInfo(const menu_info& info)
996 fSettings->SetMenuInfo(info);
1000 void
1001 LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
1003 fSettings->SetMouseMode(mode);
1007 void
1008 LockedDesktopSettings::SetFocusFollowsMouseMode(mode_focus_follows_mouse mode)
1010 fSettings->SetFocusFollowsMouseMode(mode);
1014 void
1015 LockedDesktopSettings::SetAcceptFirstClick(const bool acceptFirstClick)
1017 fSettings->SetAcceptFirstClick(acceptFirstClick);
1021 void
1022 LockedDesktopSettings::SetShowAllDraggers(bool show)
1024 fSettings->SetShowAllDraggers(show);
1028 void
1029 LockedDesktopSettings::SetUIColors(const BMessage& colors, bool* changed)
1031 fSettings->SetUIColors(colors, &changed[0]);
1035 void
1036 LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
1038 fSettings->SetSubpixelAntialiasing(subpix);
1042 void
1043 LockedDesktopSettings::SetHinting(uint8 hinting)
1045 fSettings->SetHinting(hinting);
1049 void
1050 LockedDesktopSettings::SetSubpixelAverageWeight(uint8 averageWeight)
1052 fSettings->SetSubpixelAverageWeight(averageWeight);
1055 void
1056 LockedDesktopSettings::SetSubpixelOrderingRegular(bool subpixelOrdering)
1058 fSettings->SetSubpixelOrderingRegular(subpixelOrdering);