Applied patch by Jan Klötzke with some changes by myself:

* The vesa driver/accelerant supports mode switching now. No special handling
  is needed anymore.
* Always write the vesa settings file to directly start with the right
  resolution regardless of the used graphics driver. Should save an additional
  mode switch while booting.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25795 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-06-03 18:59:12 +00:00
parent a2e19c60e2
commit 199893c3f3
2 changed files with 20 additions and 110 deletions
+19 -108
View File
@@ -216,8 +216,7 @@ stack_and_align_menu_fields(const BList& menuFields)
ScreenWindow::ScreenWindow(ScreenSettings *settings) ScreenWindow::ScreenWindow(ScreenSettings *settings)
: BWindow(settings->WindowFrame(), "Screen", B_TITLED_WINDOW, : BWindow(settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES), B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
fIsVesa(false), fBootWorkspaceApplied(false),
fVesaApplied(false),
fScreenMode(this), fScreenMode(this),
fTempScreenMode(this), fTempScreenMode(this),
fModified(false) fModified(false)
@@ -249,11 +248,8 @@ ScreenWindow::ScreenWindow(ScreenSettings *settings)
// TODO: since per workspace settings is unimplemented (Ticket #693) // TODO: since per workspace settings is unimplemented (Ticket #693)
// we force the menu to "All Workspaces" for now // we force the menu to "All Workspaces" for now
//if (_IsVesa()) { fAllWorkspacesItem->SetMarked(true);
fAllWorkspacesItem->SetMarked(true); item->SetEnabled(false);
item->SetEnabled(false);
//} else
// item->SetMarked(true);
popUpMenu->AddItem(item); popUpMenu->AddItem(item);
@@ -530,14 +526,16 @@ bool
ScreenWindow::QuitRequested() ScreenWindow::QuitRequested()
{ {
fSettings->SetWindowFrame(Frame()); fSettings->SetWindowFrame(Frame());
if (fVesaApplied) {
status_t status = _WriteVesaModeFile(fSelected); // Write mode of workspace 0 (the boot workspace) to the vesa settings file
screen_mode vesaMode;
if (fBootWorkspaceApplied && fScreenMode.Get(vesaMode, 0) == B_OK) {
status_t status = _WriteVesaModeFile(vesaMode);
if (status < B_OK) { if (status < B_OK) {
BString warning = "Could not write VESA mode settings file:\n\t"; BString warning = "Could not write VESA mode settings file:\n\t";
warning << strerror(status); warning << strerror(status);
(new BAlert("VesaAlert", warning.String(), "Okay", NULL, NULL, (new BAlert("VesaAlert", warning.String(), "Okay", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
} }
} }
@@ -766,8 +764,7 @@ ScreenWindow::_UpdateActiveMode()
// has been set manually; still, as the graphics driver // has been set manually; still, as the graphics driver
// is free to fiddle with mode passed, we better ask // is free to fiddle with mode passed, we better ask
// what kind of mode we actually got // what kind of mode we actually got
if (!fVesaApplied) fScreenMode.Get(fActive);
fScreenMode.Get(fActive);
fSelected = fActive; fSelected = fActive;
_UpdateControls(); _UpdateControls();
@@ -789,10 +786,8 @@ ScreenWindow::ScreenChanged(BRect frame, color_space mode)
void void
ScreenWindow::WorkspaceActivated(int32 workspace, bool state) ScreenWindow::WorkspaceActivated(int32 workspace, bool state)
{ {
if (!_IsVesa()) { fScreenMode.GetOriginalMode(fOriginal, workspace);
fScreenMode.GetOriginalMode(fOriginal, workspace); _UpdateActiveMode();
_UpdateActiveMode();
}
BMessage message(UPDATE_DESKTOP_COLOR_MSG); BMessage message(UPDATE_DESKTOP_COLOR_MSG);
PostMessage(&message, fMonitorView); PostMessage(&message, fMonitorView);
@@ -948,7 +943,7 @@ ScreenWindow::MessageReceived(BMessage* message)
case BUTTON_REVERT_MSG: case BUTTON_REVERT_MSG:
{ {
fModified = false; fModified = false;
fVesaApplied = false; fBootWorkspaceApplied = false;
BMenuItem *item; BMenuItem *item;
item = fWorkspaceCountField->Menu()->ItemAt(fOriginalWorkspaceCount - 1); item = fWorkspaceCountField->Menu()->ItemAt(fOriginalWorkspaceCount - 1);
if (item != NULL) if (item != NULL)
@@ -956,17 +951,9 @@ ScreenWindow::MessageReceived(BMessage* message)
// ScreenMode::Revert() assumes that we first set the correct number // ScreenMode::Revert() assumes that we first set the correct number
// of workspaces // of workspaces
set_workspace_count(fOriginalWorkspaceCount);
if (_IsVesa()) { fScreenMode.Revert();
set_workspace_count(fOriginalWorkspaceCount); _UpdateActiveMode();
fActive = fOriginal;
fSelected = fOriginal;
_UpdateControls();
} else {
set_workspace_count(fOriginalWorkspaceCount);
fScreenMode.Revert();
_UpdateActiveMode();
}
break; break;
} }
@@ -1018,68 +1005,6 @@ ScreenWindow::_WriteVesaModeFile(const screen_mode& mode) const
} }
status_t
ScreenWindow::_ReadVesaModeFile(screen_mode& mode) const
{
BPath path;
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
if (status < B_OK)
return status;
path.Append("kernel/drivers/vesa");
BFile file;
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status < B_OK)
return status;
char buffer[256];
ssize_t bytesRead = file.Read(buffer, sizeof(buffer) - 1);
if (bytesRead < B_OK) {
return bytesRead;
} else {
buffer[bytesRead] = '\0';
}
char ignore[256];
// if the file is malformed, sscanf shouldn't crash
// on reading a big string since we don't even read
// as much from the file
uint32 bitDepth = 0;
if (sscanf(buffer, "%s %ld %ld %ld", ignore, &mode.width, &mode.height,
&bitDepth) != 4) {
return B_ERROR;
}
// TODO: check for valid width and height values
switch (bitDepth) {
case 32:
mode.space = B_RGB32;
break;
case 24:
mode.space = B_RGB24;
break;
case 16:
mode.space = B_RGB16;
break;
case 15:
mode.space = B_RGB15;
break;
case 8:
mode.space = B_CMAP8;
break;
default:
// invalid value, we force it to B_RGB16 just in case
mode.space = B_RGB16;
return B_ERROR;
}
return B_OK;
}
void void
ScreenWindow::_CheckApplyEnabled() ScreenWindow::_CheckApplyEnabled()
{ {
@@ -1094,12 +1019,6 @@ ScreenWindow::_UpdateOriginal()
{ {
fOriginalWorkspaceCount = count_workspaces(); fOriginalWorkspaceCount = count_workspaces();
fScreenMode.Get(fOriginal); fScreenMode.Get(fOriginal);
// If we are in vesa we overwrite fOriginal's resolution and bitdepth
// with those found the vesa settings file. (if the file exists)
if (_IsVesa())
_ReadVesaModeFile(fOriginal);
fScreenMode.UpdateOriginalModes(); fScreenMode.UpdateOriginalModes();
} }
@@ -1107,18 +1026,6 @@ ScreenWindow::_UpdateOriginal()
void void
ScreenWindow::_Apply() ScreenWindow::_Apply()
{ {
if (_IsVesa()) {
(new BAlert("VesaAlert",
"Haiku is using your video card in compatibility mode (VESA)."
" Your settings will be applied on next startup.\n", "Okay", NULL, NULL, B_WIDTH_AS_USUAL,
B_INFO_ALERT))->Go(NULL);
fVesaApplied = true;
fActive = fSelected;
_UpdateControls();
return;
}
// make checkpoint, so we can undo these changes // make checkpoint, so we can undo these changes
fTempScreenMode.UpdateOriginalModes(); fTempScreenMode.UpdateOriginalModes();
status_t status = fScreenMode.Set(fSelected); status_t status = fScreenMode.Set(fSelected);
@@ -1136,6 +1043,10 @@ ScreenWindow::_Apply()
if (i != originatingWorkspace) if (i != originatingWorkspace)
screen.SetMode(i, &newMode, true); screen.SetMode(i, &newMode, true);
} }
fBootWorkspaceApplied = true;
} else {
if (current_workspace() == 0)
fBootWorkspaceApplied = true;
} }
fActive = fSelected; fActive = fSelected;
+1 -2
View File
@@ -51,7 +51,6 @@ class ScreenWindow : public BWindow {
void _Apply(); void _Apply();
status_t _WriteVesaModeFile(const screen_mode& mode) const; status_t _WriteVesaModeFile(const screen_mode& mode) const;
status_t _ReadVesaModeFile(screen_mode& mode) const;
bool _IsVesa() const { return fIsVesa; } bool _IsVesa() const { return fIsVesa; }
void _LayoutControls(uint32 flags); void _LayoutControls(uint32 flags);
@@ -59,7 +58,7 @@ class ScreenWindow : public BWindow {
ScreenSettings* fSettings; ScreenSettings* fSettings;
bool fIsVesa; bool fIsVesa;
bool fVesaApplied; bool fBootWorkspaceApplied;
BBox* fScreenBox; BBox* fScreenBox;
BBox* fControlsBox; BBox* fControlsBox;