Kaydet (Commit) 33b094a8 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

OSX fix updates during resize

While resizing MacOS suspends the NSDefaultRunLoopMode. So in this
caae we can't post to the system event loop, but must use timers
to restart ourself.

Since the timer itself is scheduled on the NSEventTrackingRunLoopMode
it' also triggers on resize events.

There is still some minor glitch: when resizing too fast some part of
LibreOffice isn't painted, while the left mouse button is down.

Since there isn't any layouting triggered by the mouse up, there has
to be an other inconsistency.

Change-Id: I3ccba78bd23ec8526f21e7b93b027f3d3279f901
üst e4000dbe
...@@ -91,9 +91,14 @@ can be added to the scheduler reasonably. ...@@ -91,9 +91,14 @@ can be added to the scheduler reasonably.
== MacOS implementation details == == MacOS implementation details ==
Generally the Scheduler is handled as expected. There is a workaround for a Generally the Scheduler is handled as expected, except on resize, which is
problem for pushing tasks to an empty queue, as [NSApp postEvent: ... handled with different runloop-modes in MacOS. In case of a resize, the normal
atStart: NO] doesn't append the event, if the message queue is empty. runloop is suspended in sendEvent, so we can't call the scheduler via posted
main loop-events. Instead the schedule the timer again.
There is also a workaround for a problem for pushing tasks to an empty queue,
as [NSApp postEvent: ... atStart: NO] doesn't append the event, if the
message queue is empty.
Probably that's the reason, why some code comments spoke of lost events and Probably that's the reason, why some code comments spoke of lost events and
there was some distinct additional event processing implemented. there was some distinct additional event processing implemented.
......
...@@ -74,6 +74,7 @@ public: ...@@ -74,6 +74,7 @@ public:
std::list< SalUserEvent > maUserEvents; std::list< SalUserEvent > maUserEvents;
osl::Mutex maUserEventListMutex; osl::Mutex maUserEventListMutex;
osl::Condition maWaitingYieldCond; osl::Condition maWaitingYieldCond;
bool mbIsLiveResize;
static std::list<const ApplicationEvent*> aAppEventList; static std::list<const ApplicationEvent*> aAppEventList;
......
...@@ -533,6 +533,17 @@ private: ...@@ -533,6 +533,17 @@ private:
-(void)drawRect: (NSRect)aRect -(void)drawRect: (NSRect)aRect
{ {
if( GetSalData()->mpFirstInstance )
{
const bool bIsLiveResize = [self inLiveResize];
const bool bWasLiveResize = GetSalData()->mpFirstInstance->mbIsLiveResize;
if ( bWasLiveResize != bIsLiveResize )
{
GetSalData()->mpFirstInstance->mbIsLiveResize = bIsLiveResize;
Scheduler::ProcessTaskScheduling();
}
}
// HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex
TryGuard aTryGuard; TryGuard aTryGuard;
if( !aTryGuard.IsGuarded() ) if( !aTryGuard.IsGuarded() )
......
...@@ -347,6 +347,7 @@ void DestroySalInstance( SalInstance* pInst ) ...@@ -347,6 +347,7 @@ void DestroySalInstance( SalInstance* pInst )
AquaSalInstance::AquaSalInstance() AquaSalInstance::AquaSalInstance()
: maUserEventListMutex() : maUserEventListMutex()
, maWaitingYieldCond() , maWaitingYieldCond()
, mbIsLiveResize( false )
{ {
mpSalYieldMutex = new SalYieldMutex; mpSalYieldMutex = new SalYieldMutex;
mpSalYieldMutex->acquire(); mpSalYieldMutex->acquire();
......
...@@ -30,7 +30,13 @@ ...@@ -30,7 +30,13 @@
-(void)timerElapsed:(NSTimer*)pTimer -(void)timerElapsed:(NSTimer*)pTimer
{ {
(void)pTimer; (void)pTimer;
ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent, YES ); // nil the timer, as it is just invalidated after the firing function
AquaSalTimer::pRunningTimer = nil;
const AquaSalInstance *pInst = GetSalData()->mpFirstInstance;
if (pInst->mbIsLiveResize)
AquaSalTimer::handleDispatchTimerEvent();
else
ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent, YES );
} }
@end @end
......
...@@ -83,7 +83,7 @@ static void ImplSalStartTimer( sal_uLong nMS ) ...@@ -83,7 +83,7 @@ static void ImplSalStartTimer( sal_uLong nMS )
return; return;
} }
if ( 0 == nMS ) if ( 0 == nMS && !pSalData->mpFirstInstance->mbIsLiveResize )
{ {
ImplSalStopTimer(); ImplSalStopTimer();
ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent, NO ); ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent, NO );
...@@ -93,7 +93,7 @@ static void ImplSalStartTimer( sal_uLong nMS ) ...@@ -93,7 +93,7 @@ static void ImplSalStartTimer( sal_uLong nMS )
NSTimeInterval aTI = double(nMS) / 1000.0; NSTimeInterval aTI = double(nMS) / 1000.0;
if( AquaSalTimer::pRunningTimer != nil ) if( AquaSalTimer::pRunningTimer != nil )
{ {
if (rtl::math::approxEqual( if ([AquaSalTimer::pRunningTimer isValid] && rtl::math::approxEqual(
[AquaSalTimer::pRunningTimer timeInterval], aTI)) [AquaSalTimer::pRunningTimer timeInterval], aTI))
{ {
// set new fire date // set new fire date
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment