xref: /haiku/src/servers/app/DesktopSettings.cpp (revision 926e63c8851f8e1d085981e69ef03f8e9cda1e65)
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 
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 			int32 focusFollowsMouseMode;
203 			if (settings.FindInt32("focus follows mouse mode",
204 				&focusFollowsMouseMode) == B_OK) {
205 				fFocusFollowsMouseMode =
206 					(mode_focus_follows_mouse)focusFollowsMouseMode;
207 			}
208 			bool acceptFirstClick;
209 			if (settings.FindBool("accept first click", &acceptFirstClick)
210 				== B_OK)
211 				fAcceptFirstClick = acceptFirstClick;
212 		}
213 	}
214 
215 	// read appearance settings
216 
217 	path = basePath;
218 	path.Append("appearance");
219 
220 	status = file.SetTo(path.Path(), B_READ_ONLY);
221 	if (status == B_OK) {
222 		BMessage settings;
223 		status = settings.Unflatten(&file);
224 		if (status == B_OK) {
225 			float fontSize;
226 			if (settings.FindFloat("font size", &fontSize) == B_OK)
227 				fMenuInfo.font_size = fontSize;
228 
229 			const char* fontFamily;
230 			if (settings.FindString("font family", &fontFamily) == B_OK)
231 				strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
232 
233 			const char* fontStyle;
234 			if (settings.FindString("font style", &fontStyle) == B_OK)
235 				strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
236 
237 			rgb_color bgColor;
238 			if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
239 				fMenuInfo.background_color = bgColor;
240 
241 			int32 separator;
242 			if (settings.FindInt32("separator", &separator) == B_OK)
243 				fMenuInfo.separator = separator;
244 
245 			bool clickToOpen;
246 			if (settings.FindBool("click to open", &clickToOpen) == B_OK)
247 				fMenuInfo.click_to_open = clickToOpen;
248 
249 			bool triggersAlwaysShown;
250 			if (settings.FindBool("triggers always shown",
251 				&triggersAlwaysShown) == B_OK) {
252 				fMenuInfo.triggers_always_shown = triggersAlwaysShown;
253 			}
254 
255 			bool subpix;
256 			if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK)
257 				gSubpixelAntialiasing = subpix;
258 
259 			int8 averageWeight;
260 			if (settings.FindInt8("subpixel average weight", &averageWeight)
261 					== B_OK) {
262 				gSubpixelAverageWeight = averageWeight;
263 			}
264 
265 			bool subpixelOrdering;
266 			if (settings.FindBool("subpixel ordering", &subpixelOrdering)
267 					== B_OK) {
268 				gSubpixelOrderingRGB = subpixelOrdering;
269 			}
270 
271 			for (int32 i = 0; i < kNumColors; i++) {
272 				char colorName[12];
273 				snprintf(colorName, sizeof(colorName), "color%ld",
274 					(int32)index_to_color_which(i));
275 
276 				settings.FindInt32(colorName, (int32*)&fShared.colors[i]);
277 			}
278 		}
279 	}
280 
281 	// read dragger settings
282 
283 	path = basePath;
284 	path.Append("dragger");
285 
286 	status = file.SetTo(path.Path(), B_READ_ONLY);
287 	if (status == B_OK) {
288 		BMessage settings;
289 		status = settings.Unflatten(&file);
290 		if (status == B_OK) {
291 			if (settings.FindBool("show", &fShowAllDraggers) != B_OK)
292 				fShowAllDraggers = true;
293 		}
294 	}
295 
296 	return B_OK;
297 }
298 
299 
300 status_t
301 DesktopSettingsPrivate::Save(uint32 mask)
302 {
303 #if TEST_MODE
304 	return B_OK;
305 #endif
306 
307 	BPath basePath;
308 	status_t status = _GetPath(basePath);
309 	if (status != B_OK)
310 		return status;
311 
312 	if (mask & kWorkspacesSettings) {
313 		BPath path(basePath);
314 		if (path.Append("workspaces") == B_OK) {
315 			BMessage settings('asws');
316 			settings.AddInt32("columns", fWorkspacesColumns);
317 			settings.AddInt32("rows", fWorkspacesRows);
318 
319 			for (int32 i = 0; i < kMaxWorkspaces; i++) {
320 				settings.AddMessage("workspace", &fWorkspaceMessages[i]);
321 			}
322 
323 			BFile file;
324 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
325 				| B_READ_WRITE);
326 			if (status == B_OK) {
327 				status = settings.Flatten(&file, NULL);
328 			}
329 		}
330 	}
331 
332 	if (mask & kFontSettings) {
333 		BPath path(basePath);
334 		if (path.Append("fonts") == B_OK) {
335 			BMessage settings('asfn');
336 
337 			settings.AddString("plain family", fPlainFont.Family());
338 			settings.AddString("plain style", fPlainFont.Style());
339 			settings.AddFloat("plain size", fPlainFont.Size());
340 
341 			settings.AddString("bold family", fBoldFont.Family());
342 			settings.AddString("bold style", fBoldFont.Style());
343 			settings.AddFloat("bold size", fBoldFont.Size());
344 
345 			settings.AddString("fixed family", fFixedFont.Family());
346 			settings.AddString("fixed style", fFixedFont.Style());
347 			settings.AddFloat("fixed size", fFixedFont.Size());
348 
349 			settings.AddInt32("hinting", gDefaultHintingMode);
350 
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);
356 			}
357 		}
358 	}
359 
360 	if (mask & kMouseSettings) {
361 		BPath path(basePath);
362 		if (path.Append("mouse") == B_OK) {
363 			BMessage settings('asms');
364 			settings.AddInt32("mode", (int32)fMouseMode);
365 			settings.AddInt32("focus follows mouse mode",
366 				(int32)fFocusFollowsMouseMode);
367 			settings.AddBool("accept first click", fAcceptFirstClick);
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 & kDraggerSettings) {
379 		BPath path(basePath);
380 		if (path.Append("dragger") == B_OK) {
381 			BMessage settings('asdg');
382 			settings.AddBool("show", fShowAllDraggers);
383 
384 			BFile file;
385 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
386 				| B_READ_WRITE);
387 			if (status == B_OK) {
388 				status = settings.Flatten(&file, NULL);
389 			}
390 		}
391 	}
392 
393 	if (mask & kAppearanceSettings) {
394 		BPath path(basePath);
395 		if (path.Append("appearance") == B_OK) {
396 			BMessage settings('aslk');
397 			settings.AddFloat("font size", fMenuInfo.font_size);
398 			settings.AddString("font family", fMenuInfo.f_family);
399 			settings.AddString("font style", fMenuInfo.f_style);
400 			settings.AddInt32("bg color",
401 				(const int32&)fMenuInfo.background_color);
402 			settings.AddInt32("separator", fMenuInfo.separator);
403 			settings.AddBool("click to open", fMenuInfo.click_to_open);
404 			settings.AddBool("triggers always shown",
405 				fMenuInfo.triggers_always_shown);
406 
407 			settings.AddBool("subpixel antialiasing", gSubpixelAntialiasing);
408 			settings.AddInt8("subpixel average weight", gSubpixelAverageWeight);
409 			settings.AddBool("subpixel ordering", gSubpixelOrderingRGB);
410 
411 			for (int32 i = 0; i < kNumColors; i++) {
412 				char colorName[12];
413 				snprintf(colorName, sizeof(colorName), "color%ld",
414 					(int32)index_to_color_which(i));
415 				settings.AddInt32(colorName, (const int32&)fShared.colors[i]);
416 			}
417 
418 			BFile file;
419 			status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE
420 				| B_READ_WRITE);
421 			if (status == B_OK) {
422 				status = settings.Flatten(&file, NULL);
423 			}
424 		}
425 	}
426 
427 	return status;
428 }
429 
430 
431 void
432 DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
433 {
434 	fPlainFont = font;
435 	Save(kFontSettings);
436 }
437 
438 
439 const ServerFont &
440 DesktopSettingsPrivate::DefaultPlainFont() const
441 {
442 	return fPlainFont;
443 }
444 
445 
446 void
447 DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
448 {
449 	fBoldFont = font;
450 	Save(kFontSettings);
451 }
452 
453 
454 const ServerFont &
455 DesktopSettingsPrivate::DefaultBoldFont() const
456 {
457 	return fBoldFont;
458 }
459 
460 
461 void
462 DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
463 {
464 	fFixedFont = font;
465 	Save(kFontSettings);
466 }
467 
468 
469 const ServerFont &
470 DesktopSettingsPrivate::DefaultFixedFont() const
471 {
472 	return fFixedFont;
473 }
474 
475 
476 void
477 DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
478 {
479 	fScrollBarInfo = info;
480 	Save(kAppearanceSettings);
481 }
482 
483 
484 const scroll_bar_info&
485 DesktopSettingsPrivate::ScrollBarInfo() const
486 {
487 	return fScrollBarInfo;
488 }
489 
490 
491 void
492 DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
493 {
494 	fMenuInfo = info;
495 	// Also update the ui_color
496 	SetUIColor(B_MENU_BACKGROUND_COLOR, info.background_color);
497 		// SetUIColor already saves the settings
498 }
499 
500 
501 const menu_info&
502 DesktopSettingsPrivate::MenuInfo() const
503 {
504 	return fMenuInfo;
505 }
506 
507 
508 void
509 DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
510 {
511 	fMouseMode = mode;
512 	Save(kMouseSettings);
513 }
514 
515 
516 void
517 DesktopSettingsPrivate::SetFocusFollowsMouseMode(
518 	const mode_focus_follows_mouse mode)
519 {
520 	fFocusFollowsMouseMode = mode;
521 	Save(kMouseSettings);
522 }
523 
524 
525 mode_mouse
526 DesktopSettingsPrivate::MouseMode() const
527 {
528 	return fMouseMode;
529 }
530 
531 
532 mode_focus_follows_mouse
533 DesktopSettingsPrivate::FocusFollowsMouseMode() const
534 {
535 	return fFocusFollowsMouseMode;
536 }
537 
538 
539 void
540 DesktopSettingsPrivate::SetAcceptFirstClick(const bool acceptFirstClick)
541 {
542 	fAcceptFirstClick = acceptFirstClick;
543 	Save(kMouseSettings);
544 }
545 
546 
547 bool
548 DesktopSettingsPrivate::AcceptFirstClick() const
549 {
550 	return fAcceptFirstClick;
551 }
552 
553 
554 bool
555 DesktopSettingsPrivate::FocusFollowsMouse() const
556 {
557 	return MouseMode() == B_FOCUS_FOLLOWS_MOUSE;
558 }
559 
560 
561 void
562 DesktopSettingsPrivate::SetShowAllDraggers(bool show)
563 {
564 	fShowAllDraggers = show;
565 	Save(kDraggerSettings);
566 }
567 
568 
569 bool
570 DesktopSettingsPrivate::ShowAllDraggers() const
571 {
572 	return fShowAllDraggers;
573 }
574 
575 
576 void
577 DesktopSettingsPrivate::SetWorkspacesLayout(int32 columns, int32 rows)
578 {
579 	_ValidateWorkspacesLayout(columns, rows);
580 	fWorkspacesColumns = columns;
581 	fWorkspacesRows = rows;
582 
583 	Save(kWorkspacesSettings);
584 }
585 
586 
587 int32
588 DesktopSettingsPrivate::WorkspacesCount() const
589 {
590 	return fWorkspacesColumns * fWorkspacesRows;
591 }
592 
593 
594 int32
595 DesktopSettingsPrivate::WorkspacesColumns() const
596 {
597 	return fWorkspacesColumns;
598 }
599 
600 
601 int32
602 DesktopSettingsPrivate::WorkspacesRows() const
603 {
604 	return fWorkspacesRows;
605 }
606 
607 
608 void
609 DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
610 {
611 	if (index < 0 || index > kMaxWorkspaces)
612 		return;
613 
614 	fWorkspaceMessages[index] = message;
615 }
616 
617 
618 const BMessage*
619 DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
620 {
621 	if (index < 0 || index > kMaxWorkspaces)
622 		return NULL;
623 
624 	return &fWorkspaceMessages[index];
625 }
626 
627 
628 void
629 DesktopSettingsPrivate::SetUIColor(color_which which, const rgb_color color)
630 {
631 	//
632 	int32 index = color_which_to_index(which);
633 	if (index < 0 || index >= kNumColors)
634 		return;
635 	fShared.colors[index] = color;
636 	// TODO: deprecate the background_color member of the menu_info struct,
637 	// otherwise we have to keep this duplication...
638 	if (which == B_MENU_BACKGROUND_COLOR)
639 		fMenuInfo.background_color = color;
640 	Save(kAppearanceSettings);
641 }
642 
643 
644 rgb_color
645 DesktopSettingsPrivate::UIColor(color_which which) const
646 {
647 	static const rgb_color invalidColor = {0, 0, 0, 0};
648 	int32 index = color_which_to_index(which);
649 	if (index < 0 || index >= kNumColors)
650 		return invalidColor;
651 	return fShared.colors[index];
652 }
653 
654 
655 void
656 DesktopSettingsPrivate::SetSubpixelAntialiasing(bool subpix)
657 {
658 	gSubpixelAntialiasing = subpix;
659 	Save(kAppearanceSettings);
660 }
661 
662 
663 bool
664 DesktopSettingsPrivate::SubpixelAntialiasing() const
665 {
666 	return gSubpixelAntialiasing;
667 }
668 
669 
670 void
671 DesktopSettingsPrivate::SetHinting(uint8 hinting)
672 {
673 	gDefaultHintingMode = hinting;
674 	Save(kFontSettings);
675 }
676 
677 
678 uint8
679 DesktopSettingsPrivate::Hinting() const
680 {
681 	return gDefaultHintingMode;
682 }
683 
684 
685 void
686 DesktopSettingsPrivate::SetSubpixelAverageWeight(uint8 averageWeight)
687 {
688 	gSubpixelAverageWeight = averageWeight;
689 	Save(kAppearanceSettings);
690 }
691 
692 
693 uint8
694 DesktopSettingsPrivate::SubpixelAverageWeight() const
695 {
696 	return gSubpixelAverageWeight;
697 }
698 
699 
700 void
701 DesktopSettingsPrivate::SetSubpixelOrderingRegular(bool subpixelOrdering)
702 {
703 	gSubpixelOrderingRGB = subpixelOrdering;
704 	Save(kAppearanceSettings);
705 }
706 
707 
708 bool
709 DesktopSettingsPrivate::IsSubpixelOrderingRegular() const
710 {
711 	return gSubpixelOrderingRGB;
712 }
713 
714 
715 void
716 DesktopSettingsPrivate::_ValidateWorkspacesLayout(int32& columns,
717 	int32& rows) const
718 {
719 	if (columns < 1)
720 		columns = 1;
721 	if (rows < 1)
722 		rows = 1;
723 
724 	if (columns * rows > kMaxWorkspaces) {
725 		// Revert to defaults in case of invalid settings
726 		columns = 2;
727 		rows = 2;
728 	}
729 }
730 
731 
732 //	#pragma mark - read access
733 
734 
735 DesktopSettings::DesktopSettings(Desktop* desktop)
736 	:
737 	fSettings(desktop->fSettings)
738 {
739 #if DEBUG
740 	if (!desktop->fWindowLock.IsWriteLocked()
741 		&& !desktop->fWindowLock.IsReadLocked())
742 		debugger("desktop not locked when trying to access settings");
743 #endif
744 }
745 
746 
747 void
748 DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
749 {
750 	font = fSettings->DefaultPlainFont();
751 }
752 
753 
754 void
755 DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
756 {
757 	font = fSettings->DefaultBoldFont();
758 }
759 
760 
761 void
762 DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
763 {
764 	font = fSettings->DefaultFixedFont();
765 }
766 
767 
768 void
769 DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
770 {
771 	info = fSettings->ScrollBarInfo();
772 }
773 
774 
775 void
776 DesktopSettings::GetMenuInfo(menu_info& info) const
777 {
778 	info = fSettings->MenuInfo();
779 }
780 
781 
782 mode_mouse
783 DesktopSettings::MouseMode() const
784 {
785 	return fSettings->MouseMode();
786 }
787 
788 
789 mode_focus_follows_mouse
790 DesktopSettings::FocusFollowsMouseMode() const
791 {
792 	return fSettings->FocusFollowsMouseMode();
793 }
794 
795 
796 bool
797 DesktopSettings::FocusFollowsMouse() const
798 {
799 	return fSettings->FocusFollowsMouse();
800 }
801 
802 
803 bool
804 DesktopSettings::AcceptFirstClick() const
805 {
806 	return fSettings->AcceptFirstClick();
807 }
808 
809 
810 bool
811 DesktopSettings::ShowAllDraggers() const
812 {
813 	return fSettings->ShowAllDraggers();
814 }
815 
816 
817 int32
818 DesktopSettings::WorkspacesCount() const
819 {
820 	return fSettings->WorkspacesCount();
821 }
822 
823 
824 int32
825 DesktopSettings::WorkspacesColumns() const
826 {
827 	return fSettings->WorkspacesColumns();
828 }
829 
830 
831 int32
832 DesktopSettings::WorkspacesRows() const
833 {
834 	return fSettings->WorkspacesRows();
835 }
836 
837 
838 const BMessage*
839 DesktopSettings::WorkspacesMessage(int32 index) const
840 {
841 	return fSettings->WorkspacesMessage(index);
842 }
843 
844 
845 rgb_color
846 DesktopSettings::UIColor(color_which which) const
847 {
848 	return fSettings->UIColor(which);
849 }
850 
851 
852 bool
853 DesktopSettings::SubpixelAntialiasing() const
854 {
855 	return fSettings->SubpixelAntialiasing();
856 }
857 
858 
859 uint8
860 DesktopSettings::Hinting() const
861 {
862 	return fSettings->Hinting();
863 }
864 
865 
866 uint8
867 DesktopSettings::SubpixelAverageWeight() const
868 {
869 	return fSettings->SubpixelAverageWeight();
870 }
871 
872 
873 bool
874 DesktopSettings::IsSubpixelOrderingRegular() const
875 {
876 	// True corresponds to RGB, false means BGR
877 	return fSettings->IsSubpixelOrderingRegular();
878 }
879 
880 //	#pragma mark - write access
881 
882 
883 LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
884 	: DesktopSettings(desktop),
885 	fDesktop(desktop)
886 {
887 #if DEBUG
888 	if (desktop->fWindowLock.IsReadLocked())
889 		debugger("desktop read locked when trying to change settings");
890 #endif
891 
892 	fDesktop->LockAllWindows();
893 }
894 
895 
896 LockedDesktopSettings::~LockedDesktopSettings()
897 {
898 	fDesktop->UnlockAllWindows();
899 }
900 
901 
902 void
903 LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
904 {
905 	fSettings->SetDefaultPlainFont(font);
906 }
907 
908 
909 void
910 LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
911 {
912 	fSettings->SetDefaultBoldFont(font);
913 	fDesktop->BroadcastToAllWindows(AS_SYSTEM_FONT_CHANGED);
914 }
915 
916 
917 void
918 LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
919 {
920 	fSettings->SetDefaultFixedFont(font);
921 }
922 
923 
924 void
925 LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
926 {
927 	fSettings->SetScrollBarInfo(info);
928 }
929 
930 
931 void
932 LockedDesktopSettings::SetMenuInfo(const menu_info& info)
933 {
934 	fSettings->SetMenuInfo(info);
935 }
936 
937 
938 void
939 LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
940 {
941 	fSettings->SetMouseMode(mode);
942 }
943 
944 
945 void
946 LockedDesktopSettings::SetFocusFollowsMouseMode(
947 	const mode_focus_follows_mouse mode)
948 {
949 	fSettings->SetFocusFollowsMouseMode(mode);
950 }
951 
952 
953 void
954 LockedDesktopSettings::SetAcceptFirstClick(const bool acceptFirstClick)
955 {
956 	fSettings->SetAcceptFirstClick(acceptFirstClick);
957 }
958 
959 
960 void
961 LockedDesktopSettings::SetShowAllDraggers(bool show)
962 {
963 	fSettings->SetShowAllDraggers(show);
964 }
965 
966 
967 void
968 LockedDesktopSettings::SetUIColor(color_which which, const rgb_color color)
969 {
970 	fSettings->SetUIColor(which, color);
971 }
972 
973 
974 void
975 LockedDesktopSettings::SetSubpixelAntialiasing(bool subpix)
976 {
977 	fSettings->SetSubpixelAntialiasing(subpix);
978 }
979 
980 
981 void
982 LockedDesktopSettings::SetHinting(uint8 hinting)
983 {
984 	fSettings->SetHinting(hinting);
985 }
986 
987 
988 void
989 LockedDesktopSettings::SetSubpixelAverageWeight(uint8 averageWeight)
990 {
991 	fSettings->SetSubpixelAverageWeight(averageWeight);
992 }
993 
994 void
995 LockedDesktopSettings::SetSubpixelOrderingRegular(bool subpixelOrdering)
996 {
997 	fSettings->SetSubpixelOrderingRegular(subpixelOrdering);
998 }
999 
1000