From: Alan Third <alan@idiocy.org>
To: Ben McGinnes <ben@adversary.org>
Cc: Philipp Stephani <p.stephani2@gmail.com>,
Emacs developers <emacs-devel@gnu.org>,
Noam Postavsky <npostavs@users.sourceforge.net>
Subject: Re: Emacs 26 MacOS bugs
Date: Sat, 10 Feb 2018 01:47:11 +0000 [thread overview]
Message-ID: <20180210014711.GA31157@breton.holly.idiocy.org> (raw)
In-Reply-To: <20180209163512.bgoqgj2ayyv4vvyq@adversary.org>
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
On Sat, Feb 10, 2018 at 03:35:12AM +1100, Ben McGinnes wrote:
> > Can you please try the attached patch?
>
> Yeah, I'll have to try it in a couple of days or so, I'm on the road
> at the moment.
Please ignore that last patch and test the one attached to this email.
I discovered a whole other range of problems when I tried building
against GNUstep.
--
Alan Third
[-- Attachment #2: v2-0001-Fix-modifier-keys-on-NS-port.patch --]
[-- Type: text/plain, Size: 6562 bytes --]
From 776cd862aa7686e3e72db190c2116b0bf946ca7e Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Wed, 7 Feb 2018 22:39:17 +0000
Subject: [PATCH v2] Fix modifier keys on NS port
* src/nsterm.m (EV_MODIFIERS_OPTION):
(EV_MODIFIERS_CONTROL):
(EV_MODIFIERS_COMMAND): New macros.
(ev_modifiers_helper): New function.
(EV_MODIFIERS2): Use new helper function.
(EmacsView::keyDown): Remove duplicate functionality and handle fn key
correctly.
---
src/nsterm.m | 94 +++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 58 insertions(+), 36 deletions(-)
diff --git a/src/nsterm.m b/src/nsterm.m
index b7f5a32c09..f017d8d152 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -352,31 +352,56 @@ - (NSColor *)colorUsingDefaultColorSpace
#define NSRightCommandKeyMask (0x000010 | NSEventModifierFlagCommand)
#define NSLeftAlternateKeyMask (0x000020 | NSEventModifierFlagOption)
#define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption)
-#define EV_MODIFIERS2(flags) \
- (((flags & NSEventModifierFlagHelp) ? \
- hyper_modifier : 0) \
- | (!EQ (ns_right_alternate_modifier, Qleft) && \
- ((flags & NSRightAlternateKeyMask) \
- == NSRightAlternateKeyMask) ? \
- parse_solitary_modifier (ns_right_alternate_modifier) : 0) \
- | ((flags & NSEventModifierFlagOption) ? \
- parse_solitary_modifier (ns_alternate_modifier) : 0) \
- | ((flags & NSEventModifierFlagShift) ? \
- shift_modifier : 0) \
- | (!EQ (ns_right_control_modifier, Qleft) && \
- ((flags & NSRightControlKeyMask) \
- == NSRightControlKeyMask) ? \
- parse_solitary_modifier (ns_right_control_modifier) : 0) \
- | ((flags & NSEventModifierFlagControl) ? \
- parse_solitary_modifier (ns_control_modifier) : 0) \
- | ((flags & NS_FUNCTION_KEY_MASK) ? \
- parse_solitary_modifier (ns_function_modifier) : 0) \
- | (!EQ (ns_right_command_modifier, Qleft) && \
- ((flags & NSRightCommandKeyMask) \
- == NSRightCommandKeyMask) ? \
- parse_solitary_modifier (ns_right_command_modifier) : 0) \
- | ((flags & NSEventModifierFlagCommand) ? \
- parse_solitary_modifier (ns_command_modifier):0))
+
+static unsigned int
+ev_modifiers_helper (unsigned int flags, unsigned int left_mask,
+ unsigned int right_mask, unsigned int either_mask,
+ Lisp_Object left_modifier, Lisp_Object right_modifier)
+{
+ unsigned int modifiers = 0;
+
+ if (flags & either_mask)
+ {
+ BOOL left_key = (flags & left_mask) == left_mask;
+ BOOL right_key = (flags & right_mask) == right_mask
+ && ! EQ (right_modifier, Qleft);
+
+ if (right_key)
+ modifiers |= parse_solitary_modifier (right_modifier);
+
+ /* GNUstep (and possibly macOS in certain circumstances) doesn't
+ differentiate between the left and right keys, so if we can't
+ identify which key it is, we use the left key setting. */
+ if (left_key || ! right_key)
+ modifiers |= parse_solitary_modifier (left_modifier);
+ }
+
+ return modifiers;
+}
+
+#define EV_MODIFIERS2(flags) \
+ (((flags & NSEventModifierFlagHelp) ? \
+ hyper_modifier : 0) \
+ | ((flags & NSEventModifierFlagShift) ? \
+ shift_modifier : 0) \
+ | ((flags & NS_FUNCTION_KEY_MASK) ? \
+ parse_solitary_modifier (ns_function_modifier) : 0) \
+ | ev_modifiers_helper (flags, NSLeftControlKeyMask, \
+ NSRightControlKeyMask, \
+ NSEventModifierFlagControl, \
+ ns_control_modifier, \
+ ns_right_control_modifier) \
+ | ev_modifiers_helper (flags, NSLeftCommandKeyMask, \
+ NSRightCommandKeyMask, \
+ NSEventModifierFlagCommand, \
+ ns_command_modifier, \
+ ns_right_command_modifier) \
+ | ev_modifiers_helper (flags, NSLeftAlternateKeyMask, \
+ NSRightAlternateKeyMask, \
+ NSEventModifierFlagOption, \
+ ns_alternate_modifier, \
+ ns_right_alternate_modifier))
+
#define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags])
#define EV_UDMODIFIERS(e) \
@@ -6130,15 +6155,6 @@ flag set (this is probably a bug in the OS).
code = fnKeysym;
}
- /* are there modifiers? */
- emacs_event->modifiers = 0;
-
- if (flags & NSEventModifierFlagHelp)
- emacs_event->modifiers |= hyper_modifier;
-
- if (flags & NSEventModifierFlagShift)
- emacs_event->modifiers |= shift_modifier;
-
/* The ⌘ and ⌥ modifiers can be either shift-like (for alternate
character input) or control-like (as command prefix). If we
have only shift-like modifiers, then we should use the
@@ -6155,8 +6171,14 @@ untranslated characters (returned by the
modifier keys, which returns 0 for shift-like modifiers.
Therefore its return value is the set of control-like
modifiers. */
- unsigned int control_modifiers = EV_MODIFIERS2 (flags);
- emacs_event->modifiers |= control_modifiers;
+ emacs_event->modifiers = EV_MODIFIERS2 (flags);
+
+ /* Function keys (such as the F-keys, arrow keys, etc.) behave
+ as though the fn key has been pressed even when it hasn't.
+ We need to unset the fn modifier if one of these keys is
+ pressed. FIXME: Avoid setting it in the first place. */
+ if (fnKeysym && (flags & NS_FUNCTION_KEY_MASK))
+ emacs_event->modifiers ^= parse_solitary_modifier (ns_function_modifier);
if (NS_KEYLOG)
fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",
--
2.16.1
next prev parent reply other threads:[~2018-02-10 1:47 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 14:49 Emacs 26 MacOS bugs Richard Stallman
2018-02-06 17:30 ` Noam Postavsky
2018-02-06 23:28 ` Paul Eggert
2018-02-07 3:37 ` Eli Zaretskii
2018-02-10 14:55 ` Uwe Brauer
2018-02-10 15:18 ` Noam Postavsky
2018-02-07 3:52 ` Eli Zaretskii
2018-02-06 19:05 ` Ben McGinnes
2018-02-06 20:30 ` Noam Postavsky
2018-02-06 22:27 ` Ben McGinnes
2018-02-06 22:30 ` Ben McGinnes
2018-02-06 22:50 ` Noam Postavsky
2018-02-07 0:43 ` Ben McGinnes
2018-02-07 1:33 ` Noam Postavsky
2018-02-07 2:13 ` Ben McGinnes
2018-02-07 22:55 ` Alan Third
2018-02-09 16:35 ` Ben McGinnes
2018-02-09 16:57 ` Noam Postavsky
2018-02-09 17:22 ` Ben McGinnes
2018-02-09 18:13 ` Noam Postavsky
2018-02-10 1:46 ` Ben McGinnes
2018-02-10 1:47 ` Alan Third [this message]
2018-02-11 13:53 ` Philipp Stephani
2018-02-11 21:06 ` Alan Third
2018-02-07 20:01 ` Alan Third
2018-02-10 15:01 ` Alan Third
2018-02-10 22:45 ` Alan Third
2018-02-11 11:47 ` Alan Third
2018-02-11 15:52 ` Eli Zaretskii
2018-02-11 20:57 ` Alan Third
2018-02-13 19:41 ` Ben McGinnes
2018-02-13 19:46 ` Noam Postavsky
2018-02-11 20:43 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180210014711.GA31157@breton.holly.idiocy.org \
--to=alan@idiocy.org \
--cc=ben@adversary.org \
--cc=emacs-devel@gnu.org \
--cc=npostavs@users.sourceforge.net \
--cc=p.stephani2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.