From 1c6bae636bb021e6185b60882f73092fe9b1ec90 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Feb 2023 12:17:59 +0530 Subject: [PATCH] Only accept service requests when we actually have a selection --- glfw/cocoa_window.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 290112d48..3d1bfc9ed 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1581,10 +1581,14 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) { // Support services receiving "public.utf8-plain-text" and "NSStringPboardType" - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { - if ([sendType isEqual:NSPasteboardTypeString] || [sendType isEqual:@"NSStringPboardType"]) { - return self; + if ( + (!sendType || [sendType isEqual:NSPasteboardTypeString] || [sendType isEqual:@"NSStringPboardType"]) && + (!returnType || [returnType isEqual:NSPasteboardTypeString] || [returnType isEqual:@"NSStringPboardType"]) + ) { + NSString *text = [self accessibilitySelectedText]; + if (text && text.length > 0) return self; } - return nil; + return [super validRequestorForSendType:sendType returnType:returnType]; } // Selected text as input to be sent to Services