Files
ElyOffice/patches/libreoffice/0001-lok-macos-tile-painting.patch
T
ZacharyZhang-NY b7fca0146d Ely Office: six offline-first desktop apps in Rust and GPUI
ElyDoc, ElyTable, ElyShow (LibreOfficeKit), ElyPDF (MuPDF), ElyTree (Git),
ElyMark (Milkdown and CodeMirror in CEF). ElyMail and ElyAgent follow.
2026-10-08 21:20:08 -04:00

63 lines
2.2 KiB
Diff

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a1bebedb4..27584ba49 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -181,7 +181,7 @@
#include <vcl/ImageTree.hxx>
#include <vcl/ITiledRenderable.hxx>
#include <vcl/dialoghelper.hxx>
-#ifdef _WIN32
+#if defined(_WIN32) || defined(MACOSX)
#include <vcl/BitmapTools.hxx>
#endif
#include <unicode/uchar.h>
@@ -2603,10 +2603,15 @@ void CallbackFlushHandler::stop()
stop();
}
void CallbackFlushHandler::scheduleFlush()
{
+#if defined(MACOSX)
+ // Aqua never runs posted user events: flush inline.
+ invoke();
+#else
if (!m_pFlushEvent)
m_pFlushEvent = Application::PostUserEvent(LINK(this, CallbackFlushHandler, FlushQueue));
+#endif
}
IMPL_LINK_NOARG(CallbackFlushHandler, FlushQueue, void*, void)
@@ -4274,7 +4274,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
return;
}
-#if defined(UNX) && !defined(MACOSX) || defined(_WIN32)
+#if defined(UNX) || defined(_WIN32)
// Painting of zoomed or HiDPI spreadsheets is special, we actually draw everything at 100%,
// and only set cairo's (or CoreGraphic's, in the iOS case) scale factor accordingly, so that
@@ -4317,9 +4317,14 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
// Set background to transparent by default.
pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+#if defined(MACOSX)
+ // Aqua devices cannot paint client buffers: paint, then copy.
+ pDevice->SetOutputSizePixel(Size(nCanvasWidth, nCanvasHeight));
+#else
pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
pBuffer);
+#endif
pDoc->paintTile(*pDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -4336,7 +4341,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
pDevice->DrawRect(aRect);
}
-#ifdef _WIN32
+#if defined(_WIN32) || defined(MACOSX)
// pBuffer was not used there
pDevice->EnableMapMode(false);
Bitmap aBmp(pDevice->GetBitmap({ 0, 0 }, { nCanvasWidth, nCanvasHeight }));