unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 2021835326 2/3: Implement `return-frame' for DND on NS
       [not found] ` <20220531100643.37E30C0C1B3@vcs2.savannah.gnu.org>
@ 2022-05-31 13:07   ` Po Lu
  2023-01-26 11:29     ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 3+ messages in thread
From: Po Lu @ 2022-05-31 13:07 UTC (permalink / raw)
  To: emacs-devel

Po Lu via Mailing list for Emacs changes <emacs-diffs@gnu.org> writes:

> +#ifdef NS_IMPL_COCOA
> +- (void) draggedImage: (NSImage *) dragged_image
> +	      movedTo: (NSPoint) screen_point
> +{
> +  NSInteger window_number;
> +  NSWindow *w;
> +
> +  if (dnd_mode == RETURN_FRAME_NEVER)
> +    return;
> +
> +  window_number = [NSWindow windowNumberAtPoint: [NSEvent mouseLocation]
> +		    belowWindowWithWindowNumber: 0];
> +  w = [NSApp windowWithWindowNumber: window_number];
> +
> +  if (!w || w != self)
> +    dnd_mode = RETURN_FRAME_NOW;
> +
> +  if (dnd_mode != RETURN_FRAME_NOW
> +      || ![[w delegate] isKindOfClass: [EmacsView class]])
> +    return;
> +
> +  dnd_return_frame = ((EmacsView *) [w delegate])->emacsframe;
> +
> +  /* FIXME: there must be a better way to leave the event loop.  */
> +  [NSException raise: @""
> +	      format: @"Must return DND frame"];
> +}
> +#endif

This works (and there's nothing in the documentation forbidding it), but
prints an ugly warning message to stdout every time the exception is
raised.  Does anyone know of a better way to stop an NS drag-and-drop
operation inside one of the drag source callbacks?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master 2021835326 2/3: Implement `return-frame' for DND on NS
  2022-05-31 13:07   ` master 2021835326 2/3: Implement `return-frame' for DND on NS Po Lu
@ 2023-01-26 11:29     ` YAMAMOTO Mitsuharu
  2023-01-26 11:43       ` Po Lu
  0 siblings, 1 reply; 3+ messages in thread
From: YAMAMOTO Mitsuharu @ 2023-01-26 11:29 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

On Tue, 31 May 2022 22:07:23 +0900,
Po Lu wrote:
> 
> > +  /* FIXME: there must be a better way to leave the event loop.  */
> > +  [NSException raise: @""
> > +	      format: @"Must return DND frame"];
> > +}
> > +#endif
> 
> This works (and there's nothing in the documentation forbidding it), but
> prints an ugly warning message to stdout every time the exception is
> raised.  Does anyone know of a better way to stop an NS drag-and-drop
> operation inside one of the drag source callbacks?

Posting ESC KeyDown event seems to work, as long as I tested with
Emacs 29-based Mac port (in development).

BTW, I think safe_call/redisplay in -[EmacsView draggingUpdated:] is
unsafe in some situations.  This method is called from the main thread
in the context of `select' emulation if the dragging is originated
from another application.  Because `thread_select' may cause thread
switching if we have multiple Lisp threads, Lisp evaluation in another
thread might be in progress while the main thread is waiting for the
completion of the `select' emulation.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master 2021835326 2/3: Implement `return-frame' for DND on NS
  2023-01-26 11:29     ` YAMAMOTO Mitsuharu
@ 2023-01-26 11:43       ` Po Lu
  0 siblings, 0 replies; 3+ messages in thread
From: Po Lu @ 2023-01-26 11:43 UTC (permalink / raw)
  To: YAMAMOTO Mitsuharu; +Cc: emacs-devel

YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> writes:

> Posting ESC KeyDown event seems to work, as long as I tested with
> Emacs 29-based Mac port (in development).

Thank you.  I am not quite sure how to do that, could you please explain
how?

> BTW, I think safe_call/redisplay in -[EmacsView draggingUpdated:] is
> unsafe in some situations.  This method is called from the main thread
> in the context of `select' emulation if the dragging is originated
> from another application.  Because `thread_select' may cause thread
> switching if we have multiple Lisp threads, Lisp evaluation in another
> thread might be in progress while the main thread is waiting for the
> completion of the `select' emulation.

Could you please suggest a fix?



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-26 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <165399160266.27129.5728276928017774382@vcs2.savannah.gnu.org>
     [not found] ` <20220531100643.37E30C0C1B3@vcs2.savannah.gnu.org>
2022-05-31 13:07   ` master 2021835326 2/3: Implement `return-frame' for DND on NS Po Lu
2023-01-26 11:29     ` YAMAMOTO Mitsuharu
2023-01-26 11:43       ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).