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