This is the second attempt to force a flush after scrolling.
Commit 9c0803edd1 worked on
Mac Silicon but not Mac Intel.
So, instead of calling [NSApp currentEvent] to determine if
scrolling has occurred, mark the AquaSalFrame whenever a
scrollwheel or mouse drag event is dispatched so the frame
will be flushed in the next AquaSalFrame::Flush() call.
Change-Id: I2d0b99d2cd1167e92c7fd89bf53b2f30ab85a165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159003
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Delaying flushing until the dispatch level returns to zero causes
scrolling via the scrollwheel or mouse drag to appear laggy and
jerky.
Change-Id: Ib70e7766435baa765dd0d1d704ba2fac87f7fccc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158853
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
I can't explain why inverting using Skia causes this bug on
macOS but not other platforms. My guess is that Skia on macOS
is sharing some data when different SkiaSalBitmap instances
are created from the same OutputDevice. So, mark this
SkiaSalBitmap instance's image as immutable so that successive
inversions are done with buffered bitmap data instead of Skia.
Change-Id: I8acf90561c48edba14a5f43d16f375f15f25820c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158880
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Do not return the alpha mask if it is awaiting pending scaling.
Pending scaling has not yet been done at this point since the
scaling is done in the code following this block.
Change-Id: I995d7f7eca4190f0a8b2094928bd92f718f1d5bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158599
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
I don't know why, but the fix for tdf#157635 causes
images with a palette of 16 entries to be inverted.
Is this the only condition for masking out black
pixels in non-transparent animation frames?
Change-Id: I9550baab4dc4d9b75a21c8af2f6c0b5eb8e46c12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158214
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Commit b69db38a38b09e158e8d46d8b717db85860ca874 caused tooltips
to fail to appear if their immediate parent window was not the
key window. So, look through the parent window's parent windows
and, if any of those windows are the kwy window, show the tooltip.
Change-Id: Icf1aed1144fdeac03b4b208de8ed8ee2db8ad4a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158212
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
The size of an embedded PDF files is multiplied by
PDF_INSERT_MAGIC_SCALE_FACTOR for platforms like macOS so undo that
by adjusting the size and scale factor.
For some unknown reason, when exporting the following PDF, the
estimated size of embedded PDF charts are 20x larger than expected.
This only occurs on macOS so possibly there is some special conversion
from MapUnit::MapPoint to MapUnit::MapTwip elsewhere in the code:
https://bugs.documentfoundation.org/attachment.cgi?id=190109
Change-Id: Id0563466fea3d7a3a0419787ec9da45f0c1d2e0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157852
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
On macOS, many AWT classes do their work on the main thread
deep in native methods in the java.awt.* classes. The problem
is that Oracle's and OpenJDK's JVMs don't bracket their
"perform on main thread" native calls with "attach/detach
current thread" calls to the JVM.
Change-Id: I0859dc9e20f34bd0b43bb321898507764fd530fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157985
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Also, make bitmap immutable to avoid making a copy in bitmap.asImage()
and, just to be safe, flush the canvas after drawing the pixel buffer.
Change-Id: I3ac99cf4acf0bf4c8b274dc73295ca7b9f386c70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157333
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
For some unkown reason, the previous "draw gradient with XOR, draw
polygon with N0, and draw gradient again with XOR" does not work
with Skia/Raster (at least on macOS). Fortunately, Skia supports
polypolygonal clipping so just clip and draw the gradient.
Change-Id: Id069160312a270096f5ec9c670615eb95ec6200b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157199
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Instances of this class are constructed with
TaskPriority::POST_PAINT, but then it was set to
TaskPriority::HIGHEST when reused. Flushing
seems to be expensive (at least with Skia/Metal) so keep the
existing priority when reused.
Change-Id: Ieb40cd6122f543f76e66456cc92a8643e2320d73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157162
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
For some unknown reason, the scale is 8 times larger than for
non-external PDF XObjects.
This fix also allows the CppunitTest_vcl_pdfexport to run
successfully on macOS.
Change-Id: I166914e6ac575c50985efba3fb7a38ec758dea1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157090
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
We need an alpha mask, even if it is totally opaque, so that
drawinglayer::primitive2d::ProcessAndBlurAlphaMask() can be called.
Otherwise, blurring of edges will fail in cases like running in a
slideshow or exporting to PDF.
Change-Id: If03b32a8a22ed960f1475710a9831cab33799b60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156903
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
An invert is needed to fix tdf#156808 but inverting the alpha mask
causes tdf#157086 so invert the blur mask instead.
Change-Id: Id695d04f008932caadb0fc2b477b0a4b152fa66c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156854
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
oox::xls::WorkbookFragment::finalizeImport() calls
AquaSalInstance::DoYield() with bWait set to true. But
since unit tests generally have no expected user generated
events, we can end up blocking and waiting forever so
don't block and wait when running unit tests.
Change-Id: I14cfdb88f04b82f49e8c15e554e5c4b4053e77b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156826
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Even when drawing to a VirtualDevice where antialiasing
is disabled, text will still be drawn with some
antialiased pixels on HiDPI displays. So, expand the
size of the VirtualDevice slightly to capture any of
the pixles drawn past the edges of the destination
bounds.
Change-Id: Ibcba8234708d8784c12f984289ec0a8fcad6694e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156098
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Commit 5baac4e531 switched to setting
the surface size to mPixelsSize in an attempt to avoid downscaling
mImage but since it causes tdf#156866, revert back to setting the
surface size to mSize.
Also, in release builds, tdf#156629 and tdf#156630 reappear in many
cases because a BitmapInfoAccess is in a debug block. So, instead
of relying on other code to a create a BitmapInfoAccess instance,
create one here to force the alpha mask to handle any pending
scaling and make the alpha mask immutable.
Change-Id: If9f0dfb7b9a82cf7a3e402965ceffd42eace4c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156022
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
At the time of this change, only the AquaSalMenu class calls this
function so it should be safe to invert the alpha mask here.
Change-Id: Id67ad0f453bbf88b43d37087eef36a27ced3ad37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155977
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Emoji bitmaps need to have their alpha mask inverted like is done
with transparent images and shapes. So, invert the alpha mask of
Type 3 font bitmaps.
Also, add links to test documents for future development and testing.
Regression from:
commit 81994cb2b8
Date: Fri Apr 16 20:33:10 2021 +0200
Convert internal vcl bitmap formats transparency->alpha (II)
Change-Id: I18223a231ab751945883ede029d660949a406f7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155960
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
This reverts commit 3e20c3e73c.
Reason for revert: This breaks every single fix that I have made for exporting alpha masks to PDF. A different solution is needed as the invert needs to be where it was to snapshot the AlphaMask.
Change-Id: I5f743b67067dff43a2324d6ca9bc1f444e245a12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155917
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Tested-by: Patrick Luby <plubius@neooffice.org>
Commit ad1f69d28d fixed an alpha
blending bug in AlphaMask::BlendWith(const AlphaMask&) so almost
all of the special alpha mask inversions when drawing transparent
meta actions are no longer needed and so, when Skia is disabled,
the same inversions as Skia are now used.
The one special alpha mask inversion that is still needed when Skia
is disabled is when exporting to PDF documents like the following
with transparent gradients:
https://bugs.documentfoundation.org/attachment.cgi?id=188084
Change-Id: I3212a38916be3d238bb9c868b161031616baf0a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155859
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Reimplement fix in commit 926c5246b6
in an attempt to reduce the fix's performance hit. Instead of
invoking EnsureBitmapData() and converting the SkImage to a
memory buffer, any pending scaling on alpha masks is handled by
creating a new, scaled SkImage.
Note that in commit 926c5246b6,
EnsureBitmapData() was invoked which converted the SkImage to a
memory buffer. That in turn would make Invert() a noop which
fixed the related bug where an image has been opened and, before
it has been printed or run in a slideshow, the alpha mask would
unexpectedly be inverted. So keep this immutable behavior without
calling EnsureBitmapData() by adding a new mutability flag.
Change-Id: I99dc272b40c53664ea49333402a6a637b1548a5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155850
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Passing an expanded, rotated polygon noticeably modifies the
drawing of the gradient in a slideshow due to moving of the
starting and ending colors far off the edges of the drawing
surface. So try another way and set the angle of the
gradient and draw only the unadjusted bounds.
Change-Id: I95441dfa3215396d5bc7edfa9f985335480b37de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155729
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
On macOS, with Skia/Metal or Skia/Raster with a Retina display
(i.e. 2.0 window scale), the alpha mask gets upscaled in certain
cases.
This bug appears to be caused by pending scaling of an existing
SkImage in the bitmap parameter. So, force the SkiaSalBitmap to
handle its pending scaling.
This change consolidates the three duplicate fixes added in the
following commits into the AlphaMask(const Bitmap&) constructor.
commit 12fd870113
commit ce2d9f5dd4
From my light testing, the bitmap's SkImage is not scaled except
when running macOS with a Retina display. The only exception is
that this fix will be triggered on all platforms when exporting
to PDF images with an alpha mask.
Change-Id: Iea5afd55aac984ca606b2b4b44e457d81d76fac0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155568
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
On macOS, with Skia/Metal with a Retina display (i.e. 2.0 window
scale), the alpha mask gets upscaled for the font color and the
character background color icons in Writer's properties sidebar
with most icon sets. The Breeze and Colibre icon sets running in
light mode are the most obvious cases.
This bug appears to be caused by asynchronous rendering of the
returned image. So, we force a copy of the alpha mask in case it
changes before the image is actually drawn.
Change-Id: Ie3aa3b26acaee4bd9173e6b356137980c070c7c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155562
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Due to the switch from transparency to alpha in commit
81994cb2b8, flip the background colors
for the VirtualDevices and invert an alpha mask.
On macOS, with Skia/Raster with a Retina display (i.e. 2.0 window
scale), the alpha mask gets upscaled. Also, when Skia is enabled,
the alpha mask gets inverted in the first export to PDF after
launching the application. These two bugs appear to be caused by
asynchronous rendering of the returned bitmap. So, we force a copy
of the alpha mask in case it changes before the bitmap is actually
drawn.
Lastly, respect system animation settings when determining if the image
should be animated.
Change-Id: I8144691a6c99bf8361b301b88d22172991463f26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155429
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Due to the switch from transparency to alpha in commit
81994cb2b8, a sprite's
alpha mask needs to be inverted when Skia is enabled and
the fAlpha value needs to be inverted when Skia is disabled.
Change-Id: Ie802924b07ddbab536a2eddb57bf82e5146cffe7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155358
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
After 0e7d4ea64f, white polygons are
drawn in the LibreOffice about .svg in both the About dialog and with
the .svg in a document.
Creating the mask with COL_WHITE instead of COL_BLACK appears to fix
this without causing tdf#156508 to reoccur.
Change-Id: I886451245126c2b7f936e30275965148bf029627
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155362
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
This reverts commit 01a1d2a849.
That commit appeared to fix tdf#144072 but it only delays the crash as the reportdesign module will keep reusing the same SdHdl pointer that has already been deleted.
Change-Id: I8e416b0376aa8724b697f54ed45f58341b47dc2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155181
Tested-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
BegDragObj_createInvisibleObjectAtPosition() may clear the handle
list and that will delete the SdrHdl instances owned by this section
view so set _pHdl to null if it has been deleted during the call.
Change-Id: I89606958f8a76a2c35685d1aff6b0159739a464a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155119
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
In the verious LibreOffice samples attached to tdf#156470, it appears
that LibreOffice spends a lot of time the GetTextArray() calls in
SvxFont::QuickGetTextSize(). So add logging to determine if any of
the GetTextArray() calls are returning unusual sizes.
Change-Id: Ie6f0fcc85396b47342b6a93180d4bc9873420931
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155072
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Revert portion of commit 9d68c794d6
that stops the animated border when a copy action is performed in
a different document by cancelling the animated border.
While the change worked on macOS and Linux, on Windows it stops
the currently active copy border so revert this fix.
Change-Id: I0dbdc8b1bf3077eecadbbe591a27e60ef3d48b7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155067
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Using the mdls command fails if macOS Spotlight is disabled for the path
selected by the user. So, instead, check if the path contains a matching
"ProductKey=<version>" line in its Contents/Resources/bootstraprc file.
Change-Id: Idbf8e2712b9fae8efa0997cf5c5c0f3fa6e68658
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154718
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Allow the system's "reduce animation" preferences to disable the
Calc animated border when copying a selection of cells.
Also, fix failure to stop the animated border when a copy action is
performed in a different document by cancelling the animated border.
This transferable has lost ownership of the system clipboard so,
in essence, the previous copy action that created this transferable
has been cancelled.
Change-Id: I4da6d557c5dbf653c38a99eb7a16d961843a41d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154752
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
OutputDevice::ImplDrawRotateText() draws black text but
that will generate gray pixels due to antialiasing so
count dark gray the same as black, light gray the same
as white, and the rest as medium gray.
The results are not smooth since LibreOffice appears to
redraw these semi-transparent masks repeatedly without
clearing the background so the semi-transparent pixels
will grow darker with repeatedly redraws due to
cumulative blending. But it is now better than before.
Change-Id: If64ff5ab52a6e441b587aa3c3c12b08137ecf34e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154079
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
When adding entitlements in a debug, non-codesigned build, the
codesign command fails on some Mac Intel machines. Since this
command is only executed in non-release builds, ignore any
failures.
Change-Id: I4d89e03bbbc00725b2902446f2abbb99f273eab7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153269
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
com::sun::star::accessibility::XAccessibleContext::getAccessibleChild()
can throw an IndexOutOfBoundsException exception even when fetching with
an index that is positive and less than the value returned by a call to
the accessible context's getAccessibleChildCount() method so put every
getAccessibleChild() call in a try/catch block.
Note: this is actually expected behavior even though it is rare. For
example, accessibility::AccessibleTextHelper_Impl::getAccessibleChild()
uses the following code snippet to throw such an exception:
if( 0 > i || i >= getAccessibleChildCount() ||
GetTextForwarder().GetParagraphCount() <= i )
In the case of tdf#146626, getAccessibleChildCount() returns 22 but
getAccessibleChild(1) throws such an exception due to the last
condition in the above code snippet.
Change-Id: If974afb7b9178faa99b91dcd79eb5f169bbfe13e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153160
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
When a Calc column is selected, the child count will be
at least a million. Constructing that many C++ Calc objects
takes several minutes even on a fast Silicon Mac so apply
the maximum table cell limit here.
Change-Id: I4e3ebf9fdf7367620313e4e10dd0918de9d6bffb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152853
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Also, when building a .dmg for macOS, skip codesigning for non-release
builds, both with and without the macOS sandbox, if there is no identity
set but set entitlements to allow Xcode's Instruments application to
connect to the application.
Lastly, add entitlements when building soffice in $(INSTROOTBASE) if
this is a non-release build.
Change-Id: I764bf5bd5d44e878669c4287906e6efd6aac593f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152655
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
On macOS, accessibility is implemented by creating a native NSView
for each C++ accessible element. The problem with using an NSView
for each element is that NSViews are very slow to add to or remove from
an NSWindow once the number of NSViews is more than a thousand or so.
Fortunately, Apple added a protocol that allows adding a native
accessible element using the lightweight NSAccessiblityElement class.
The topmost NSAccessiblityElement elements are connected to the single
SalFrameView in each NSWindow but since NSAccessiblityElements are not
NSViews, they are not connected to any of NSWindow's event or draw
dispatching. This makes NSAccessiblityElements significantly faster to
add to or remove from an NSWindow with no apparent loss in functionality.
Note: this change is a subset of the LibreOffice 4.4 code changes that I
wrote for NeoOffice.
Change-Id: I408108d57217db407512dfa3457fe26d2ab455de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152717
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
This reverts commit ff95984c8e.
Reason for revert: The script was just a quick hack that I whipped up during other development work and I didn't know how to integrate it into debug builds by default. @Christian Lohmeier reviewed the script and noted the existing build scripts that add entitlements based on build type where I can put this new entitlement.
Change-Id: I4246639e99a62c63fb1ba38b19cac0442c71c0a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152031
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Fix crash due to an uncaught DisposedException thrown by
SwAccessibleParagraph::getTextRange() by using the same try/catch
block in -[A11yWrapper accessibilityAttributeValue:] in
-[A11yWrapper accessibilityAttributeValue:forParameter].
Change-Id: Ifcaec3eb2d76f32bddc56a1242f6d86f8b90f782
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152361
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
(cherry picked from commit f8cc6f960e8aeb37547d447fed2b2c6e6ddc02e3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152317
To connect Xcode's Instruments application to profile LibreOffice, the
"com.apple.security.get-task-allow" entitlement must be added to the
soffice executable.
This script will set the "com.apple.security.get-task-allow" entitlement
instdir/LibreOfficeDev.app/Contents/MacOS/soffice executable so that
profiling can be done using a local build.
Credit for documenting this Xcode requirement goes to the following blog:
https://cocoaphony.micro.blog/2022/10/29/solving-required-kernel.html
Change-Id: I547edf7c1ad340267e9ed4c396fc723b7ea719be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151981
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
With a HiDPI display on macOS, each logical pixel is backed
by 4 physical pixels. Turning off antialiasing and drawing a
diagonal line causes many logical pixels on the edge of the
diagonal line to have a mixture of white and blue physical
pixels. Then, when such logical pixels are fetched via
BitmapEx::GetPixelColor(), their underlying 4 white and blue
physical pixels are combined into blended shades of white
and blue.
Change-Id: I1aca121f294ce2f4cb7b17a93b904425c8049f80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151705
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Don't display tooltips when mousing over non-key windows even if the
application is active as the tooltip window will pull the non-key
window in front of the key window.
Change-Id: I425b9af09de0272ebee84a218e2e5ae8c200a4e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151646
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
The default attributes sequence sometimes crashes when it is released but
only when compiler optimization is enabled, so disable optimization for the
+[AquaA11yTextAttributesWrapper createAttributedStringForElement] selector.
Also, disabling optimization by itself is apparently not enough to stop
the crashing. Acquiring the solar mutex during native accessibility calls
is also needed. Native accessibility calls are called from native input
sources in [NSApp nextEventMatchingMask:untilDate:inMode:dequeue:]. Since
AquaSalInstance::DoYield() releases the solar mutex before calling
[NSApp nextEventMatchingMask:untilDate:inMode:dequeue:], we need to
always acquire the solar mutex during all NSAccessibility selectors (both
the old informal protocol and the newer formal protocol) that we implement.
Change-Id: I9b715e17e9c5a32b7ce28815e288b2af236c3cc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145742
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Pressing and holding action keys such as arrow keys must not be handled
like pressing and holding a character key as it will insert unexpected
text.
Change-Id: I6beaff265e6cae30337b025791692ff67b760ff8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145689
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Some events and timers call Application::Reschedule() or
Application::Yield() so don't block and wait for events when a
window is in live resize.
Also, only native events and timers need to be dispatched to redraw
the window so skip dispatching user events when a window is in
live resize.
Lastly, only higher priority tasks need to be fired to redraw the
window so skip firing potentially long-running tasks, such as the
Writer idle layout timer, when a window is in live resize.
Change-Id: I5d449caa432399e836b8e59781e5cc53af718873
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145211
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Application::Reschedule() can potentially display a modal dialog which
will cause a hang so temporarily disable live resize by clampiing the
window's minimum and maximum sizes to the current frame size which in
Application::Reschedule().
Also, eliminate flickering during live resizing of a window when using
Skia/Metal. When in live resize, the SkiaSalGraphicsImpl class does not
detect that the window size has changed until after the flush has been
called so call checkSurface() to recreate the SkSurface if needed before
flushing. Flushing had to be moved during [self windowDidResize:] to eliminate
flicker. Flushing in [self displayIfNeeded] does not eliminate flicker so
apparently [self windowDidResize:] is called earlier.
Change-Id: Id3de838d2e17fee85cb583b6c4e862b571d47142
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145053
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
During a live resize, macOS floods the application with windowDidResize:
notifications so sending a paint event does not trigger redrawing with
the new size. Instead, force relayout by dispatching all pending internal
events and firing any pending timers.
Also, force a repaint of the window after live resizing ends by reposting
this notification so that [self windowDidResize:] will be called at least
once after live resizing ends.
Change-Id: I9d93108c989418bab6d80c7f6afaccc1daaa746e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145042
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
The window will clear its background in [SalFrameWindow displayIfNeeded]
so when Skia/Metal is enabled, explicitly flush the Skia graphics to the
window during live resizing or else nothing will be drawn until after live
resizing has ended.
Also, when Skia/Metal is enabled, rapidly resizing a window has a noticeable
amount of flicker so don't send any paint events during live resizing. Also,
it appears that most of the LibreOffice layouts do not change their layout
much during live resizing so apply this change when Skia is not enabled to
ensure consistent behavior whether Skia is enabled or not.
Change-Id: If6423faa72529b9de8735e04e69c9511aceb2276
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144979
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Commit 9eb732a320 fixed crashing when
printing SkiaSalBitmaps to a non-Skia SalGraphics. However, the fix
almost always makes two copies of the SkiaSalBitmap's bitmap data: the
first copy is made in SkiaSalBitmap::AcquireBuffer() and then
QuartzSalBitmap makes a copy of the first copy.
By making QuartzSalBitmap's methods that return a CGImageRef pure
virtual, a non-Skia SalGraphics can now create a CGImageRef directly
from a SkiaSalBitmap's Skia bitmap data without copying to any
intermediate buffers.
Change-Id: If6ab7f175889cb4839d8a2461b7be7671e575c08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144856
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This bug occurs when the values for NSTextInsertionPointBlinkPeriodOn or
NSTextInsertionPointBlinkPeriodOff are set to zero or close to zero.
LibreOffice becomes very sluggish opening documents when either is set
at 100 milliseconds or less so set the blink rate to the maximum of
500 milliseconds, NSTextInsertionPointBlinkPeriodOn, and
NSTextInsertionPointBlinkPeriodOff.
Change-Id: I953bddda757f8514221ac5cd9c04bd749a994fda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144775
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
The first step to enable this input method is to always return a valid selected
range location. -[NSResponder interpretKeyEvents:] will not call
[self firstRectForCharacterRange:actualRange:] if the selected range location
is NSNotFound so that is what was disabling display of the press-and-hold
input method popup.
Once [self firstRectForCharacterRange:actualRange:] is called, emulate the
press-and-hold behavior of the TextEdit application by setting the marked text
to the last key down event's characters. The characters will already have been
committed by the special character input method so set the
mbTextInputWantsNonRepeatKeyDown flag to indicate that the characters need to
be deleted if the input method replaces the committed characters.
Also, emulate the press-and-hold behavior of the TextEdit application by
committing any uncommitted text when either the escape or the return key is
pressed while the press-and-hold input method popup is displayed.
Lastly, handle repeat key events by explicitly inserting the text if there is
no uncommitted text before -[NSResponder interpretKeyEvents:] is called.
Change-Id: I104b3d64a8c66fef3a5a1cec0fba1daa553cd9a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144630
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Several users reported that copying the LibreOffice.app package
in the Finder from a .dmg file compressed with lzfse compression
copies the package several times faster than from a .dmg compressed
with bzip2 compression.
On a mid-2015 Intel MacBook Pro running macOS, copying in the Finder
was at least 5 times faster with lzfse than with bzip2. Also, the
hdiutil man page as of macOS Monterey 12.6.2 has marked bzip2 as
deprecated. lzfse is marked as supported since macOS El Capitan 10.11
so this change appears safe.
The one thing that bzip2 has is better compression so a .dmg with
bzip2 should be smaller than with lzfse. A .dmg built from a debug
build was 262M with bzip2 and 273MB for lzfse. So it appears that
lzfse creates .dmg files that are only 4% or 5% larger than bzip2.
Change-Id: I61e2a08cede19a5bb8c257d4fa4762168a3a9dc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144342
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
HACK: Adding a subview to an NSView that is not attached
to an NSWindow leads to infinite recursion in the native
NSViewGetVisibleRect() function. This seems to be a new
behavior starting with macOS 12.6.2.
In the case of tdf#146765, we end up here because
-[AquaA11yWrapper childrenAttribute] is called by a
wrapper that is already attached to an NSWindow. That is
normal. What isn't normal is that the child wrapper's
unignored accessible parent is a differnt wrapper than
the caller and that different wrapper is not yet
attached to an NSWindow.
TODO: switch the AquaA11yWrapper class to inherit the
lightweight NSAccessibilityElement class instead of the
NSView class to possibly avoid the need for this hack.
Change-Id: Ic6c2a60e90a154786dd7f5935582ef7d3f57584c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
As described in the comment in the above code, CGBitmapContextCreate()
and CGBitmapContextCreateWithData() will try to access pixels up to
mDirtyRect.x() + pixmap.bounds.width() for each row. When reading the
last line in the SkPixmap, the buffer allocated for the SkPixmap ends at
mDirtyRect.x() + mDirtyRect.width() and mDirtyRect.width() is clamped to
pixmap.bounds.width() - mDirtyRect.x().
This behavior looks like an optimization within CGBitmapContextCreate()
to draw with a single memcpy() so fix this bug by chaining the
CGDataProvider(), CGImageCreate(), and CGImageCreateWithImageInRect()
functions to create the screen image.
Change-Id: Ic83f6162f8eb63de22693c0c40015da3b88aee65
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144194
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Prevent the non-native LibreOffice PrintDialog from displaying by creating a fake printer if there are no printers. This will allow the LibreOffice printing code to proceed with native NSPrintOperation which will display the native print panel.
Change-Id: Iee13305520360b0165464889f0ee51b1207dd5ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143794
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
When running the sw_ooxmlexport17 unit test on slower macOS Intel
machines, This loop will never end even after 1M+ loops so set a
maximum number of loops like is done in the nested while loops.
Change-Id: If3a6140e03f21f4a16f6d90be7988c28c8f36753
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143947
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Commit de3f13e217 disabled Skia for printing.
However, since all SalBitmaps created are either all QuartzSalBitmaps or all
SkiaSalBitmaps, a crash occurs whenever a SkiaSalBitmap is passed to a
printer's SalGraphics instance which is now always non-Skia.
Change-Id: I7c1b0e1a9993e21db18ba5695a106cb10cc4088a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143939
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Skia does not work with a native print graphics contexts. I am not sure why but from what I can see, the Skia implementation drawing to a bitmap buffer. However, in an NSPrintOperation, the print view's backing buffer is CGPDFContext so even if this bug could be solved by blitting the Skia bitmap buffer, the printed PDF would not have selectable text so always disable Skia for print graphics contexts.
Change-Id: I214ba83b6e368af3ef51ea770b093612d04047a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143798
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
The Windows implementation of the SalFrame::EndExtTextInput() method commits or discards the native input method session. It appears that most macOS applications discard the uncommitted text when cancelling a session so always commit the uncommitted text. This change also commits any uncommitted text and cancels the native input method session whenever a window loses focus like in Safari, Firefox, and Excel.
Note: if there is any marked text, SalEvent::EndExtTextInput may leave the cursor hidden so commit the marked range to force the cursor to be visible.
Dispatching SalEvent::EndExtTextInput in SalFrame::EndExtTextInput() creates some other related native input method handling bugs that have also been fixed in this patch:
- Whenever a SalEvent::EndExtTextInput event is dispatched, cancel the native input method session so that the native input context's state is in sync with LibreOffice's internal state. The only exceptions are in [SalFrameView insertText:replacementRange:] or [SalFrameView setMarkedText:selectedRange:replacementRange:] because when these two selectors commit text, the native input method session has already been cancelled and calling [SalFrameView endExtTextInput] will cause repeated text insertions from the native macOS Character Viewer dialog to overwrite previous insertions.
- Highlight all characters in the selected range. Normally uncommitted text is underlined but when an item is selected in the native input method popup or selecting a subblock of uncommitted text using the left or right arrow keys, the selection range is set and the selected range is either highlighted like in Excel or is bold underlined like in Safari. Highlighting the selected range was chosen because highlighting was used in LibreOffice 7.4.x and using bold and double underlines can get clipped making the selection range indistinguishable from the rest of the uncommitted text.
- The fix for ooo#106901 always returns a zero length range if [self markedRange] called outside of mbInKeyInput. If a zero length range is returned, macOS won't call [self firstRectForCharacterRange:actualRange:] for any newly appended uncommitted text and the native input method popup will appear in the bottom left corner of the screen. So, [self markedRange] now returns the marked range if is valid.
- Commit uncommitted text before dispatching menu item selections and key shortcuts. In certain cases such as selecting the Insert > Comment menu item or pressing Command-Option-C in a Writer document while there is uncommitted text will call AquaSalFrame::EndExtTextInput() which will dispatch a SalEvent::EndExtTextInput event. Writer's handler for that event will delete the uncommitted text and then insert the committed text but LibreOffice will crash when deleting the uncommitted text because deletion of the text also removes and deletes the newly inserted comment.
Change-Id: I4ff4682aeef7d42ce26059aa76f971a68128833c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143619
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
The nodes in mpIMEInfos may be deleted in ImpEditEngine::Clear() which causes a crash in the CommandEventId::ExtTextInput and CommandEventId::EndExtTextInput event handlers.
This crash occurs on Windows or macOS using the following steps:
- Enter uncommitted text (enter "aaa" with a Japanese Hiragana input method) in a comment in a Writer document
- Switch to another empty Writer document without committing the text in the first Writer document
- Switch back to the first Writer document
The above steps may need to be repeated a few times but it will eventually crash with the following stack trace:
(lldb) bt 25
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
frame #0: 0x00000001b928ad98 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001b92bfee0 libsystem_pthread.dylib`pthread_kill + 288
frame #2: 0x00000001b91fa340 libsystem_c.dylib`abort + 168
* frame #3: 0x00000001b91f9754 libsystem_c.dylib`__assert_rtn + 272
frame #4: 0x000000010374a09c libeditenglo.dylib`ImpEditEngine::ImpRemoveParagraph(this=0x000000011a684e00, nPara=-2147483648) at impedit2.cxx:2512:5
frame #5: 0x0000000103739658 libeditenglo.dylib`ImpEditEngine::ImpDeleteSelection(this=0x000000011a684e00, rCurSel=0x000000016fdf7250) at impedit2.cxx:2473:9
frame #6: 0x0000000103739328 libeditenglo.dylib`ImpEditEngine::DeleteSelected(this=0x000000011a684e00, rSel=0x000000016fdf7250) at impedit2.cxx:259:19
frame #7: 0x000000010373aac4 libeditenglo.dylib`ImpEditEngine::Command(this=0x000000011a684e00, rCEvt=0x000000016fdf7698, pView=0x0000600000169e10) at impedit2.cxx:408:24
frame #8: 0x0000000103721744 libeditenglo.dylib`ImpEditView::Command(this=0x00000002e3f8b7b0, rCEvt=0x000000016fdf7698) at impedit.cxx:1757:41
frame #9: 0x00000001036d7df4 libeditenglo.dylib`EditView::Command(this=0x0000600000169e10, rCEvt=0x000000016fdf7698) at editview.cxx:495:26
frame #10: 0x000000010b1d2420 libsvxlo.dylib`WeldEditView::Command(this=0x0000600002b11e30, rCEvt=0x000000016fdf7698) at weldeditview.cxx:312:23
frame #11: 0x00000002ea78dd50 libswlo.dylib`sw::sidebarwindows::SidebarTextControl::Command(this=0x0000600002b11e30, rCEvt=0x000000016fdf7698) at SidebarTxtControl.cxx:461:26
frame #12: 0x000000011656f3d4 libvcllo.dylib`weld::CustomWeld::DoCommand(this=0x000060000016a740, rPos=0x000000016fdf7698) at customweld.cxx:93:32
frame #13: 0x000000011656ee7c libvcllo.dylib`weld::CustomWeld::LinkStubDoCommand(instance=0x000060000016a740, data=0x000000016fdf7698) at customweld.cxx:91:1
frame #14: 0x0000000115ca1dd4 libvcllo.dylib`Link<CommandEvent const&, bool>::Call(this=0x00000002e3f8bc48, data=0x000000016fdf7698) const at link.hxx:111:45
frame #15: 0x00000001165b1658 libvcllo.dylib`SalInstanceDrawingArea::CommandHdl(this=0x00000002e3f8bb50, rEvent=0x000000016fdf7698) at salvtables.cxx:6473:26
frame #16: 0x00000001165af588 libvcllo.dylib`SalInstanceDrawingArea::LinkStubCommandHdl(instance=0x00000002e3f8bb50, data=0x000000016fdf7698) at salvtables.cxx:6471:1
frame #17: 0x0000000115ca1dd4 libvcllo.dylib`Link<CommandEvent const&, bool>::Call(this=0x00000002e3f90208, data=0x000000016fdf7698) const at link.hxx:111:45
frame #18: 0x0000000115d047d0 libvcllo.dylib`VclDrawingArea::Command(this=0x00000002e3f90080, rEvent=0x000000016fdf7698) at layout.hxx:685:27
frame #19: 0x0000000115e2e2bc libvcllo.dylib`ImplCallCommand(pChild=0x000000016fdf77c8, nEvt=ExtTextInput, pData=0x000000016fdf77d8, bMouse=false, pPos=0x0000000000000000) at winproc.cxx:229:17
frame #20: 0x0000000115e34458 libvcllo.dylib`ImplHandleExtTextInput(pWindow=0x0000600002aa8930, rText=0x000000016fdf8290, pTextAttr=0x0000600000018710, nCursorPos=4, nCursorFlags=1) at winproc.cxx:1424:13
frame #21: 0x0000000115e30dc8 libvcllo.dylib`ImplWindowFrameProc(_pWindow=0x0000600002aa8930, nEvent=ExtTextInput, pEvent=0x000000016fdf8290) at winproc.cxx:2863:20
frame #22: 0x000000011b0424e0 libvclplug_osxlo.dylib`SalFrame::CallCallback(this=0x00000001378ffb40, nEvent=ExtTextInput, pEvent=0x000000016fdf8290) const at salframe.hxx:306:29
frame #23: 0x000000011b0ef8f4 libvclplug_osxlo.dylib`-[SalFrameView setMarkedText:selectedRange:replacementRange:](self=0x00000002c4b0d980, _cmd="setMarkedText:selectedRange:replacementRange:", aString="嗚呼嗚呼", selRange=location=4, length=0, replacementRange=location=9223372036854775807, length=0) at salframeview.mm:1595:18
frame #24: 0x00000001bc8d6a2c AppKit`-[NSTextInputContext(NSInputContext_WithCompletion) setMarkedText:selectedRange:replacementRange:completionHandler:] + 168
Change-Id: I500824967d56232272041f8a2b972cdb2c9fe05c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143806
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>