diff --git a/apps/shared/round_cursor_view.cpp b/apps/shared/round_cursor_view.cpp index 10b14e86b..74661c644 100644 --- a/apps/shared/round_cursor_view.cpp +++ b/apps/shared/round_cursor_view.cpp @@ -66,11 +66,40 @@ bool RoundCursorView::eraseCursorIfPossible() { return false; } // Erase the cursor - KDColor cursorWorkingBuffer[Dots::LargeDotDiameter*Dots::LargeDotDiameter]; + KDColor cursorWorkingBuffer[k_cursorSize * k_cursorSize]; KDContext * ctx = KDIonContext::sharedContext(); ctx->setOrigin(currentFrame.origin()); ctx->setClippingRect(currentFrame); - ctx->fillRectWithPixels(KDRect(0,0,k_cursorSize, k_cursorSize), m_underneathPixelBuffer, cursorWorkingBuffer); + KDSize cursorSize = KDSize(k_cursorSize, k_cursorSize); + + /* We assert that the visible frame is not cropped (indeed a cursor is always + * fully inside the window, thanks to panToMakeCursorVisible). Otherwise, we + * would need to change this algorithm. + * + * +---+ + * | |<- frame m_underneathPixelBuffer: +---+ + * +----+---+--------+ |000| + * | |xxx| |<- parentVisibleFrame |xxx| + * | +---+ | +---+ + * | | + * +-----------------+ + * + * +---+ + * |xxx|: absoluteVisibleFrame + * +---+ + * + * What we would draw with the current algorithm: + * +---+ + * | |<- frame + * +----+---+--------+ + * | |000| |<- parentVisibleFrame + * | +---+ | + * | | + * +-----------------+ + * + * */ + assert(currentFrame.size() == cursorSize); + ctx->fillRectWithPixels(KDRect(0, 0, cursorSize), m_underneathPixelBuffer, cursorWorkingBuffer); // TODO Restore the context to previous values? return true; } diff --git a/kandinsky/include/kandinsky/size.h b/kandinsky/include/kandinsky/size.h index 970b4f071..875719de4 100644 --- a/kandinsky/include/kandinsky/size.h +++ b/kandinsky/include/kandinsky/size.h @@ -9,6 +9,9 @@ public: m_width(width), m_height(height) {} constexpr KDCoordinate width() const { return m_width; } constexpr KDCoordinate height() const { return m_height; } + bool operator==(const KDSize &other) const { + return m_width == other.width() && m_height == other.height(); + } private: KDCoordinate m_width; KDCoordinate m_height;