* VirtualScreen::RestoreConfiguration() now also takes care of collecting the

screens that actually changed their resolution, which simplifies the code
  in Desktop considerably.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32537 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-08-20 09:45:54 +00:00
parent 0d1d2de59b
commit 02b6c95990
3 changed files with 56 additions and 17 deletions
+12 -11
View File
@@ -930,6 +930,7 @@ Desktop::SetWorkspace(int32 index)
_SendFakeMouseMoved(); _SendFakeMouseMoved();
} }
/*! Changes the current workspace to the one specified by \a index. /*! Changes the current workspace to the one specified by \a index.
You must hold the all window lock when calling this method. You must hold the all window lock when calling this method.
*/ */
@@ -996,18 +997,18 @@ Desktop::_SetWorkspace(int32 index)
fPreviousWorkspace = fCurrentWorkspace; fPreviousWorkspace = fCurrentWorkspace;
fCurrentWorkspace = index; fCurrentWorkspace = index;
// Change the display mode, if needed // Change the display modes, if needed
// TODO: this needs to be done for all screens
display_mode previousMode, newMode;
fVirtualScreen.ScreenAt(0)->GetMode(&previousMode);
fVirtualScreen.RestoreConfiguration(*this,
fSettings->WorkspacesMessage(index));
fVirtualScreen.ScreenAt(0)->GetMode(&newMode);
// We only need to invalidate the entire desktop if we changed display modes
if (memcmp(&previousMode, &newMode, sizeof(display_mode)))
ScreenChanged(fVirtualScreen.ScreenAt(0), false);
// show windows, and include them in the changed region - but only uint32 changedScreens;
fVirtualScreen.RestoreConfiguration(*this,
fSettings->WorkspacesMessage(index), &changedScreens);
for (int32 i = 0; changedScreens != 0; i++, changedScreens /= 2) {
if ((changedScreens & (1 << i)) != 0)
ScreenChanged(fVirtualScreen.ScreenAt(i), false);
}
// Show windows, and include them in the changed region - but only
// those that were not visible before (or whose position changed) // those that were not visible before (or whose position changed)
WindowList windows(kWorkingList); WindowList windows(kWorkingList);
+42 -5
View File
@@ -53,8 +53,33 @@ VirtualScreen::_Reset()
status_t status_t
VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings) VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings,
uint32* _changedScreens)
{ {
// Remember previous screen modes
typedef std::map<Screen*, display_mode> ScreenModeMap;
ScreenModeMap previousModes;
bool previousModesFailed = false;
if (_changedScreens != NULL) {
*_changedScreens = 0;
try {
for (int32 i = 0; i < fScreenList.CountItems(); i++) {
Screen* screen = fScreenList.ItemAt(i)->screen;
display_mode mode;
screen->GetMode(&mode);
previousModes.insert(std::make_pair(screen, mode));
}
} catch (...) {
previousModesFailed = true;
*_changedScreens = ~0L;
}
}
_Reset(); _Reset();
// Copy current Desktop workspace settings // Copy current Desktop workspace settings
@@ -64,7 +89,7 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings)
ScreenList list; ScreenList list;
status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0, false, status_t status = gScreenManager->AcquireScreens(&desktop, NULL, 0, false,
list); list);
if (status < B_OK) { if (status != B_OK) {
// TODO: we would try again here with force == true // TODO: we would try again here with force == true
return status; return status;
} }
@@ -73,6 +98,17 @@ VirtualScreen::RestoreConfiguration(Desktop& desktop, const BMessage* settings)
Screen* screen = list.ItemAt(i); Screen* screen = list.ItemAt(i);
AddScreen(screen); AddScreen(screen);
if (!previousModesFailed && _changedScreens != NULL) {
// Figure out which screens have changed their mode
display_mode mode;
screen->GetMode(&mode);
ScreenModeMap::const_iterator found = previousModes.find(screen);
if (found != previousModes.end()
&& memcmp(&mode, &found->second, sizeof(display_mode)))
*_changedScreens |= 1 << i;
}
} }
return B_OK; return B_OK;
@@ -147,11 +183,12 @@ VirtualScreen::AddScreen(Screen* screen)
status = screen->SetMode(*mode, true); status = screen->SetMode(*mode, true);
// TODO: named settings will get lost if setting the mode failed! // TODO: named settings will get lost if setting the mode failed!
} }
if (status < B_OK) { if (status != B_OK) {
// TODO: more intelligent standard mode (monitor preference, desktop default, ...)
status_t status = screen->SetPreferredMode(); status_t status = screen->SetPreferredMode();
if (status != B_OK) if (status != B_OK) {
// TODO: more intelligent standard mode (desktop default, ...)
status = screen->SetBestMode(1024, 768, B_RGB32, 60.f); status = screen->SetBestMode(1024, 768, B_RGB32, 60.f);
}
if (status != B_OK) if (status != B_OK)
screen->SetBestMode(800, 600, B_RGB32, 60.f, false); screen->SetBestMode(800, 600, B_RGB32, 60.f, false);
} }
+2 -1
View File
@@ -32,7 +32,8 @@ class VirtualScreen {
{ return fHWInterface; } { return fHWInterface; }
status_t RestoreConfiguration(Desktop& desktop, status_t RestoreConfiguration(Desktop& desktop,
const BMessage* settings); const BMessage* settings,
uint32* _changedScreens = NULL);
status_t StoreConfiguration(BMessage& settings); status_t StoreConfiguration(BMessage& settings);
status_t AddScreen(Screen* screen); status_t AddScreen(Screen* screen);