tried to find the bug that causes the wrong area underneath the software cursor to be restored, but failed, the only accomplishment is that the cursor is now showing right from the beginning, not only after one moves the mouse

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13702 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-07-16 22:52:28 +00:00
parent c18d3059b4
commit 95e42caf13
2 changed files with 24 additions and 37 deletions
+21 -35
View File
@@ -14,7 +14,6 @@
HWInterface::HWInterface(bool doubleBuffered) HWInterface::HWInterface(bool doubleBuffered)
: MultiLocker("hw interface lock"), : MultiLocker("hw interface lock"),
fCursorAreaBackup(NULL), fCursorAreaBackup(NULL),
fSoftwareCursorHidden(false),
fCursor(NULL), fCursor(NULL),
fCursorVisible(true), fCursorVisible(true),
fCursorLocation(0, 0), fCursorLocation(0, 0),
@@ -98,7 +97,8 @@ HWInterface::MoveCursorTo(const float& x, const float& y)
BRect oldFrame = _CursorFrame(); BRect oldFrame = _CursorFrame();
fCursorLocation = p; fCursorLocation = p;
if (fCursorAreaBackup) { if (fCursorAreaBackup) {
_RestoreCursorArea(oldFrame); // means we have a software cursor which we need to draw
_RestoreCursorArea();
_DrawCursor(_CursorFrame()); _DrawCursor(_CursorFrame());
} }
Invalidate(oldFrame); Invalidate(oldFrame);
@@ -204,16 +204,15 @@ HWInterface::CopyBackToFront(const BRect& frame)
void void
HWInterface::HideSoftwareCursor(const BRect& area) HWInterface::HideSoftwareCursor(const BRect& area)
{ {
if (fCursorAreaBackup && !fSoftwareCursorHidden) { if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
BRect backupArea(fCursorAreaBackup->left, BRect backupArea(fCursorAreaBackup->left,
fCursorAreaBackup->top, fCursorAreaBackup->top,
fCursorAreaBackup->right, fCursorAreaBackup->right,
fCursorAreaBackup->bottom); fCursorAreaBackup->bottom);
if (area.Intersects(backupArea)) { if (area.Intersects(backupArea)) {
//printf("HideSoftwareCursor(BRect(%.1, %.1, %.1, %.1))\n", area.left, area.top, area.right, area.bottom); //printf("HideSoftwareCursor(BRect(%.1f, %.1f, %.1f, %.1f))\n", area.left, area.top, area.right, area.bottom);
//backupArea.PrintToStream(); //backupArea.PrintToStream();
_RestoreCursorArea(backupArea); _RestoreCursorArea();
fSoftwareCursorHidden = true;
} }
} }
} }
@@ -222,24 +221,17 @@ HWInterface::HideSoftwareCursor(const BRect& area)
void void
HWInterface::HideSoftwareCursor() HWInterface::HideSoftwareCursor()
{ {
if (fCursorAreaBackup && !fSoftwareCursorHidden) {
//printf("HideSoftwareCursor()\n"); //printf("HideSoftwareCursor()\n");
_RestoreCursorArea(BRect(fCursorAreaBackup->left, _RestoreCursorArea();
fCursorAreaBackup->top,
fCursorAreaBackup->right,
fCursorAreaBackup->bottom));
fSoftwareCursorHidden = true;
}
} }
// ShowSoftwareCursor // ShowSoftwareCursor
void void
HWInterface::ShowSoftwareCursor() HWInterface::ShowSoftwareCursor()
{ {
if (fCursorAreaBackup && fSoftwareCursorHidden) { if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) {
//printf("ShowSoftwareCursor()\n"); //printf("ShowSoftwareCursor()\n");
_DrawCursor(_CursorFrame()); _DrawCursor(_CursorFrame());
fSoftwareCursorHidden = false;
} }
} }
@@ -295,6 +287,8 @@ HWInterface::_DrawCursor(BRect area) const
uint8* dst = buffer; uint8* dst = buffer;
if (fCursorAreaBackup) { if (fCursorAreaBackup) {
//printf("backup: BRect(%ld, %ld, %ld, %ld)\n", left, top, right, bottom);
fCursorAreaBackup->cursor_hidden = false;
// remember which area the backup contains // remember which area the backup contains
fCursorAreaBackup->left = left; fCursorAreaBackup->left = left;
fCursorAreaBackup->top = top; fCursorAreaBackup->top = top;
@@ -478,7 +472,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
dst += dstBPR; dst += dstBPR;
src += srcBPR; src += srcBPR;
} }
} } else
printf("nothing to copy\n");
break; break;
} }
// NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap() // NOTE: on R5, B_RGB24 bitmaps are not supported by DrawBitmap()
@@ -609,27 +604,18 @@ HWInterface::_CursorFrame() const
// _RestoreCursorArea // _RestoreCursorArea
void void
HWInterface::_RestoreCursorArea(const BRect& area) const HWInterface::_RestoreCursorArea() const
{ {
if (fCursorAreaBackup) { if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
//printf("restore\n");
_CopyToFront(fCursorAreaBackup->buffer,
fCursorAreaBackup->bpr,
fCursorAreaBackup->left,
fCursorAreaBackup->top,
fCursorAreaBackup->right,
fCursorAreaBackup->bottom);
// clip backup area against "area" fCursorAreaBackup->cursor_hidden = true;
int32 left = max_c((int32)area.left, fCursorAreaBackup->left);
int32 top = max_c((int32)area.top, fCursorAreaBackup->top);
int32 right = min_c((int32)area.right, fCursorAreaBackup->right);
int32 bottom = min_c((int32)area.bottom, fCursorAreaBackup->bottom);
if (left <= right && top <= bottom) {
uint8* src = fCursorAreaBackup->buffer;
if (fCursorAreaBackup->left < left)
src += (left - fCursorAreaBackup->left) * 4;
if (fCursorAreaBackup->top < top)
src += (top - fCursorAreaBackup->top) * fCursorAreaBackup->bpr;
_CopyToFront(src, fCursorAreaBackup->bpr,
left, top, right, bottom);
}
} }
} }
+3 -2
View File
@@ -117,7 +117,7 @@ class HWInterface : public MultiLocker {
int32 right, int32 bottom) const; int32 right, int32 bottom) const;
BRect _CursorFrame() const; BRect _CursorFrame() const;
void _RestoreCursorArea(const BRect& frame) const; void _RestoreCursorArea() const;
// If we draw the cursor somewhere in the drawing buffer, // If we draw the cursor somewhere in the drawing buffer,
// we need to backup its contents before drawing, so that // we need to backup its contents before drawing, so that
@@ -135,6 +135,7 @@ class HWInterface : public MultiLocker {
top = 0; top = 0;
right = -1; right = -1;
bottom = -1; bottom = -1;
cursor_hidden = true;
} }
~buffer_clip() ~buffer_clip()
{ {
@@ -146,10 +147,10 @@ class HWInterface : public MultiLocker {
int32 right; int32 right;
int32 bottom; int32 bottom;
int32 bpr; int32 bpr;
bool cursor_hidden;
}; };
buffer_clip* fCursorAreaBackup; buffer_clip* fCursorAreaBackup;
bool fSoftwareCursorHidden;
ServerCursor* fCursor; ServerCursor* fCursor;
bool fCursorVisible; bool fCursorVisible;