From 02ed46b0de9b1e4f67ef3fc89886a526fa4fa5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 16 Nov 2005 10:29:06 +0000 Subject: [PATCH] * fixes the cursor handling after Axels changes, it crashed on real HW. Axel, I think you didn't realise that _CursorFrame() gave and invalid BRect for fCursorVisible=false, but that rect was used to create the backup area, so it was buggy at that place. I removed your checks for fCursorVisible in SetCursor() for cleaner code, but left it in MoveCursor() because it might save a few cycles. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14954 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/drawing/HWInterface.cpp | 36 ++++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/servers/app/drawing/HWInterface.cpp b/src/servers/app/drawing/HWInterface.cpp index 841db8ba89..98f9e5f953 100644 --- a/src/servers/app/drawing/HWInterface.cpp +++ b/src/servers/app/drawing/HWInterface.cpp @@ -48,18 +48,16 @@ HWInterface::SetCursor(ServerCursor* cursor) delete fCursor; delete fCursorAreaBackup; fCursor = cursor; - if (fCursorVisible) - Invalidate(oldFrame); + Invalidate(oldFrame); BRect r = _CursorFrame(); if (fCursor && !IsDoubleBuffered()) { - fCursorAreaBackup = new buffer_clip(r.IntegerWidth() + 1, - r.IntegerHeight() + 1); - if (fCursorVisible) - _DrawCursor(r); + BRect cursorBounds = fCursor->Bounds(); + fCursorAreaBackup = new buffer_clip(cursorBounds.IntegerWidth() + 1, + cursorBounds.IntegerHeight() + 1); + _DrawCursor(r); } else fCursorAreaBackup = NULL; - if (fCursorVisible) - Invalidate(r); + Invalidate(r); } WriteUnlock(); } @@ -99,13 +97,19 @@ HWInterface::MoveCursorTo(const float& x, const float& y) if (p != fCursorLocation) { BRect oldFrame = _CursorFrame(); fCursorLocation = p; - if (fCursorAreaBackup && fCursorVisible) { - // means we have a software cursor which we need to draw - _RestoreCursorArea(); - _DrawCursor(_CursorFrame()); + if (fCursorVisible) { + // Invalidate and _DrawCursor would not draw + // anything if the cursor is hidden + // (invalid cursor frame), but explicitly + // testing for it here saves us some cycles + if (fCursorAreaBackup) { + // means we have a software cursor which we need to draw + _RestoreCursorArea(); + _DrawCursor(_CursorFrame()); + } + Invalidate(oldFrame); + Invalidate(_CursorFrame()); } - Invalidate(oldFrame); - Invalidate(_CursorFrame()); } WriteUnlock(); } @@ -248,7 +252,7 @@ void HWInterface::_DrawCursor(BRect area) const { RenderingBuffer* backBuffer = DrawingBuffer(); - if (!backBuffer) + if (!backBuffer || !area.IsValid()) return; BRect cf = _CursorFrame(); @@ -289,7 +293,7 @@ HWInterface::_DrawCursor(BRect area) const uint8* dst = buffer; - if (fCursorAreaBackup) { + if (fCursorAreaBackup && fCursorAreaBackup->buffer) { //printf("backup: BRect(%ld, %ld, %ld, %ld)\n", left, top, right, bottom); fCursorAreaBackup->cursor_hidden = false; // remember which area the backup contains