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