diff options
author | Patrick Luby <guibmacdev@gmail.com> | 2024-10-27 20:15:42 -0400 |
---|---|---|
committer | Patrick Luby <guibomacdev@gmail.com> | 2024-11-08 17:44:54 +0100 |
commit | dae9394768f217cde1ad0bfc1604f32a31882960 (patch) | |
tree | d407b7469f82cd0232f66d0b263304640203a7ab /vcl | |
parent | 3384fcc9172507f280ffd07df2a8de34fc1bf6ab (diff) |
Set the native tracking area in -[SalFrameView updateTrackingAreas]
NSTrackingArea has an immutable rectangle so it cannot grow when
the SalFrameView's window is resized. So, whenever the SalFrameView's
bounds change, remove the old NSTrackingArea and add a new one with
the SalFrameView's current bounds.
Change-Id: I70a5be7fbe6dd6b5f4f2ed4878dd12a36ab3622b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175708
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
Tested-by: Jenkins
(cherry picked from commit e7f27f96f0789939436cf1cb3dff79579a67cf3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175742
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/osx/salframeview.h | 3 | ||||
-rw-r--r-- | vcl/osx/salframe.cxx | 14 | ||||
-rw-r--r-- | vcl/osx/salframeview.mm | 34 |
3 files changed, 37 insertions, 14 deletions
diff --git a/vcl/inc/osx/salframeview.h b/vcl/inc/osx/salframeview.h index dec2f03a42f3..287ccaedbc06 100644 --- a/vcl/inc/osx/salframeview.h +++ b/vcl/inc/osx/salframeview.h @@ -111,6 +111,7 @@ enum class SalEvent; BOOL mbInCommitMarkedText; NSAttributedString* mpLastMarkedText; BOOL mbTextInputWantsNonRepeatKeyDown; + NSTrackingArea* mpLastTrackingArea; } +(void)unsetMouseFrame: (AquaSalFrame*)pFrame; -(id)initWithSalFrame: (AquaSalFrame*)pFrame; @@ -146,6 +147,8 @@ enum class SalEvent; -(BOOL)handleKeyDownException:(NSEvent*)pEvent; -(void)clearLastEvent; -(void)clearLastMarkedText; +-(void)clearLastTrackingArea; +-(void)updateTrackingAreas; /* text action methods */ diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index 940337b770a1..81aae45457a7 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -244,20 +244,6 @@ void AquaSalFrame::initWindowAndView() [mpNSWindow setRestorable:NO]; - // tdf#155092 use tracking areas instead of tracking rectangles - // Apparently, the older, tracking rectangles selectors cause - // unexpected window resizing upon the first mouse down after the - // window has been manually resized so switch to the newer, - // tracking areas selectors. Also, the NSTrackingInVisibleRect - // option allows us to create one single tracking area that - // resizes itself automatically over the lifetime of the view. - // Note: for some unknown reason, both NSTrackingMouseMoved and - // NSTrackingAssumeInside are necessary options for this fix - // to work. - NSTrackingArea *pTrackingArea = [[NSTrackingArea alloc] initWithRect: [mpNSView bounds] options: ( NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways | NSTrackingAssumeInside | NSTrackingInVisibleRect ) owner: mpNSView userInfo: nil]; - [mpNSView addTrackingArea: pTrackingArea]; - [pTrackingArea release]; - maSysData.mpNSView = mpNSView; UpdateFrameGeometry(); diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index fa59f1018a39..950cec3271eb 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -773,6 +773,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize) mbInCommitMarkedText = NO; mpLastMarkedText = nil; mbTextInputWantsNonRepeatKeyDown = NO; + mpLastTrackingArea = nil; } return self; @@ -782,6 +783,7 @@ static void updateWinDataInLiveResize(bool bInLiveResize) { [self clearLastEvent]; [self clearLastMarkedText]; + [self clearLastTrackingArea]; [self revokeWrapper]; [super dealloc]; @@ -2128,6 +2130,38 @@ static void updateWinDataInLiveResize(bool bInLiveResize) mbTextInputWantsNonRepeatKeyDown = NO; } +-(void)clearLastTrackingArea +{ + if (mpLastTrackingArea) + { + [self removeTrackingArea: mpLastTrackingArea]; + [mpLastTrackingArea release]; + mpLastTrackingArea = nil; + } +} + +-(void)updateTrackingAreas +{ + [super updateTrackingAreas]; + + // tdf#155092 use tracking areas instead of tracking rectangles + // Apparently, the older, tracking rectangles selectors cause + // unexpected window resizing upon the first mouse down after the + // window has been manually resized so switch to the newer, + // tracking areas selectors. Also, the NSTrackingInVisibleRect + // option allows us to create one single tracking area that + // resizes itself automatically over the lifetime of the view. + // Note: for some unknown reason, both NSTrackingMouseMoved and + // NSTrackingAssumeInside are necessary options for this fix + // to work. + // Note: for some unknown reason, [mpLastTrackingArea rect] + // returns an empty NSRect (at least on macOS Sequoia) so always + // remove the old tracking area and add a new one. + [self clearLastTrackingArea]; + mpLastTrackingArea = [[NSTrackingArea alloc] initWithRect: [self bounds] options: ( NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways | NSTrackingAssumeInside | NSTrackingInVisibleRect ) owner: self userInfo: nil]; + [self addTrackingArea: mpLastTrackingArea]; +} + - (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { // FIXME - These should probably be used? |