Merge branch 'fix-macos-cur-update' of https://github.com/page-down/kitty

This commit is contained in:
Kovid Goyal 2022-02-18 13:40:05 +05:30
commit 702bb2cd06
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 44 additions and 6 deletions

View File

@ -144,6 +144,10 @@ Detailed list of changes
- Add an option :opt:`wheel_scroll_min_lines` to set the minimum number of lines for mouse wheel scrolling when using a mouse with a wheel that generates very small offsets when slow scrolling (:pull:`4710`) - Add an option :opt:`wheel_scroll_min_lines` to set the minimum number of lines for mouse wheel scrolling when using a mouse with a wheel that generates very small offsets when slow scrolling (:pull:`4710`)
- macOS: Allows to configure the toggle fullscreen shortcut in global menu. (:pull:`4714`)
- macOS: Fix the mouse cursor being set to arrow after switching desktops or toggling fullscreen. (:pull:`4716`)
0.24.2 [2022-02-03] 0.24.2 [2022-02-03]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -154,6 +154,8 @@ typedef struct _GLFWwindowNS
// Whether a render frame has been requested for this window // Whether a render frame has been requested for this window
bool renderFrameRequested; bool renderFrameRequested;
GLFWcocoarenderframefun renderFrameCallback; GLFWcocoarenderframefun renderFrameCallback;
// update cursor after switching desktops with Mission Control
bool initialCursorUpdateRequested;
} _GLFWwindowNS; } _GLFWwindowNS;
typedef struct _GLFWDisplayLinkNS typedef struct _GLFWDisplayLinkNS

View File

@ -582,6 +582,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} }
- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow; - (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
- (void)requestInitialCursorUpdate:(id)sender;
@end @end
@ -692,6 +693,9 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
_glfwPlatformGetCursorPos(window, &x, &y); _glfwPlatformGetCursorPos(window, &x, &y);
_glfwInputCursorPos(window, x, y); _glfwInputCursorPos(window, x, y);
} }
// macOS will send a delayed event to update the cursor to arrow after switching desktops.
// So we need to delay and update the cursor once after that.
[self performSelector:@selector(requestInitialCursorUpdate:) withObject:nil afterDelay:0.3];
} }
- (void)windowDidResignKey:(NSNotification *)notification - (void)windowDidResignKey:(NSNotification *)notification
@ -722,16 +726,36 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} }
} }
- (void)requestInitialCursorUpdate:(id)sender
{
(void)sender;
if (window) window->ns.initialCursorUpdateRequested = true;
}
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
(void)notification;
if (window) window->ns.in_fullscreen_transition = true;
}
- (void)windowDidEnterFullScreen:(NSNotification *)notification - (void)windowDidEnterFullScreen:(NSNotification *)notification
{ {
(void)notification; (void)notification;
window->ns.in_fullscreen_transition = false; if (window) window->ns.in_fullscreen_transition = false;
[self performSelector:@selector(requestInitialCursorUpdate:) withObject:nil afterDelay:0.3];
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
(void)notification;
if (window) window->ns.in_fullscreen_transition = true;
} }
- (void)windowDidExitFullScreen:(NSNotification *)notification - (void)windowDidExitFullScreen:(NSNotification *)notification
{ {
(void)notification; (void)notification;
window->ns.in_fullscreen_transition = false; if (window) window->ns.in_fullscreen_transition = false;
[self performSelector:@selector(requestInitialCursorUpdate:) withObject:nil afterDelay:0.3];
} }
@end // }}} @end // }}}
@ -916,6 +940,11 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
window->ns.cursorWarpDeltaX = 0; window->ns.cursorWarpDeltaX = 0;
window->ns.cursorWarpDeltaY = 0; window->ns.cursorWarpDeltaY = 0;
if (window->ns.initialCursorUpdateRequested) {
window->ns.initialCursorUpdateRequested = false;
if (cursorInContentArea(window)) updateCursorImage(window);
}
} }
- (void)rightMouseDown:(NSEvent *)event - (void)rightMouseDown:(NSEvent *)event
@ -1015,6 +1044,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)updateTrackingAreas - (void)updateTrackingAreas
{ {
if (window && [window->ns.object areCursorRectsEnabled])
[window->ns.object disableCursorRects];
if (trackingArea != nil) if (trackingArea != nil)
{ {
[self removeTrackingArea:trackingArea]; [self removeTrackingArea:trackingArea];
@ -1566,10 +1597,11 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
- (void)toggleFullScreen:(nullable id)sender - (void)toggleFullScreen:(nullable id)sender
{ {
if (glfw_window) {
if (glfw_window->ns.in_fullscreen_transition) return; if (glfw_window->ns.in_fullscreen_transition) return;
if (glfw_window && glfw_window->ns.toggleFullscreenCallback && glfw_window->ns.toggleFullscreenCallback((GLFWwindow*)glfw_window) == 1) if (glfw_window->ns.toggleFullscreenCallback && glfw_window->ns.toggleFullscreenCallback((GLFWwindow*)glfw_window) == 1) return;
return;
glfw_window->ns.in_fullscreen_transition = true; glfw_window->ns.in_fullscreen_transition = true;
}
// When resizeIncrements is set, Cocoa cannot restore the original window size after returning from fullscreen. // When resizeIncrements is set, Cocoa cannot restore the original window size after returning from fullscreen.
const NSSize original = [self resizeIncrements]; const NSSize original = [self resizeIncrements];
[self setResizeIncrements:NSMakeSize(1.0, 1.0)]; [self setResizeIncrements:NSMakeSize(1.0, 1.0)];