From 4f74b935468fd8b39d4cf974892fa242bb059248 Mon Sep 17 00:00:00 2001 From: Akemi Date: Sun, 19 Feb 2017 03:25:32 +0100 Subject: cocoa: fix cursor hiding at the top of the screen in fullscreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- video/out/cocoa/events_view.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m index eda4781418..8be74d5e15 100644 --- a/video/out/cocoa/events_view.m +++ b/video/out/cocoa/events_view.m @@ -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]; -- cgit v1.2.3