diff --git a/src/kits/interface/PrivateScreen.cpp b/src/kits/interface/PrivateScreen.cpp index d3e80df7c7..6ef3188ecb 100644 --- a/src/kits/interface/PrivateScreen.cpp +++ b/src/kits/interface/PrivateScreen.cpp @@ -31,6 +31,7 @@ using namespace BPrivate; + static BObjectList sScreens(2, true); // used to synchronize creation/deletion of the sScreen object @@ -159,7 +160,7 @@ color_space BPrivateScreen::ColorSpace() { display_mode mode; - if (GetMode(B_CURRENT_WORKSPACE, &mode) == B_OK) + if (GetMode(B_CURRENT_WORKSPACE_INDEX, &mode) == B_OK) return (color_space)mode.space; return B_NO_COLOR_SPACE; @@ -171,10 +172,10 @@ BPrivateScreen::Frame() { // If something goes wrong, we just return this rectangle. - if (system_time() > fLastUpdate + 100000) { - // invalidate the settings after 0.1 secs + if (system_time() > fLastUpdate + 10000) { + // invalidate the settings after 10 msecs display_mode mode; - if (GetMode(B_CURRENT_WORKSPACE, &mode) == B_OK) { + if (GetMode(B_CURRENT_WORKSPACE_INDEX, &mode) == B_OK) { fFrame.Set(0, 0, (float)mode.virtual_width - 1, (float)mode.virtual_height - 1); fLastUpdate = system_time(); @@ -649,6 +650,23 @@ BPrivateScreen::BytesPerRow() // #pragma mark - private methods +void +BPrivateScreen::_Acquire() +{ + fReferenceCount++; + + fLastUpdate = 0; + // force an update for the new BScreen object +} + + +bool +BPrivateScreen::_Release() +{ + return --fReferenceCount == 0; +} + + sem_id BPrivateScreen::_RetraceSemaphore() { @@ -687,6 +705,7 @@ BPrivateScreen::_GetFrameBufferConfig(frame_buffer_config& config) BPrivateScreen::BPrivateScreen(int32 id) : fID(id), + fReferenceCount(0), fColorMap(NULL), fRetraceSem(-1), fRetraceSemValid(false), diff --git a/src/kits/interface/PrivateScreen.h b/src/kits/interface/PrivateScreen.h index 1c4a27f512..d3e64eff12 100644 --- a/src/kits/interface/PrivateScreen.h +++ b/src/kits/interface/PrivateScreen.h @@ -22,6 +22,9 @@ class BApplication; class BWindow; +#define B_CURRENT_WORKSPACE_INDEX (~0L) + + namespace BPrivate { class BPrivateScreen { @@ -88,8 +91,8 @@ private: BPrivateScreen(int32 id); ~BPrivateScreen(); - void _Acquire() { fRefCount++; } - bool _Release() { return --fRefCount == 0; } + void _Acquire(); + bool _Release(); sem_id _RetraceSemaphore(); status_t _GetFrameBufferConfig( @@ -100,7 +103,7 @@ private: private: int32 fID; - int32 fRefCount; + int32 fReferenceCount; color_map* fColorMap; sem_id fRetraceSem; bool fRetraceSemValid; diff --git a/src/kits/interface/Screen.cpp b/src/kits/interface/Screen.cpp index 688a73a16b..0ebc403378 100644 --- a/src/kits/interface/Screen.cpp +++ b/src/kits/interface/Screen.cpp @@ -7,6 +7,7 @@ * Axel Dörfler, axeld@pinc-software.de */ + /*! BScreen lets you retrieve and change the display settings. */ @@ -15,11 +16,10 @@ #include #include + using namespace BPrivate; -static const uint32 kCurrentWorkspaceIndex = ~0; - /*! \brief Creates a BScreen object which represents the display with the given screen_id \param id The screen_id of the screen to get. @@ -250,7 +250,7 @@ rgb_color BScreen::DesktopColor() { if (fScreen != NULL) - return fScreen->DesktopColor(kCurrentWorkspaceIndex); + return fScreen->DesktopColor(B_CURRENT_WORKSPACE_INDEX); return rgb_color(); } @@ -280,7 +280,7 @@ void BScreen::SetDesktopColor(rgb_color rgb, bool stick) { if (fScreen != NULL) - fScreen->SetDesktopColor(rgb, kCurrentWorkspaceIndex, stick); + fScreen->SetDesktopColor(rgb, B_CURRENT_WORKSPACE_INDEX, stick); } @@ -345,12 +345,13 @@ status_t BScreen::GetMode(display_mode* mode) { if (fScreen != NULL) - return fScreen->GetMode(kCurrentWorkspaceIndex, mode); + return fScreen->GetMode(B_CURRENT_WORKSPACE_INDEX, mode); return B_ERROR; } /*! \brief Copies the current display_mode of the given workspace into mode. + \param workspace The index of the workspace to query. \param mode A pointer to a display_mode structure, where the current display_mode will be copied. \return \c B_OK if the operation was succesful. @@ -373,13 +374,13 @@ status_t BScreen::SetMode(display_mode* mode, bool makeDefault) { if (fScreen != NULL) - return fScreen->SetMode(kCurrentWorkspaceIndex, mode, makeDefault); + return fScreen->SetMode(B_CURRENT_WORKSPACE_INDEX, mode, makeDefault); return B_ERROR; } /*! \brief Set the given workspace to the given mode. - \param workspace The workspace that you want to change. + \param workspace The index of the workspace that you want to change. \param mode A pointer to a display_mode. \param makeDefault If true, the mode becomes the default for the workspace. \return \c B_OK.