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