From: Nick Helm <nick@tenpoint.co.nz>
To: Alan Third <alan@idiocy.org>
Cc: 30929@debbugs.gnu.org
Subject: bug#30929: 26.0.91; Text drag and drop does not work
Date: Wed, 28 Mar 2018 22:20:13 +1300 [thread overview]
Message-ID: <m2bmf8sgj6.fsf@tenpoint.co.nz> (raw)
In-Reply-To: <20180325115732.GA52626@breton.holly.idiocy.org> (Alan Third's message of "Sun, 25 Mar 2018 12:57:32 +0100")
[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]
Hi Alan,
On Sun, 25 Mar 2018 at 12:57:32 +0100, Alan Third wrote:
> Looks like this is how the modifiers are set in performDragOperation
>
> if (! (op & (NSDragOperationMove|NSDragOperationDelete)) &&
> // URL drags contain all operations (0xf), don't allow all to be set.
> (op & 0xf) != 0xf)
> {
> if (op & NSDragOperationLink)
> modifiers |= NSEventModifierFlagControl;
> if (op & NSDragOperationCopy)
> modifiers |= NSEventModifierFlagOption;
> if (op & NSDragOperationGeneric)
> modifiers |= NSEventModifierFlagCommand;
> }
>
> modifiers = EV_MODIFIERS2 (modifiers);
>
> It’s setting the actual modifier keys, so when a user changes those
> keys’ settings this breaks.
>
> You can also set these flags by using the actual modifier keys.
>
> This looks like it matches up with what Apple expect you to do, but it
> doesn’t seem to match up with Emacs’s event handling very well.
That looks about right to me too, it least it matches the general
approach in the docs.
I had a go at mapping the hardware modifiers to Emacs events (and
existing bindings) for each drag type and DragOperation mask. Patch
attached. This doesn't support the ns-right-*-modifiers yet, but they
should be pretty easy to add if you want to go this way.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improve-handling-of-drag-and-drop-modifiers-on-NS.patch --]
[-- Type: text/x-patch, Size: 4273 bytes --]
From 9a177de5bacde98ef5c513c73f7aa48b58909af4 Mon Sep 17 00:00:00 2001
From: Nick Helm <nick@tenpoint.co.nz>
Date: Wed, 28 Mar 2018 21:06:59 +1300
Subject: [PATCH] Improve handling of drag-and-drop modifiers on NS.
---
src/nsterm.m | 56 +++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 41 insertions(+), 15 deletions(-)
diff --git a/src/nsterm.m b/src/nsterm.m
index c8ae31abc0..4ad60d1b6a 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8115,19 +8115,6 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
pb = [sender draggingPasteboard];
type = [pb availableTypeFromArray: ns_drag_types];
- if (! (op & (NSDragOperationMove|NSDragOperationDelete)) &&
- // URL drags contain all operations (0xf), don't allow all to be set.
- (op & 0xf) != 0xf)
- {
- if (op & NSDragOperationLink)
- modifiers |= NSEventModifierFlagControl;
- if (op & NSDragOperationCopy)
- modifiers |= NSEventModifierFlagOption;
- if (op & NSDragOperationGeneric)
- modifiers |= NSEventModifierFlagCommand;
- }
-
- modifiers = EV_MODIFIERS2 (modifiers);
if (type == 0)
{
return NO;
@@ -8141,13 +8128,24 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
if (!(files = [pb propertyListForType: type]))
return NO;
+ if (! (op & (NSDragOperationMove | NSDragOperationDelete)) &&
+ (op & 0xf) != 0xf)
+ {
+ if (op & NSDragOperationGeneric)
+ modifiers |= NSEventModifierFlagCommand;
+ else if (op & NSDragOperationLink)
+ modifiers |= NSEventModifierFlagControl;
+ else if (op & NSDragOperationCopy)
+ modifiers |= NSEventModifierFlagOption;
+ }
+
fenum = [files objectEnumerator];
while ( (file = [fenum nextObject]) )
{
emacs_event->kind = DRAG_N_DROP_EVENT;
XSETINT (emacs_event->x, x);
XSETINT (emacs_event->y, y);
- emacs_event->modifiers = modifiers;
+ emacs_event->modifiers = EV_MODIFIERS2 (modifiers);
emacs_event->arg = list2 (Qfile, build_string ([file UTF8String]));
EV_TRAILER (theEvent);
}
@@ -8158,10 +8156,22 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
NSURL *url = [NSURL URLFromPasteboard: pb];
if (url == nil) return NO;
+ if (! (op & (NSDragOperationMove|NSDragOperationDelete)) &&
+ // URL drags contain all operations (0xf), don't allow all to be set.
+ (op & 0xf) != 0xf)
+ {
+ if (op & NSDragOperationGeneric)
+ modifiers |= NSEventModifierFlagCommand;
+ else if (op & NSDragOperationLink)
+ modifiers |= NSEventModifierFlagControl;
+ else if (op & NSDragOperationCopy)
+ modifiers |= NSEventModifierFlagOption;
+ }
+
emacs_event->kind = DRAG_N_DROP_EVENT;
XSETINT (emacs_event->x, x);
XSETINT (emacs_event->y, y);
- emacs_event->modifiers = modifiers;
+ emacs_event->modifiers = EV_MODIFIERS2 (modifiers);
emacs_event->arg = list2 (Qurl,
build_string ([[url absoluteString]
UTF8String]));
@@ -8183,6 +8193,22 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
if (! (data = [pb stringForType: type]))
return NO;
+ if (! (op & (NSDragOperationMove | NSDragOperationDelete)) &&
+ (op & 0xf) != 0xf)
+ {
+ if ((op & NSDragOperationCopy) && (op & NSDragOperationGeneric))
+ modifiers |= meta_modifier;
+ else if (op & NSDragOperationGeneric)
+ modifiers |= (parse_solitary_modifier (ns_command_modifier)
+ | meta_modifier);
+ else if (op & NSDragOperationCopy)
+ modifiers |= (parse_solitary_modifier (ns_alternate_modifier)
+ | meta_modifier);
+ else
+ modifiers |= (parse_solitary_modifier (ns_control_modifier)
+ | meta_modifier);
+ }
+
emacs_event->kind = DRAG_N_DROP_EVENT;
XSETINT (emacs_event->x, x);
XSETINT (emacs_event->y, y);
--
2.14.3 (Apple Git-98)
next prev parent reply other threads:[~2018-03-28 9:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-24 12:28 bug#30929: 26.0.91; Text drag and drop does not work Nick Helm
2018-03-25 11:57 ` Alan Third
2018-03-28 9:20 ` Nick Helm [this message]
2018-04-07 15:01 ` Alan Third
2018-04-09 1:51 ` Nick Helm
2018-04-10 19:38 ` Alan Third
2018-04-12 5:34 ` Nick Helm
2018-04-13 18:33 ` Alan Third
2018-04-24 12:42 ` Nick Helm
2018-04-24 18:19 ` Alan Third
2018-04-25 23:16 ` Nick Helm
2018-04-26 20:44 ` Alan Third
2018-04-28 9:57 ` Nick Helm
2019-01-05 10:27 ` Alan Third
2019-01-05 13:05 ` Nick Helm
2019-01-05 16:20 ` Alan Third
2019-01-07 10:38 ` Nick Helm
2019-01-10 19:23 ` Alan Third
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=m2bmf8sgj6.fsf@tenpoint.co.nz \
--to=nick@tenpoint.co.nz \
--cc=30929@debbugs.gnu.org \
--cc=alan@idiocy.org \
/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.