Changeset 24280

Show
Ignore:
Timestamp:
03/06/08 15:17:20 (9 months ago)
Author:
aldeck
Message:

* as discussed on the dev list, fixed revert and apply behaviour (tested
under vesa and supported mode). Changed message of the vesa warning
alert. TODO: additional warning text (see discussion)
* apply now stays deactivated if you only change the workspace count as
it is applied instantly already.
* disabled current workspace menu item for now since it is not
implemented. see ticket #696

Location:
haiku/trunk/src/preferences/screen
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/preferences/screen/ScreenWindow.cpp

    r22734 r24280  
    11/* 
    2  * Copyright 2001-2007, Haiku. 
     2 * Copyright 2001-2008, Haiku. 
    33 * Distributed under the terms of the MIT License. 
    44 * 
     
    1010 *              Axel Dörfler, axeld@pinc-software.de 
    1111 *              Stephan Aßmus <superstippi@gmx.de> 
     12 *              Alexandre Deckner, alex@zappotek.com 
    1213 */ 
    1314 
     
    246247        BMenuItem *item = new BMenuItem("Current Workspace", 
    247248                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()) { 
    249253                fAllWorkspacesItem->SetMarked(true); 
    250254                item->SetEnabled(false); 
    251         } else 
    252                 item->SetMarked(true); 
     255        //} else 
     256        //      item->SetMarked(true); 
     257                 
    253258        popUpMenu->AddItem(item); 
    254259 
     
    347352        float min, max; 
    348353        if (fScreenMode.GetRefreshLimits(fActive, min, max) && min == max) { 
     354                // TODO: investigate, doesn't work for VESA at least 
     355                 
    349356                // This is a special case for drivers that only support a single 
    350357                // frequency, like the VESA driver 
     
    779786ScreenWindow::WorkspaceActivated(int32 workspace, bool state) 
    780787{ 
    781         fScreenMode.GetOriginalMode(fOriginal, workspace); 
    782         UpdateActiveMode(); 
     788        if (!_IsVesa()) { 
     789                fScreenMode.GetOriginalMode(fOriginal, workspace); 
     790                UpdateActiveMode(); 
     791        } 
    783792         
    784793        BMessage message(UPDATE_DESKTOP_COLOR_MSG); 
     
    936945                { 
    937946                        fModified = false; 
     947                        fVesaApplied = false; 
    938948                        BMenuItem *item; 
    939949                        item = fWorkspaceCountField->Menu()->ItemAt(fOriginalWorkspaceCount - 1); 
     
    943953                        // ScreenMode::Revert() assumes that we first set the correct number 
    944954                        // 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                        }                        
    948966                        break; 
    949967                } 
     
    9971015 
    9981016 
    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; 
     1017status_t 
     1018ScreenWindow::_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        } 
    10111076} 
    10121077 
     
    10151080ScreenWindow::CheckApplyEnabled() 
    10161081{ 
    1017         fApplyButton->SetEnabled(CanApply()); 
    1018         fRevertButton->SetEnabled(CanRevert()); 
     1082        fApplyButton->SetEnabled(fSelected != fActive); 
     1083        fRevertButton->SetEnabled(count_workspaces() != fOriginalWorkspaceCount || fSelected != fOriginal); 
    10191084} 
    10201085 
     
    10251090        fOriginalWorkspaceCount = count_workspaces(); 
    10261091        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 
    10271098        fScreenMode.UpdateOriginalModes(); 
    10281099} 
     
    10341105        if (_IsVesa()) { 
    10351106                (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,                       
    10381109                        B_INFO_ALERT))->Go(NULL); 
    10391110 
    10401111                fVesaApplied = true; 
    10411112                fActive = fSelected; 
     1113                UpdateControls();                
    10421114                return; 
    10431115        } 
  • haiku/trunk/src/preferences/screen/ScreenWindow.h

    r20096 r24280  
    5151                void Apply(); 
    5252 
    53                 bool CanApply() const; 
    54                 bool CanRevert() const; 
    55  
    5653                status_t _WriteVesaModeFile(const screen_mode& mode) const; 
     54                status_t _ReadVesaModeFile(screen_mode& mode) const;             
    5755                bool _IsVesa() const { return fIsVesa; } 
    5856