* Fixed a little bug that caused unnecessary mode changes when pressing Revert.

* Fixed compilation under R5.
* Made Revert more user-friendly by also allowing to revert settings to the previously active state after having pressed Apply. This only works if you didn't make new changes in the meantime. In that case, only the new changes will be reverted.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20031 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Waldemar Kornewald 2007-02-01 21:36:50 +00:00
parent 24a0bfcb01
commit a40498e2b2
3 changed files with 38 additions and 10 deletions

View File

@ -17,6 +17,14 @@
#include <Screen.h>
#ifndef __HAIKU__
inline bool operator!=(const rgb_color& x, const rgb_color& y)
{
return (x.red!=y.red || x.blue!=y.blue || x.green!=y.green);
}
#endif
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
fWidth(width),

View File

@ -219,7 +219,7 @@ ScreenMode::Revert()
return B_OK;
screen_mode current;
if (Get(current) && fOriginal == current)
if (Get(current) == B_OK && fOriginal == current)
return B_OK;
BScreen screen(fWindow);

View File

@ -801,8 +801,11 @@ ScreenWindow::MessageReceived(BMessage* message)
case POP_RESOLUTION_MSG:
{
int32 oldWidth = fSelected.width, oldHeight = fSelected.height;
message->FindInt32("width", &fSelected.width);
message->FindInt32("height", &fSelected.height);
if (fSelected.width == oldWidth && fSelected.height == oldHeight)
break;
CheckColorMenu();
CheckRefreshMenu();
@ -810,29 +813,44 @@ ScreenWindow::MessageReceived(BMessage* message)
UpdateMonitorView();
UpdateRefreshControl();
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled();
break;
}
case POP_COLORS_MSG:
{
color_space old = fSelected.space;
message->FindInt32("space", (int32 *)&fSelected.space);
if (fSelected.space == old)
break;
BString string;
string << fSelected.BitsPerPixel() << " Bits/Pixel";
fColorsMenu->Superitem()->SetLabel(string.String());
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled();
break;
}
case POP_REFRESH_MSG:
{
float old = fSelected.refresh;
message->FindFloat("refresh", &fSelected.refresh);
fOtherRefresh->SetLabel("Other" B_UTF8_ELLIPSIS);
// revert "Other…" label - it might have had a refresh rate prefix
if (fSelected.refresh == old)
break;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
CheckApplyEnabled();
break;
}
case POP_OTHER_REFRESH_MSG:
{
@ -856,8 +874,13 @@ ScreenWindow::MessageReceived(BMessage* message)
{
// user pressed "done" in "Other…" refresh dialog;
// select the refresh rate chosen
float old = fSelected.refresh;
message->FindFloat("refresh", &fSelected.refresh);
if (fSelected.refresh != old)
break;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
UpdateRefreshControl();
CheckApplyEnabled();
break;
@ -909,6 +932,8 @@ ScreenWindow::MessageReceived(BMessage* message)
fSelected.use_laptop_panel = false;
fSelected.tv_standard = 0;
fScreenMode.Get(fOriginal);
fScreenMode.UpdateOriginalMode();
UpdateControls();
break;
}
@ -959,7 +984,6 @@ ScreenWindow::MessageReceived(BMessage* message)
fChangingAllWorkspaces = false;
}
fScreenMode.UpdateOriginalMode();
UpdateActiveMode();
break;
}
@ -1005,20 +1029,16 @@ ScreenWindow::_WriteVesaModeFile(const screen_mode& mode) const
bool
ScreenWindow::CanApply() const
{
if (fAllWorkspacesItem->IsMarked())
return true;
return fSelected != fActive;
return fAllWorkspacesItem->IsMarked() || fSelected != fOriginal
|| fSelected != fActive;
}
bool
ScreenWindow::CanRevert() const
{
if (fActive != fOriginal)
return true;
return CanApply();
return (fActive != fOriginal && !fAllWorkspacesItem->IsMarked())
|| fSelected != fActive;
}