summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-02-23 15:27:51 +0200
committerMichael Meeks <michael.meeks@collabora.com>2018-02-26 13:05:39 +0100
commitf99b91ab0a67ce23f1c11bdb67370c0773813d15 (patch)
tree4b4d6ebef5c4a740d0f4abd3773723929b28eb7b /vcl
parent4c9f01179be9325486047f02d9978d18c592afaa (diff)
tdf#103571: Avoid spurious heavy SalEvent::DisplayChanged callbacks
It seems that on some Macs that the NSApplicationDidChangeScreenParametersNotification is sent for unknown reasons quite often. I can reproduce the problem by changing the Dock size in System Preferences while LibreOffice is running, but others seem to get it without resorting to such trickery. The code used to invoke the SalEvent::DisplayChanged callback in all cases, which can be extremely heavy, as it involves re-measuring text layouts all over the place in all open document windows. Avoid that if the geometry in fact has not changed. Sure, there still is the problem that LibreOffice can become unresponsive for several seconds when the display geometry *does* change, like when you attach or detach a display. Change-Id: I659881e5e392bd599f6be190835e32a77d9f4725 Reviewed-on: https://gerrit.libreoffice.org/50249 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tor Lillqvist <tml@collabora.com> (cherry picked from commit 715b7b6f346fdd9c856db268dcd66334b58c273c) Reviewed-on: https://gerrit.libreoffice.org/50264 Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/osx/salframe.h6
-rw-r--r--vcl/osx/salframe.cxx66
2 files changed, 56 insertions, 16 deletions
diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h
index 0d93e9e9b2ff..c2b53e270648 100644
--- a/vcl/inc/osx/salframe.h
+++ b/vcl/inc/osx/salframe.h
@@ -82,6 +82,7 @@ public:
PointerStyle mePointerStyle; // currently active pointer style
NSTrackingRectTag mnTrackingRectTag; // used to get enter/leave messages
+ NSRect maTrackingRect;
CGMutablePathRef mrClippingPath; // used for "shaping"
std::vector< CGRect > maClippingRects;
@@ -95,6 +96,11 @@ public:
// To prevent display sleep during presentation
IOPMAssertionID mnAssertionID;
+ NSRect maFrameRect;
+ NSRect maContentRect;
+
+ bool mbGeometryDidChange;
+
public:
/** Constructor
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 9bf63720dbef..c029f25159ba 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -268,6 +268,10 @@ void AquaSalFrame::screenParametersChanged()
if( mpGraphics )
mpGraphics->updateResolution();
+
+ if (!mbGeometryDidChange)
+ return;
+
CallCallback( SalEvent::DisplayChanged, nullptr );
}
@@ -1522,6 +1526,9 @@ void AquaSalFrame::SetParent( SalFrame* pNewParent )
void AquaSalFrame::UpdateFrameGeometry()
{
+ bool bFirstTime = (mnTrackingRectTag == 0);
+ mbGeometryDidChange = false;
+
if ( !mpNSWindow )
return;
@@ -1534,38 +1541,65 @@ void AquaSalFrame::UpdateFrameGeometry()
NSScreen * pScreen = [mpNSWindow screen];
if( pScreen )
{
- maScreenRect = [pScreen frame];
+ NSRect aNewScreenRect = [pScreen frame];
+ if (bFirstTime || !NSEqualRects(maScreenRect, aNewScreenRect))
+ {
+ mbGeometryDidChange = true;
+ maScreenRect = aNewScreenRect;
+ }
NSArray* pScreens = [NSScreen screens];
if( pScreens )
- maGeometry.nDisplayScreenNumber = [pScreens indexOfObject: pScreen];
+ {
+ unsigned int nNewDisplayScreenNumber = [pScreens indexOfObject: pScreen];
+ if (bFirstTime || maGeometry.nDisplayScreenNumber != nNewDisplayScreenNumber)
+ {
+ mbGeometryDidChange = true;
+ maGeometry.nDisplayScreenNumber = nNewDisplayScreenNumber;
+ }
+ }
}
NSRect aFrameRect = [mpNSWindow frame];
NSRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask];
- // release old track rect
- [mpNSView removeTrackingRect: mnTrackingRectTag];
- // install the new track rect
NSRect aTrackRect = { NSZeroPoint, aContentRect.size };
- mnTrackingRectTag = [mpNSView addTrackingRect: aTrackRect owner: mpNSView userData: nil assumeInside: NO];
+
+ if (bFirstTime || !NSEqualRects(maTrackingRect, aTrackRect))
+ {
+ mbGeometryDidChange = true;
+ maTrackingRect = aTrackRect;
+
+ // release old track rect
+ [mpNSView removeTrackingRect: mnTrackingRectTag];
+ // install the new track rect
+ mnTrackingRectTag = [mpNSView addTrackingRect: aTrackRect owner: mpNSView userData: nil assumeInside: NO];
+ }
// convert to vcl convention
CocoaToVCL( aFrameRect );
CocoaToVCL( aContentRect );
- maGeometry.nX = static_cast<int>(aContentRect.origin.x);
- maGeometry.nY = static_cast<int>(aContentRect.origin.y);
+ if (bFirstTime || !NSEqualRects(maContentRect, aContentRect) || !NSEqualRects(maFrameRect, aFrameRect))
+ {
+ mbGeometryDidChange = true;
+
+ maContentRect = aContentRect;
+ maFrameRect = aFrameRect;
- maGeometry.nLeftDecoration = static_cast<unsigned int>(aContentRect.origin.x - aFrameRect.origin.x);
- maGeometry.nRightDecoration = static_cast<unsigned int>((aFrameRect.origin.x + aFrameRect.size.width) -
- (aContentRect.origin.x + aContentRect.size.width));
+ maGeometry.nX = static_cast<int>(aContentRect.origin.x);
+ maGeometry.nY = static_cast<int>(aContentRect.origin.y);
- maGeometry.nTopDecoration = static_cast<unsigned int>(aContentRect.origin.y - aFrameRect.origin.y);
- maGeometry.nBottomDecoration = static_cast<unsigned int>((aFrameRect.origin.y + aFrameRect.size.height) -
- (aContentRect.origin.y + aContentRect.size.height));
+ maGeometry.nLeftDecoration = static_cast<unsigned int>(aContentRect.origin.x - aFrameRect.origin.x);
+ maGeometry.nRightDecoration = static_cast<unsigned int>((aFrameRect.origin.x + aFrameRect.size.width) -
+ (aContentRect.origin.x + aContentRect.size.width));
- maGeometry.nWidth = static_cast<unsigned int>(aContentRect.size.width);
- maGeometry.nHeight = static_cast<unsigned int>(aContentRect.size.height);
+ maGeometry.nTopDecoration = static_cast<unsigned int>(aContentRect.origin.y - aFrameRect.origin.y);
+ maGeometry.nBottomDecoration = static_cast<unsigned int>((aFrameRect.origin.y + aFrameRect.size.height) -
+ (aContentRect.origin.y + aContentRect.size.height));
+
+ maGeometry.nWidth = static_cast<unsigned int>(aContentRect.size.width);
+ maGeometry.nHeight = static_cast<unsigned int>(aContentRect.size.height);
+ }
}
void AquaSalFrame::CaptureMouse( bool bCapture )