From d74a705cdefcb1c3faf8103f0e9062ca0730c47e Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Tue, 4 Mar 2025 08:14:43 -0800 Subject: [PATCH] Add ns-click-through option to control activation click handling * src/nsterm.m (acceptsFirstMouse): Use ns_click_through variable instead of always returning YES. (syms_of_nsterm): Define ns-click-through variable. * lisp/cus-start.el: Add customization definition for ns-click-through. * etc/NEWS: Document the new option. (cherry picked from commit 3a8ce5ac9c4652eb87bf0bce835d82083061a28b) --- lisp/cus-start.el | 6 ++++++ src/nsterm.m | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 133f44c9fad..16e4f7e65b3 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -577,6 +577,12 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (ns-use-fullscreen-animation ns boolean "25.1") (ns-use-srgb-colorspace ns boolean "24.4") (ns-scroll-event-delta-factor ns float "29.1") + + (ns-click-through + ns (choice (const :tag "Never (nil)" :value nil) + (const :tag "Always (t)" :value t)) + "31.1") + ;; process.c (delete-exited-processes processes-basics boolean) (process-error-pause-time processes-basics integer "29.1") diff --git a/src/nsterm.m b/src/nsterm.m index e7108c817c8..fcd9377646f 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6891,7 +6891,7 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action) { NSTRACE_MSG ("First mouse event: type=%ld, clickCount=%ld", [theEvent type], [theEvent clickCount]); - return YES; + return ns_click_through; } - (void)resetCursorRects { @@ -11300,6 +11300,21 @@ This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */); doc: /* SKIP: real doc in xterm.c. */); x_underline_at_descent_line = 0; + // TODO: add an "auto" mode that passes clicks through to "utility" UI + // elements, selectis windows, and so on, but doesn't pass them + // through for commands in general --- consistent with + // other applications. + + DEFVAR_BOOL ("ns-click-through", + ns_click_through, + doc: /* Whether to pass activation clicks through to Emacs. +When nil, if Emacs is not focused, the click that focuses Emacs will not +be interpreted as a common. If t, it will be. For example, when nil, +if Emacs is inactive, two clicks are needed to move point: the first to +activate Emacs and the second to activate the mouse-1 binding. When t, +only a single click is needed. */); + ns_click_through = YES; + DEFSYM (Qx_underline_at_descent_line, "x-underline-at-descent-line"); DEFVAR_LISP ("ns-scroll-event-delta-factor", Vns_scroll_event_delta_factor, -- 2.39.5