Changeset 24280
- Timestamp:
- 03/06/08 15:17:20 (9 months ago)
- Location:
- haiku/trunk/src/preferences/screen
- Files:
-
- 2 modified
-
ScreenWindow.cpp (modified) (11 diffs)
-
ScreenWindow.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/preferences/screen/ScreenWindow.cpp
r22734 r24280 1 1 /* 2 * Copyright 2001-200 7, Haiku.2 * Copyright 2001-2008, Haiku. 3 3 * Distributed under the terms of the MIT License. 4 4 * … … 10 10 * Axel Dörfler, axeld@pinc-software.de 11 11 * Stephan Aßmus <superstippi@gmx.de> 12 * Alexandre Deckner, alex@zappotek.com 12 13 */ 13 14 … … 246 247 BMenuItem *item = new BMenuItem("Current Workspace", 247 248 new BMessage(WORKSPACE_CHECK_MSG)); 248 if (_IsVesa()) { 249 250 // TODO: since per workspace settings is unimplemented (Ticket #693) 251 // we force the menu to "All Workspaces" for now 252 //if (_IsVesa()) { 249 253 fAllWorkspacesItem->SetMarked(true); 250 254 item->SetEnabled(false); 251 } else 252 item->SetMarked(true); 255 //} else 256 // item->SetMarked(true); 257 253 258 popUpMenu->AddItem(item); 254 259 … … 347 352 float min, max; 348 353 if (fScreenMode.GetRefreshLimits(fActive, min, max) && min == max) { 354 // TODO: investigate, doesn't work for VESA at least 355 349 356 // This is a special case for drivers that only support a single 350 357 // frequency, like the VESA driver … … 779 786 ScreenWindow::WorkspaceActivated(int32 workspace, bool state) 780 787 { 781 fScreenMode.GetOriginalMode(fOriginal, workspace); 782 UpdateActiveMode(); 788 if (!_IsVesa()) { 789 fScreenMode.GetOriginalMode(fOriginal, workspace); 790 UpdateActiveMode(); 791 } 783 792 784 793 BMessage message(UPDATE_DESKTOP_COLOR_MSG); … … 936 945 { 937 946 fModified = false; 947 fVesaApplied = false; 938 948 BMenuItem *item; 939 949 item = fWorkspaceCountField->Menu()->ItemAt(fOriginalWorkspaceCount - 1); … … 943 953 // ScreenMode::Revert() assumes that we first set the correct number 944 954 // of workspaces 945 set_workspace_count(fOriginalWorkspaceCount); 946 fScreenMode.Revert(); 947 UpdateActiveMode(); 955 956 if (_IsVesa()) { 957 set_workspace_count(fOriginalWorkspaceCount); 958 fActive = fOriginal; 959 fSelected = fOriginal; 960 UpdateControls(); 961 } else { 962 set_workspace_count(fOriginalWorkspaceCount); 963 fScreenMode.Revert(); 964 UpdateActiveMode(); 965 } 948 966 break; 949 967 } … … 997 1015 998 1016 999 bool 1000 ScreenWindow::CanApply() const 1001 { 1002 return fAllWorkspacesItem->IsMarked() || fSelected != fActive; 1003 } 1004 1005 1006 bool 1007 ScreenWindow::CanRevert() const 1008 { 1009 return fSelected != fActive || count_workspaces() != fOriginalWorkspaceCount 1010 || fModified; 1017 status_t 1018 ScreenWindow::_ReadVesaModeFile(screen_mode& mode) const 1019 { 1020 BPath path; 1021 status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true); 1022 if (status < B_OK) 1023 return status; 1024 1025 path.Append("kernel/drivers/vesa"); 1026 BFile file; 1027 status = file.SetTo(path.Path(), B_READ_ONLY); 1028 if (status < B_OK) 1029 return status; 1030 1031 char buffer[256]; 1032 1033 ssize_t bytesRead = file.Read(buffer, sizeof(buffer) - 1); 1034 if (bytesRead < B_OK) { 1035 return bytesRead; 1036 } else { 1037 buffer[bytesRead] = '\0'; 1038 } 1039 1040 char ignore[256]; 1041 // if the file is malformed, sscanf shouldn't crash 1042 // on reading a big string since we don't even read 1043 // as much from the file 1044 uint32 bitDepth = 0; 1045 1046 if (sscanf(buffer, "%s %ld %ld %ld", ignore, 1047 &mode.width, &mode.height, &bitDepth) == 4) { 1048 1049 //TODO: check for valid width and height values 1050 1051 switch (bitDepth) { 1052 case 32: 1053 mode.space = B_RGB32; 1054 break; 1055 case 24: 1056 mode.space = B_RGB24; 1057 break; 1058 case 16: 1059 mode.space = B_RGB16; 1060 break; 1061 case 15: 1062 mode.space = B_RGB15; 1063 break; 1064 case 8: 1065 mode.space = B_CMAP8; 1066 break; 1067 default: 1068 // invalid value, we force it to B_RGB16 just in case 1069 mode.space = B_RGB16; 1070 return B_ERROR; 1071 } 1072 return B_OK; 1073 } else { 1074 return B_ERROR; 1075 } 1011 1076 } 1012 1077 … … 1015 1080 ScreenWindow::CheckApplyEnabled() 1016 1081 { 1017 fApplyButton->SetEnabled( CanApply());1018 fRevertButton->SetEnabled( CanRevert());1082 fApplyButton->SetEnabled(fSelected != fActive); 1083 fRevertButton->SetEnabled(count_workspaces() != fOriginalWorkspaceCount || fSelected != fOriginal); 1019 1084 } 1020 1085 … … 1025 1090 fOriginalWorkspaceCount = count_workspaces(); 1026 1091 fScreenMode.Get(fOriginal); 1092 1093 // If we are in vesa we overwrite fOriginal's resolution and bitdepth 1094 // with those found the vesa settings file. (if the file exists) 1095 if (_IsVesa()) 1096 _ReadVesaModeFile(fOriginal); 1097 1027 1098 fScreenMode.UpdateOriginalModes(); 1028 1099 } … … 1034 1105 if (_IsVesa()) { 1035 1106 (new BAlert("VesaAlert", 1036 " Your graphics card is not supported. Resolution changes will be"1037 " adopted on next system startup.\n", "Okay", NULL, NULL, B_WIDTH_AS_USUAL,1107 "Haiku is using your video card in safe mode (VESA)." 1108 " Your settings will be applied on next startup.\n", "Okay", NULL, NULL, B_WIDTH_AS_USUAL, 1038 1109 B_INFO_ALERT))->Go(NULL); 1039 1110 1040 1111 fVesaApplied = true; 1041 1112 fActive = fSelected; 1113 UpdateControls(); 1042 1114 return; 1043 1115 } -
haiku/trunk/src/preferences/screen/ScreenWindow.h
r20096 r24280 51 51 void Apply(); 52 52 53 bool CanApply() const;54 bool CanRevert() const;55 56 53 status_t _WriteVesaModeFile(const screen_mode& mode) const; 54 status_t _ReadVesaModeFile(screen_mode& mode) const; 57 55 bool _IsVesa() const { return fIsVesa; } 58 56
