Cocoa API keeps resetting our NSCursor

234 views Asked by At

We have an application that has a full screen video player and a floating window (pallet) can be brought up to give users tools to modify the video, there is only one view for video playback and all the drawing occur in there, its an NSOpenGLView subclass. If the user click on a button in the pallet, and then move of the pallet onto the video view we use mouseEntered: to update the cursor -[NSCursor set] to one to reflect that the user is drawing, but about a second after, Cocoa set the cursor back to the arrow cursor.

I created a Symbolic break point on -[NSCursor set] to see where this is coming from and this is the call stack I get.

0   ???                                 0x000000010cade785 0x0 + 4507690885,
1   Periscope HiDef4                    0x00000001001d3f70 main + 0,
2   AppKit                              0x00007fff4da7c55e __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 695,
3   QuartzCore                          0x00007fff5b73b8c7 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 49,
4   QuartzCore                          0x00007fff5b73a389 _ZN2CA11Transaction6commitEv + 171,
5   AppKit                              0x00007fff4e234a72 __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke + 283,
6   CoreFoundation                      0x00007fff503ca737 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23,
7   CoreFoundation                      0x00007fff503ca65f __CFRunLoopDoObservers + 511,
8   CoreFoundation                      0x00007fff503ad128 __CFRunLoopRun + 1240,
9   CoreFoundation                      0x00007fff503ac9b7 CFRunLoopRunSpecific + 487,
10  HIToolbox                           0x00007fff4f68cd96 RunCurrentEventLoopInMode + 286,
11  HIToolbox                           0x00007fff4f68cb06 ReceiveNextEventCommon + 613,
12  HIToolbox                           0x00007fff4f68c884 _BlockUntilNextEventMatchingListInModeWithFilter + 64,
13  AppKit                              0x00007fff4d93da73 _DPSNextEvent + 2085,
14  AppKit                              0x00007fff4e0d3e34 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044,
15  AppKit                              0x00007fff4d932885 -[NSApplication run] + 764,
16  AppKit                              0x00007fff4d901a72 NSApplicationMain + 804,
17  Periscope HiDef4                    0x00000001001d3f92 main + 34,
18  libdyld.dylib                       0x00007fff7828a015 start + 1,
19  ???                                 0x0000000000000003 0x0 + 3

I tried changing the implementation from using -[NSCursor set] and mouseEntered: events to -[NSView addCursorRect:cursor:] with a rect of the entire view bounds, but that wouldn't set the cursor at all, maybe because we are using an NSOpenGLView subclass?

The strange thing is the cursor is not always reset, if you click the button and pause and then move off the pallet we don't get the -[NSCursor set] with the above stack, its only if you move straight away, its possible its got something to do with the resize window frame cursor for the pallet changing, but I'm not sure.

I have come up with a hacky solution of using mouseMoved: to check the cursor is what its suppose to be, but it only works if the user moves the cursor and I would rather work out why I getting the unwanted -[NSCursor set] and fix that instead.

0

There are 0 answers