Subject: bug#51658: [PATCH] Haiku port (again)

From: Eli Zaretskii <[email-masked]>
Date: Sun, 14 Nov 2021 12:28:22 +0200

> From: Po Lu <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 14 Nov 2021 17:36:01 +0800
> 
> >> > Why isn't this treated as drag-and-drop on other platforms?  Then you
> >> > won't need Haiku-specific documentation and events.
> >> 
> >> It might not specifically be a drag event: for example, the Tracker
> >> could ask Emacs to open a file, because the user selected it from the
> >> "Recent files" menu.
> 
> > The result is the same: Emacs visits a file.  I don't think I
> > understand why these events should be exposed to Lisp.
> 
> But drag-n-drop events have a POSITION argument, while a position isn't
> available when the system sends Emacs a B_REFS_FOUND message.

How is POSITION used?  Can't you fake POSITION, so we get the same
event as on other platforms?

> > Which part is specific to X?
> 
> The entire file is preconditioned on HAVE_X_SM, and is based on things
> such as `SmcInteractDone' that only make sense on X.
> 
> It also relies on functions like `emacs-session-save', which are in
> x-win.el and rely on X specific code.
> 
> > And if the current implementation uses X-specific code, it just means
> > the implementation should be extended to allow other platforms trigger
> > the same mechanism.  Any reason Haiku couldn't do that?
> 
> Haiku doesn't have a session manager, so it doesn't make sense to use
> the mechanism in xsmfns.c: the system doesn't try to restore Emacs when
> the system restarts, or to save Emacs's session information when it
> quits.
> 
> It tells the application that it's about to quit as a courtesy, so it
> can perhaps run a few popup dialogs informing the user to save his
> files.

Every modern system has something similar, so it would make sense to
have a unified mechanism for handling those system messages in Emacs.
If xsmfns.c is too X-specific, we should build a layer above it, and
then implement th lower layer for Haiku.  It makes no sense to me to
introduce new events for specific platforms when similar features
already exist and just need to be extended or abstracted.