mirror of https://github.com/mpv-player/mpv
cocoa: fix cursor hiding at the top of the screen in fullscreen
even before the recent refactor the cursor was hidden when moving it to the top of the screen in fullscreen and placing it on top of the now visible menu bar. we need to know when the menu bar is hidden so we don’t create a ‘dead zone’ at the top of the screen where the cursor can’t be hidden. to determine when the menu bar is visible, and with that the title bar, we get the height of the menu bar. the height is always 0 when hidden. furthermore there is no way to get the title bar directly and with that its height. so we calculate the frame rect of a NSWindowStyleMaskTitled window from a CGRectZero content frame. the resulting height is the height of a title bar. with that we can exclude the top area for the cursor hiding and can be certain when the menu bar is not hidden.
This commit is contained in:
parent
d45074455a
commit
4f74b93546
|
@ -86,7 +86,19 @@
|
|||
|
||||
- (BOOL)containsMouseLocation
|
||||
{
|
||||
CGFloat topMargin = 0.0;
|
||||
CGFloat menuBarHeight = [[NSApp mainMenu] menuBarHeight];
|
||||
|
||||
// menuBarHeight is 0 when menu bar is hidden in fullscreen
|
||||
// 1pt to compensate of the black line beneath the menu bar
|
||||
if ([self.adapter isInFullScreenMode] && menuBarHeight > 0) {
|
||||
NSRect tr = [NSWindow frameRectForContentRect:CGRectZero
|
||||
styleMask:NSWindowStyleMaskTitled];
|
||||
topMargin = tr.size.height + 1 + menuBarHeight;
|
||||
}
|
||||
|
||||
NSRect vF = [[self.window screen] frame];
|
||||
vF.size.height -= topMargin;
|
||||
NSRect vFW = [self.window convertRectFromScreen:vF];
|
||||
NSRect vFV = [self convertRect:vFW fromView:nil];
|
||||
NSPoint pt = [self convertPoint:[self mouseLocation] fromView:nil];
|
||||
|
|
Loading…
Reference in New Issue