xref: /haiku/src/servers/app/DesktopSettings.cpp (revision b6b0567fbd186f8ce8a0c90bdc7a7b5b4c649678)
1 /*
2  * Copyright 2005-2008, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
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  */
10 
11 
12 #include "DesktopSettings.h"
13 #include "DesktopSettingsPrivate.h"
14 #include "Desktop.h"
15 #include "FontCache.h"
16 #include "FontCacheEntry.h"
17 #include "FontManager.h"
18 #include "GlobalSubpixelSettings.h"
19 #include "ServerConfig.h"
20 
21 #include <DefaultColors.h>
22 #include <ServerReadOnlyMemory.h>
23 
24 #include <Directory.h>
25 #include <File.h>
26 #include <FindDirectory.h>
27 #include <Path.h>
28 
29 
30 DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
31 	:
32 	fShared(*shared)
33 {
34 	// if the on-disk settings are not complete, the defaults will be kept
35 	_SetDefaults();
36 	_Load();
37 }
38 
39 
40 DesktopSettingsPrivate::~DesktopSettingsPrivate()
41 {
42 }
43 
44 
45 void
46 DesktopSettingsPrivate::_SetDefaults()
47 {
48 	fPlainFont = *gFontManager->DefaultPlainFont();
49 	fBoldFont = *gFontManager->DefaultBoldFont();
50 	fFixedFont = *gFontManager->DefaultFixedFont();
51 
52 	fMouseMode = B_NORMAL_MOUSE;
53 	fShowAllDraggers = true;
54 
55 	// init scrollbar info
56 	fScrollBarInfo.proportional = true;
57 	fScrollBarInfo.double_arrows = false;
58 	fScrollBarInfo.knob = 1;
59 		// look of the knob (R5: (0, 1, 2), 1 = default)
60 	fScrollBarInfo.min_knob_size = 15;
61 
62 	// init menu info
63 	strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
64 	strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
65 	fMenuInfo.font_size = fPlainFont.Size();
66 	fMenuInfo.background_color.set_to(216, 216, 216);
67 
68 	fMenuInfo.separator = 0;
69 		// look of the separator (R5: (0, 1, 2), default 0)
70 	fMenuInfo.click_to_open = true; // always true
71 	fMenuInfo.triggers_always_shown = false;
72 
73 	fWorkspacesColumns = 2;
74 	fWorkspacesRows = 2;
75 
76 	memcpy(fShared.colors, BPrivate::kDefaultColors,
77 		sizeof(rgb_color) * kNumColors);
78 
79 	gSubpixelAntialiasing = false;
80 	gDefaultHintingMode = HINTING_MODE_ON;
81 	gSubpixelAverageWeight = 120;
82 	gSubpixelOrderingRGB = true;
83 }
84 
85 
86 status_t
87 DesktopSettingsPrivate::_GetPath(BPath& path)
88 {
89 	status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
90 	if (status < B_OK)
91 		return status;
92 
93 	status = path.Append("system/app_server");
94 	if (status < B_OK)
95 		return status;
96 
97 	return create_directory(path.Path(), 0755);
98 }
99 
100 
101 status_t
102 DesktopSettingsPrivate::_Load()
103 {
104 	// TODO: add support for old app_server_settings file as well
105 
106 	BPath basePath;
107 	status_t status = _GetPath(basePath);
108 	if (status < B_OK)
109 		return status;
110 
111 	// read workspaces settings
112 
113 	BPath path(basePath);
114 	path.Append("workspaces");
115 
116 	BFile file;
117 	status = file.SetTo(path.Path(), B_READ_ONLY);
118 	if (status == B_OK) {
119 		BMessage settings;
120 		status = settings.Unflatten(&file);
121 		if (status == B_OK) {
122 			int32 columns;
123 			int32 rows;
124 			if (settings.FindInt32("columns", &columns) == B_OK
125 				&& settings.FindInt32("rows", &rows) == B_OK) {
126 				_ValidateWorkspacesLayout(columns, rows);
127 				fWorkspacesColumns = columns;
128 				fWorkspacesRows = rows;
129 			}
130 
131 			int32 i = 0;
132 			while (i < kMaxWorkspaces && settings.FindMessage("workspace",
133 					i, &fWorkspaceMessages[i]) == B_OK) {
134 				i++;
135 			}
136 		}
137 	}
138 
139 	// read font settings
140 
141 	path = basePath;
142 	path.Append("fonts");
143 
144 	status = file.SetTo(path.Path(), B_READ_ONLY);
145 	if (status == B_OK) {
146 		BMessage settings;
147 		status = settings.Unflatten(&file);
148 		if (status == B_OK && gFontManager->Lock()) {
149 			const char* family;
150 			const char* style;
151 			float size;
152 
153 			if (settings.FindString("plain family", &family) == B_OK
154 				&& settings.FindString("plain style", &style) == B_OK
155 				&& settings.FindFloat("plain size", &size) == B_OK) {
156 				FontStyle* fontStyle = gFontManager->GetStyle(family, style);
157 				fPlainFont.SetStyle(fontStyle);
158 				fPlainFont.SetSize(size);
159 			}
160 
161 			if (settings.FindString("bold family", &family) == B_OK
162 				&& settings.FindString("bold style", &style) == B_OK
163 				&& settings.FindFloat("bold size", &size) == B_OK) {
164 				FontStyle* fontStyle = gFontManager->GetStyle(family, style);
165 				fBoldFont.SetStyle(fontStyle);
166 				fBoldFont.SetSize(size);
167 			}
168 
169 			if (settings.FindString("fixed family", &family) == B_OK
170 				&& settings.FindString("fixed style", &style) == B_OK
171 				&& settings.FindFloat("fixed size", &size) == B_OK) {
172 				FontStyle* fontStyle = gFontManager->GetStyle(family, style);
173 				if (fontStyle != NULL && fontStyle->IsFixedWidth())
174 					fFixedFont.SetStyle(fontStyle);
175 				fFixedFont.SetSize(size);
176 			}
177 
178 			int32 hinting;
179 			if (settings.FindInt32("hinting", &hinting) == B_OK)
180 				gDefaultHintingMode = hinting;
181 
182 			gFontManager->Unlock();
183 		}
184 	}
185 
186 	// read mouse settings
187 
188 	path = basePath;
189 	path.Append("mouse");
190 
191 	status = file.SetTo(path.Path(), B_READ_ONLY);
192 	if (status == B_OK) {
193 		BMessage settings;
194 		status = settings.Unflatten(&file);
195 		if (status == B_OK) {
196 			int32 mode;
197 			if (settings.FindInt32("mode", &mode) == B_OK) {
198 				fMouseMode = (mode_mouse)mode;
199 			}
200 		}
201 	}
202 
203 	// read appearance settings
204 
205 	path = basePath;
206 	path.Append("appearance");
207 
208 	status = file.SetTo(path.Path(), B_READ_ONLY);
209 	if (status == B_OK) {
210 		BMessage settings;
211 		status = settings.Unflatten(&file);
212 		if (status == B_OK) {
213 			float fontSize;
214 			if (settings.FindFloat("font size", &fontSize) == B_OK)
215 				fMenuInfo.font_size = fontSize;
216 
217 			const char* fontFamily;
218 			if (settings.FindString("font family", &fontFamily) == B_OK)
219 				strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
220 
221 			const char* fontStyle;
222 			if (settings.FindString("font style", &fontStyle) == B_OK)
223 				strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
224 
225 			rgb_color bgColor;
226 			if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
227 				fMenuInfo.background_color = bgColor;
228 
229 			int32 separator;
230 			if (settings.FindInt32("separator", &separator) == B_OK)
231 				fMenuInfo.separator = separator;
232 
233 			bool clickToOpen;
234 			if (settings.FindBool("click to open", &clickToOpen) == B_OK)
235 				fMenuInfo.click_to_open = clickToOpen;
236 
237 			bool triggersAlwaysShown;
238 			if (settings.FindBool("triggers always shown", &triggersAlwaysShown)
239 					== B_OK) {
240 				fMenuInfo.triggers_always_shown = triggersAlwaysShown;
241 			}
242 
243 			bool subpix;
244 			if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK)
245 				gSubpixelAntialiasing = subpix;
246 
247 			int8 averageWeight;
248 			if (settings.FindInt8("subpixel average weight", &averageWeight)
249 					== B_OK) {
250 				gSubpixelAverageWeight = averageWeight;
251 			}
252 
253 			bool subpixelOrdering;
254 			if (settings.FindBool("subpixel ordering", &subpixelOrdering)
255 					== B_OK) {
256 				gSubpixelOrderingRGB = subpixelOrdering;
257 			}
258 
259 			for (int32 i = 0; i < kNumColors; i++) {
260 				char colorName[12];
261 				snprintf(colorName, sizeof(colorName), "color%ld",
262 					(int32)index_to_color_which(i));
263 
264 				settings.FindInt32(colorName, (int32*)&fShared.colors[i]);
265 			}
266 		}
267 	}
268 
269 	// read dragger settings
270 
271 	path = basePath;
272 	path.Append("dragger");
273 
274 	status = file.SetTo(path.Path(), B_READ_ONLY);
275 	if (status == B_OK) {
276 		BMessage settings;
277 		status = settings.Unflatten(&file);
278 		if (status == B_OK) {
279 			if (settings.FindBool("show", &fShowAllDraggers) != B_OK)
280 				fShowAllDraggers = true;
281 		}
282 	}
283 
284 	return B_OK;
285 }
286 
287 
288 status_t
289 DesktopSettingsPrivate::Save(uint32 mask)
290 {
291 #if TEST_MODE
292 	return B_OK;
293 #endif
294 
295 	BPath basePath;
296 	status_t status = _GetPath(basePath);
297 	if (status != B_OK)
298 		return status;
299 
300 	if (mask & kWorkspacesSettings) {
301 		BPath path(basePath);
302 		if (path.Append("workspaces") == B_OK) {
303 			BMessage settings('asws');
304 			settings.AddInt32("columns", fWorkspacesColumns);
305 			settings.AddInt32("rows", fWorkspacesRows);
306 
307 			for (int32 i = 0; i < kMaxWorkspaces; i++) {
308 				settings.AddMessage("workspace", &fWorkspaceMessages[i]);
309 			}
310 
311 			BFile file;
312 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
313 				| B_READ_WRITE);
314 			if (status == B_OK) {
315 				status = settings.Flatten(&file, NULL);
316 			}
317 		}
318 	}
319 
320 	if (mask & kFontSettings) {
321 		BPath path(basePath);
322 		if (path.Append("fonts") == B_OK) {
323 			BMessage settings('asfn');
324 
325 			settings.AddString("plain family", fPlainFont.Family());
326 			settings.AddString("plain style", fPlainFont.Style());
327 			settings.AddFloat("plain size", fPlainFont.Size());
328 
329 			settings.AddString("bold family", fBoldFont.Family());
330 			settings.AddString("bold style", fBoldFont.Style());
331 			settings.AddFloat("bold size", fBoldFont.Size());
332 
333 			settings.AddString("fixed family", fFixedFont.Family());
334 			settings.AddString("fixed style", fFixedFont.Style());
335 			settings.AddFloat("fixed size", fFixedFont.Size());
336 
337 			settings.AddInt32("hinting", gDefaultHintingMode);
338 
339 			BFile file;
340 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
341 				| B_READ_WRITE);
342 			if (status == B_OK) {
343 				status = settings.Flatten(&file, NULL);
344 			}
345 		}
346 	}
347 
348 	if (mask & kMouseSettings) {
349 		BPath path(basePath);
350 		if (path.Append("mouse") == B_OK) {
351 			BMessage settings('asms');
352 			settings.AddInt32("mode", (int32)fMouseMode);
353 
354 			BFile file;
355 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
356 				| B_READ_WRITE);
357 			if (status == B_OK) {
358 				status = settings.Flatten(&file, NULL);
359 			}
360 		}
361 	}
362 
363 	if (mask & kDraggerSettings) {
364 		BPath path(basePath);
365 		if (path.Append("dragger") == B_OK) {
366 			BMessage settings('asdg');
367 			settings.AddBool("show", fShowAllDraggers);
368 
369 			BFile file;
370 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
371 				| B_READ_WRITE);
372 			if (status == B_OK) {
373 				status = settings.Flatten(&file, NULL);
374 			}
375 		}
376 	}
377 
378 	if (mask & kAppearanceSettings) {
379 		BPath path(basePath);
380 		if (path.Append("appearance") == B_OK) {
381 			BMessage settings('aslk');
382 			settings.AddFloat("font size", fMenuInfo.font_size);
383 			settings.AddString("font family", fMenuInfo.f_family);
384 			settings.AddString("font style", fMenuInfo.f_style);
385 			settings.AddInt32("bg color",
386 				(const int32&)fMenuInfo.background_color);
387 			settings.AddInt32("separator", fMenuInfo.separator);
388 			settings.AddBool("click to open", fMenuInfo.click_to_open);
389 			settings.AddBool("triggers always shown",
390 				fMenuInfo.triggers_always_shown);
391 
392 			settings.AddBool("subpixel antialiasing", gSubpixelAntialiasing);
393 			settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
394 			settings.AddBool("subpixel ordering", gSubpixelOrderingRGB);
395 
396 			for (int32 i = 0; i < kNumColors; i++) {
397 				char colorName[12];
398 				snprintf(colorName, sizeof(colorName), "color%ld",
399 					(int32)index_to_color_which(i));
400 				settings.AddInt32(colorName, (const int32&)fShared.colors[i]);
401 			}
402 
403 			BFile file;
404 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
405 				| B_READ_WRITE);
406 			if (status == B_OK) {
407 				status = settings.Flatten(&file, NULL);
408 			}
409 		}
410 	}
411 
412 	return status;
413 }
414 
415 
416 void
417 DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
418 {
419 	fPlainFont = font;
420 	Save(kFontSettings);
421 }
422 
423 
424 const ServerFont &
425 DesktopSettingsPrivate::DefaultPlainFont() const
426 {
427 	return fPlainFont;
428 }
429 
430 
431 void
432 DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
433 {
434 	fBoldFont = font;
435 	Save(kFontSettings);
436 }
437 
438 
439 const ServerFont &
440 DesktopSettingsPrivate::DefaultBoldFont() const
441 {
442 	return fBoldFont;
443 }
444 
445 
446 void
447 DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
448 {
449 	fFixedFont = font;
450 	Save(kFontSettings);
451 }
452 
453 
454 const ServerFont &
455 DesktopSettingsPrivate::DefaultFixedFont() const
456 {
457 	return fFixedFont;
458 }
459 
460 
461 void
462 DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
463 {
464 	fScrollBarInfo = info;
465 	Save(kAppearanceSettings);
466 }
467 
468 
469 const scroll_bar_info&
470 DesktopSettingsPrivate::ScrollBarInfo() const
471 {
472 	return fScrollBarInfo;
473 }
474 
475 
476 void
477 DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
478 {
479 	fMenuInfo = info;
480 	// Also update the ui_color
481 	SetUIColor(B_MENU_BACKGROUND_COLOR, info.background_color);
482 		// SetUIColor already saves the settings
483 }
484 
485 
486 const menu_info&
487 DesktopSettingsPrivate::MenuInfo() const
488 {
489 	return fMenuInfo;
490 }
491 
492 
493 void
494 DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
495 {
496 	fMouseMode = mode;
497 	Save(kMouseSettings);
498 }
499 
500 
501 mode_mouse
502 DesktopSettingsPrivate::MouseMode() const
503 {
504 	return fMouseMode;
505 }
506 
507 
508 bool
509 DesktopSettingsPrivate::FocusFollowsMouse() const
510 {
511 	return MouseMode() != B_NORMAL_MOUSE;
512 }
513 
514 
515 void
516 DesktopSettingsPrivate::SetShowAllDraggers(bool show)
517 {
518 	fShowAllDraggers = show;
519 	Save(kDraggerSettings);
520 }
521 
522 
523 bool
524 DesktopSettingsPrivate::ShowAllDraggers() const
525 {
526 	return fShowAllDraggers;
527 }
528 
529 
530 void
531 DesktopSettingsPrivate::SetWorkspacesLayout(int32 columns, int32 rows)
532 {
533 	_ValidateWorkspacesLayout(columns, rows);
534 	fWorkspacesColumns = columns;
535 	fWorkspacesRows = rows;
536 
537 	Save(kWorkspacesSettings);
538 }
539 
540 
541 int32
542 DesktopSettingsPrivate::WorkspacesCount() const
543 {
544 	return fWorkspacesColumns * fWorkspacesRows;
545 }
546 
547 
548 int32
549 DesktopSettingsPrivate::WorkspacesColumns() const
550 {
551 	return fWorkspacesColumns;
552 }
553 
554 
555 int32
556 DesktopSettingsPrivate::WorkspacesRows() const
557 {
558 	return fWorkspacesRows;
559 }
560 
561 
562 void
563 DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
564 {
565 	if (index < 0 || index > kMaxWorkspaces)
566 		return;
567 
568 	fWorkspaceMessages[index] = message;
569 }
570 
571 
572 const BMessage*
573 DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
574 {
575 	if (index < 0 || index > kMaxWorkspaces)
576 		return NULL;
577 
578 	return &fWorkspaceMessages[index];
579 }
580 
581 
582 void
583 DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
584 {
585 	//
586 	int32 index = color_which_to_index(which);
587 	if (index < 0 || index >= kNumColors)
588 		return;
589 	fShared.colors[index] = color;
590 	// TODO: deprecate the background_color member of the menu_info struct,
591 	// otherwise we have to keep this duplication...
592 	if (which == B_MENU_BACKGROUND_COLOR)
593 		fMenuInfo.background_color = color;
594 	Save(kAppearanceSettings);
595 }
596 
597 
598 rgb_color
599 DesktopSettingsPrivate::UIColor(color_which which) const
600 {
601 	static const rgb_color invalidColor = {0, 0, 0, 0};
602 	int32 index = color_which_to_index(which);
603 	if (index < 0 || index >= kNumColors)
604 		return invalidColor;
605 	return fShared.colors[index];
606 }
607 
608 
609 void
610 DesktopSettingsPrivate::SetSubpixelAntialiasing(bool subpix)
611 {
612 	gSubpixelAntialiasing = subpix;
613 	Save(kAppearanceSettings);
614 }
615 
616 
617 bool
618 DesktopSettingsPrivate::SubpixelAntialiasing() const
619 {
620 	return gSubpixelAntialiasing;
621 }
622 
623 
624 void
625 DesktopSettingsPrivate::SetHinting(uint8 hinting)
626 {
627 	gDefaultHintingMode = hinting;
628 	Save(kFontSettings);
629 }
630 
631 
632 uint8
633 DesktopSettingsPrivate::Hinting() const
634 {
635 	return gDefaultHintingMode;
636 }
637 
638 
639 void
640 DesktopSettingsPrivate::SetSubpixelAverageWeight(uint8 averageWeight)
641 {
642 	gSubpixelAverageWeight = averageWeight;
643 	Save(kAppearanceSettings);
644 }
645 
646 
647 uint8
648 DesktopSettingsPrivate::SubpixelAverageWeight() const
649 {
650 	return gSubpixelAverageWeight;
651 }
652 
653 
654 void
655 DesktopSettingsPrivate::SetSubpixelOrderingRegular(bool subpixelOrdering)
656 {
657 	gSubpixelOrderingRGB = subpixelOrdering;
658 	Save(kAppearanceSettings);
659 }
660 
661 
662 bool
663 DesktopSettingsPrivate::IsSubpixelOrderingRegular() const
664 {
665 	return gSubpixelOrderingRGB;
666 }
667 
668 
669 void
670 DesktopSettingsPrivate::_ValidateWorkspacesLayout(int32& columns,
671 	int32& rows) const
672 {
673 	if (columns < 1)
674 		columns = 1;
675 	if (rows < 1)
676 		rows = 1;
677 
678 	if (columns * rows > kMaxWorkspaces) {
679 		// Revert to defaults in case of invalid settings
680 		columns = 2;
681 		rows = 2;
682 	}
683 }
684 
685 
686 //	#pragma mark - read access
687 
688 
689 DesktopSettings::DesktopSettings(Desktop* desktop)
690 	:
691 	fSettings(desktop->fSettings)
692 {
693 #if DEBUG
694 	if (!desktop->fWindowLock.IsWriteLocked()
695 		&& !desktop->fWindowLock.IsReadLocked())
696 		debugger("desktop not locked when trying to access settings");
697 #endif
698 }
699 
700 
701 void
702 DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
703 {
704 	font = fSettings->DefaultPlainFont();
705 }
706 
707 
708 void
709 DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
710 {
711 	font = fSettings->DefaultBoldFont();
712 }
713 
714 
715 void
716 DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
717 {
718 	font = fSettings->DefaultFixedFont();
719 }
720 
721 
722 void
723 DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
724 {
725 	info = fSettings->ScrollBarInfo();
726 }
727 
728 
729 void
730 DesktopSettings::GetMenuInfo(menu_info& info) const
731 {
732 	info = fSettings->MenuInfo();
733 }
734 
735 
736 mode_mouse
737 DesktopSettings::MouseMode() const
738 {
739 	return fSettings->MouseMode();
740 }
741 
742 
743 bool
744 DesktopSettings::FocusFollowsMouse() const
745 {
746 	return fSettings->FocusFollowsMouse();
747 }
748 
749 
750 bool
751 DesktopSettings::ShowAllDraggers() const
752 {
753 	return fSettings->ShowAllDraggers();
754 }
755 
756 
757 int32
758 DesktopSettings::WorkspacesCount() const
759 {
760 	return fSettings->WorkspacesCount();
761 }
762 
763 
764 int32
765 DesktopSettings::WorkspacesColumns() const
766 {
767 	return fSettings->WorkspacesColumns();
768 }
769 
770 
771 int32
772 DesktopSettings::WorkspacesRows() const
773 {
774 	return fSettings->WorkspacesRows();
775 }
776 
777 
778 const BMessage*
779 DesktopSettings::WorkspacesMessage(int32 index) const
780 {
781 	return fSettings->WorkspacesMessage(index);
782 }
783 
784 
785 rgb_color
786 DesktopSettings::UIColor(color_which which) const
787 {
788 	return fSettings->UIColor(which);
789 }
790 
791 
792 bool
793 DesktopSettings::SubpixelAntialiasing() const
794 {
795 	return fSettings->SubpixelAntialiasing();
796 }
797 
798 
799 uint8
800 DesktopSettings::Hinting() const
801 {
802 	return fSettings->Hinting();
803 }
804 
805 
806 uint8
807 DesktopSettings::SubpixelAverageWeight() const
808 {
809 	return fSettings->SubpixelAverageWeight();
810 }
811 
812 
813 bool
814 DesktopSettings::IsSubpixelOrderingRegular() const
815 {
816 	// True corresponds to RGB, false means BGR
817 	return fSettings->IsSubpixelOrderingRegular();
818 }
819 
820 //	#pragma mark - write access
821 
822 
823 LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
824 	: DesktopSettings(desktop),
825 	fDesktop(desktop)
826 {
827 #if DEBUG
828 	if (desktop->fWindowLock.IsReadLocked())
829 		debugger("desktop read locked when trying to change settings");
830 #endif
831 
832 	fDesktop->LockAllWindows();
833 }
834 
835 
836 LockedDesktopSettings::~LockedDesktopSettings()
837 {
838 	fDesktop->UnlockAllWindows();
839 }
840 
841 
842 void
843 LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
844 {
845 	fSettings->SetDefaultPlainFont(font);
846 }
847 
848 
849 void
850 LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
851 {
852 	fSettings->SetDefaultBoldFont(font);
853 	fDesktop->BroadcastToAllWindows(AS_SYSTEM_FONT_CHANGED);
854 }
855 
856 
857 void
858 LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
859 {
860 	fSettings->SetDefaultFixedFont(font);
861 }
862 
863 
864 void
865 LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
866 {
867 	fSettings->SetScrollBarInfo(info);
868 }
869 
870 
871 void
872 LockedDesktopSettings::SetMenuInfo(const menu_info& info)
873 {
874 	fSettings->SetMenuInfo(info);
875 }
876 
877 
878 void
879 LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
880 {
881 	fSettings->SetMouseMode(mode);
882 }
883 
884 
885 void
886 LockedDesktopSettings::SetShowAllDraggers(bool show)
887 {
888 	fSettings->SetShowAllDraggers(show);
889 }
890 
891 
892 void
893 LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
894 {
895 	fSettings->SetUIColor(which, color);
896 }
897 
898 
899 void
900 LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
901 {
902 	fSettings->SetSubpixelAntialiasing(subpix);
903 }
904 
905 
906 void
907 LockedDesktopSettings::SetHinting(uint8 hinting)
908 {
909 	fSettings->SetHinting(hinting);
910 }
911 
912 
913 void
914 LockedDesktopSettings::SetSubpixelAverageWeight(uint8 averageWeight)
915 {
916 	fSettings->SetSubpixelAverageWeight(averageWeight);
917 }
918 
919 void
920 LockedDesktopSettings::SetSubpixelOrderingRegular(bool subpixelOrdering)
921 {
922 	fSettings->SetSubpixelOrderingRegular(subpixelOrdering);
923 }
924 
925