* BPrivateScreen used B_CURRENT_WORKSPACE where an index was required. This
was reason that caused bug #2658. * Introduced a new constant B_CURRENT_WORKSPACE_INDEX in PrivateScreen.h; maybe this should be made public one day. * Fixed another reason that caused bug #2658: BPrivateScreen waited 100ms between frame updates, leaving a large window open for such problems; I've reduced it to 10ms now, but the actual bug fix is to reset the counter for each BScreen object, so that when you create a new BScreen object, the frame is retrieved timely. * The reference count was not initialized, causing BPrivateScreens to be leaked forever. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32557 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
static BObjectList<BPrivateScreen> sScreens(2, true);
|
static BObjectList<BPrivateScreen> sScreens(2, true);
|
||||||
|
|
||||||
// used to synchronize creation/deletion of the sScreen object
|
// used to synchronize creation/deletion of the sScreen object
|
||||||
@@ -159,7 +160,7 @@ color_space
|
|||||||
BPrivateScreen::ColorSpace()
|
BPrivateScreen::ColorSpace()
|
||||||
{
|
{
|
||||||
display_mode mode;
|
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 (color_space)mode.space;
|
||||||
|
|
||||||
return B_NO_COLOR_SPACE;
|
return B_NO_COLOR_SPACE;
|
||||||
@@ -171,10 +172,10 @@ BPrivateScreen::Frame()
|
|||||||
{
|
{
|
||||||
// If something goes wrong, we just return this rectangle.
|
// If something goes wrong, we just return this rectangle.
|
||||||
|
|
||||||
if (system_time() > fLastUpdate + 100000) {
|
if (system_time() > fLastUpdate + 10000) {
|
||||||
// invalidate the settings after 0.1 secs
|
// invalidate the settings after 10 msecs
|
||||||
display_mode mode;
|
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,
|
fFrame.Set(0, 0, (float)mode.virtual_width - 1,
|
||||||
(float)mode.virtual_height - 1);
|
(float)mode.virtual_height - 1);
|
||||||
fLastUpdate = system_time();
|
fLastUpdate = system_time();
|
||||||
@@ -649,6 +650,23 @@ BPrivateScreen::BytesPerRow()
|
|||||||
// #pragma mark - private methods
|
// #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
|
sem_id
|
||||||
BPrivateScreen::_RetraceSemaphore()
|
BPrivateScreen::_RetraceSemaphore()
|
||||||
{
|
{
|
||||||
@@ -687,6 +705,7 @@ BPrivateScreen::_GetFrameBufferConfig(frame_buffer_config& config)
|
|||||||
BPrivateScreen::BPrivateScreen(int32 id)
|
BPrivateScreen::BPrivateScreen(int32 id)
|
||||||
:
|
:
|
||||||
fID(id),
|
fID(id),
|
||||||
|
fReferenceCount(0),
|
||||||
fColorMap(NULL),
|
fColorMap(NULL),
|
||||||
fRetraceSem(-1),
|
fRetraceSem(-1),
|
||||||
fRetraceSemValid(false),
|
fRetraceSemValid(false),
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ class BApplication;
|
|||||||
class BWindow;
|
class BWindow;
|
||||||
|
|
||||||
|
|
||||||
|
#define B_CURRENT_WORKSPACE_INDEX (~0L)
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class BPrivateScreen {
|
class BPrivateScreen {
|
||||||
@@ -88,8 +91,8 @@ private:
|
|||||||
BPrivateScreen(int32 id);
|
BPrivateScreen(int32 id);
|
||||||
~BPrivateScreen();
|
~BPrivateScreen();
|
||||||
|
|
||||||
void _Acquire() { fRefCount++; }
|
void _Acquire();
|
||||||
bool _Release() { return --fRefCount == 0; }
|
bool _Release();
|
||||||
|
|
||||||
sem_id _RetraceSemaphore();
|
sem_id _RetraceSemaphore();
|
||||||
status_t _GetFrameBufferConfig(
|
status_t _GetFrameBufferConfig(
|
||||||
@@ -100,7 +103,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int32 fID;
|
int32 fID;
|
||||||
int32 fRefCount;
|
int32 fReferenceCount;
|
||||||
color_map* fColorMap;
|
color_map* fColorMap;
|
||||||
sem_id fRetraceSem;
|
sem_id fRetraceSem;
|
||||||
bool fRetraceSemValid;
|
bool fRetraceSemValid;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! BScreen lets you retrieve and change the display settings. */
|
/*! BScreen lets you retrieve and change the display settings. */
|
||||||
|
|
||||||
|
|
||||||
@@ -15,11 +16,10 @@
|
|||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kCurrentWorkspaceIndex = ~0;
|
|
||||||
|
|
||||||
/*! \brief Creates a BScreen object which represents the display with the given
|
/*! \brief Creates a BScreen object which represents the display with the given
|
||||||
screen_id
|
screen_id
|
||||||
\param id The screen_id of the screen to get.
|
\param id The screen_id of the screen to get.
|
||||||
@@ -250,7 +250,7 @@ rgb_color
|
|||||||
BScreen::DesktopColor()
|
BScreen::DesktopColor()
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->DesktopColor(kCurrentWorkspaceIndex);
|
return fScreen->DesktopColor(B_CURRENT_WORKSPACE_INDEX);
|
||||||
|
|
||||||
return rgb_color();
|
return rgb_color();
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ void
|
|||||||
BScreen::SetDesktopColor(rgb_color rgb, bool stick)
|
BScreen::SetDesktopColor(rgb_color rgb, bool stick)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
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)
|
BScreen::GetMode(display_mode* mode)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->GetMode(kCurrentWorkspaceIndex, mode);
|
return fScreen->GetMode(B_CURRENT_WORKSPACE_INDEX, mode);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Copies the current display_mode of the given workspace into mode.
|
/*! \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,
|
\param mode A pointer to a display_mode structure,
|
||||||
where the current display_mode will be copied.
|
where the current display_mode will be copied.
|
||||||
\return \c B_OK if the operation was succesful.
|
\return \c B_OK if the operation was succesful.
|
||||||
@@ -373,13 +374,13 @@ status_t
|
|||||||
BScreen::SetMode(display_mode* mode, bool makeDefault)
|
BScreen::SetMode(display_mode* mode, bool makeDefault)
|
||||||
{
|
{
|
||||||
if (fScreen != NULL)
|
if (fScreen != NULL)
|
||||||
return fScreen->SetMode(kCurrentWorkspaceIndex, mode, makeDefault);
|
return fScreen->SetMode(B_CURRENT_WORKSPACE_INDEX, mode, makeDefault);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Set the given workspace to the given mode.
|
/*! \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 mode A pointer to a display_mode.
|
||||||
\param makeDefault If true, the mode becomes the default for the workspace.
|
\param makeDefault If true, the mode becomes the default for the workspace.
|
||||||
\return \c B_OK.
|
\return \c B_OK.
|
||||||
|
|||||||
Reference in New Issue
Block a user