xref: /haiku/src/add-ons/accelerants/radeon/settings.cpp (revision 39241fe22890fb958b6ba32d6ab9526da98be187)
1 /*
2 	Copyright (c) 2002, Thomas Kurschel
3 
4 
5 	Part of Radeon accelerant
6 
7 	Settings file
8 
9 	We shouldn't really need settings as this info
10 	should be stored by app_server, but especially
11 	BWindowScreen programs cannot now about extra
12 	features/settings, so we need to store the flags
13 	internally (until I have a better idea ;)
14 
15 	Especially "SwapWindow" should be mode-independant
16 	(you don't swap monitors when you select another
17 	workspace, do you?)
18 */
19 
20 #include "radeon_accelerant.h"
21 #include "generic.h"
22 #include "GlobalData.h"
23 
24 #include <FindDirectory.h>
25 #include <Path.h>
26 #include <File.h>
27 
28 void Radeon_ReadSettings( virtual_card *vc )
29 {
30 	BPath path;
31 	int32 tmp;
32 
33 	// per default we enable combine mode;
34 	// if actual mode isn't combine mode, we fall back to clone mode
35 	vc->wanted_multi_mode = mm_combine;
36 	vc->swap_displays = false;
37 
38 	// per default, show overlay on first port
39 	//vc->whished_overlay_port = 0;
40 
41 	// this is problematic during boot: if there is	multi-user support,
42 	// you don't have a user when app_server gets launched;
43 	// on the other hand, storing settings globally is not user-friendly...
44 	if( find_directory( B_USER_SETTINGS_DIRECTORY, &path ) != B_OK )
45 		return;
46 
47 	path.Append( "radeon" );
48 
49 	BFile file( path.Path(), B_READ_ONLY );
50 
51 	if( file.InitCheck() != B_OK )
52 		return;
53 
54 	BMessage settings;
55 
56 	if( settings.Unflatten( &file ) != B_OK )
57 		return;
58 
59 	if( settings.FindBool( "SwapDisplays", &vc->swap_displays ) != B_OK )
60 		vc->swap_displays = false;
61 
62 	if( settings.FindInt32( "MultiMonitorMode", &tmp ) != B_OK )
63 		tmp = mm_combine;
64 
65 	switch( tmp ) {
66 	case mm_none:
67 	case mm_mirror:
68 	case mm_combine:
69 	case mm_clone:
70 		vc->wanted_multi_mode = (multi_mode_e) tmp;
71 		break;
72 	default:
73 		vc->wanted_multi_mode = mm_combine;
74 	}
75 
76 	if( settings.FindInt32( "OverlayPort", &tmp ) != B_OK )
77 		tmp = 0;
78 
79 	//vc->whished_overlay_port = tmp;
80 }
81 
82 void Radeon_WriteSettings( virtual_card *vc )
83 {
84 	BPath path;
85 	int32 tmp;
86 
87 	// this is problematic during boot: if there is	multi-user support,
88 	// you don't have a user when app_server gets launched;
89 	// on the other hand, storing settings globally is not user-friendly...
90 	if( find_directory( B_USER_SETTINGS_DIRECTORY, &path ) != B_OK )
91 		return;
92 
93 	path.Append( "radeon" );
94 
95 	BFile file( path.Path(), B_CREATE_FILE | B_WRITE_ONLY );
96 
97 	if( file.InitCheck() != B_OK )
98 		return;
99 
100 	BMessage settings;
101 
102 	settings.AddBool( "SwapDisplays", vc->swap_displays );
103 	tmp = vc->wanted_multi_mode;
104 	settings.AddInt32( "MultiMonitorMode", tmp );
105 	/*tmp = vc->whished_overlay_port;
106 	settings.AddInt32( "OverlayPort", tmp );*/
107 
108 	settings.Flatten( &file );
109 }
110