2020-08-05 00:15:41 +00:00
|
|
|
|
;;; x-dnd.el --- drag and drop support for X -*- lexical-binding: t; -*-
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2010-06-22 07:10:16 +00:00
|
|
|
|
;; Author: Jan Djärv <jan.h.d@swipnet.se>
|
2019-05-25 20:43:06 +00:00
|
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
2004-02-03 16:55:30 +00:00
|
|
|
|
;; Keywords: window, drag, drop
|
2010-08-29 16:17:13 +00:00
|
|
|
|
;; Package: emacs
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2004-02-03 16:55:30 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2022-06-16 06:33:30 +00:00
|
|
|
|
;; This file provides the receiving side of the XDND and Motif
|
|
|
|
|
;; protocols, and both the receiving and initiating ends of the old
|
|
|
|
|
;; KDE (OffiX) and new OffiX protocols.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
(require 'dnd)
|
2023-05-11 13:25:46 +00:00
|
|
|
|
;; For when building a --without-x configuration, where this is not
|
|
|
|
|
;; preloaded.
|
|
|
|
|
(eval-when-compile (require 'mwheel))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
;;; Customizable variables
|
2020-08-05 00:15:41 +00:00
|
|
|
|
(defcustom x-dnd-test-function #'x-dnd-default-test-function
|
2023-04-08 15:36:23 +00:00
|
|
|
|
"Function to be used by drag-and-drop to determine whether to accept a drop.
|
|
|
|
|
The function takes three arguments: WINDOW, ACTION, and TYPES.
|
|
|
|
|
WINDOW is where the window under the mouse is when the function is called.
|
|
|
|
|
WINDOW may be a frame if the mouse isn't over a real window (e.g., menu
|
|
|
|
|
bar, tool bar, scroll bar, etc.).
|
|
|
|
|
ACTION is the suggested action from the drag and drop source, one of the
|
|
|
|
|
symbols `move', `copy', `link' or `ask'.
|
|
|
|
|
TYPES is a vector of available types for the drop.
|
|
|
|
|
Each element of TYPES should either be a string (containing the
|
2022-06-13 07:01:06 +00:00
|
|
|
|
name of the type's X atom), or a symbol, whose name will be used.
|
|
|
|
|
|
|
|
|
|
The function shall return nil to reject the drop or a cons with
|
2023-04-08 15:36:23 +00:00
|
|
|
|
two values, the wanted action as `car' and the wanted type as `cdr'.
|
|
|
|
|
The wanted action can be `copy', `move', `link', `ask' or `private'.
|
2022-06-13 07:01:06 +00:00
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
The default value for this variable is `x-dnd-default-test-function'."
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1"
|
2004-02-03 16:55:30 +00:00
|
|
|
|
:type 'symbol
|
|
|
|
|
:group 'x)
|
|
|
|
|
|
|
|
|
|
(defcustom x-dnd-types-alist
|
2022-06-10 03:45:27 +00:00
|
|
|
|
`((,(purecopy "text/uri-list") . x-dnd-handle-uri-list)
|
2009-10-26 06:43:36 +00:00
|
|
|
|
(,(purecopy "text/x-moz-url") . x-dnd-handle-moz-url)
|
|
|
|
|
(,(purecopy "_NETSCAPE_URL") . x-dnd-handle-uri-list)
|
|
|
|
|
(,(purecopy "FILE_NAME") . x-dnd-handle-file-name)
|
|
|
|
|
(,(purecopy "UTF8_STRING") . x-dnd-insert-utf8-text)
|
|
|
|
|
(,(purecopy "text/plain;charset=UTF-8") . x-dnd-insert-utf8-text)
|
|
|
|
|
(,(purecopy "text/plain;charset=utf-8") . x-dnd-insert-utf8-text)
|
|
|
|
|
(,(purecopy "text/unicode") . x-dnd-insert-utf16-text)
|
|
|
|
|
(,(purecopy "text/plain") . dnd-insert-text)
|
|
|
|
|
(,(purecopy "COMPOUND_TEXT") . x-dnd-insert-ctext)
|
|
|
|
|
(,(purecopy "STRING") . dnd-insert-text)
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(,(purecopy "TEXT") . dnd-insert-text)
|
|
|
|
|
(,(purecopy "DndTypeFile") . x-dnd-handle-offix-file)
|
2022-06-16 02:39:01 +00:00
|
|
|
|
(,(purecopy "DndTypeFiles") . x-dnd-handle-offix-files)
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(,(purecopy "DndTypeText") . dnd-insert-text))
|
2023-04-08 15:36:23 +00:00
|
|
|
|
"Functions to call to handle drag-and-drop of known types.
|
|
|
|
|
If the type of the drop is not present in the alist, or the
|
|
|
|
|
function corresponding to the type is nil, the drop of that
|
|
|
|
|
type will be rejected.
|
|
|
|
|
|
|
|
|
|
Each function takes three arguments: WINDOW, ACTION, and DATA.
|
|
|
|
|
WINDOW is the window where the drop occurred.
|
|
|
|
|
ACTION is the action for this drop (`copy', `move', `link', `private'
|
|
|
|
|
or `ask'), as determined by a previous call to `x-dnd-test-function'.
|
|
|
|
|
DATA is the drop data.
|
|
|
|
|
The function shall return the action it used (one of the above,
|
|
|
|
|
excluding `ask') if drop is successful, nil if not."
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1"
|
2004-02-03 16:55:30 +00:00
|
|
|
|
:type 'alist
|
|
|
|
|
:group 'x)
|
|
|
|
|
|
2004-08-31 11:24:10 +00:00
|
|
|
|
(defcustom x-dnd-known-types
|
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
(tex-dvi-print-command, tex-bibtex-command, tex-start-commands)
(tex-start-options, slitex-run-command, latex-run-command)
(tex-run-command, tex-directory):
* textmodes/ispell.el (ispell-html-skip-alists)
(ispell-tex-skip-alists, ispell-tex-skip-alists):
* textmodes/fill.el (adaptive-fill-first-line-regexp):
(adaptive-fill-regexp):
* textmodes/dns-mode.el (auto-mode-alist):
* progmodes/python.el (interpreter-mode-alist):
* progmodes/etags.el (tags-compression-info-list):
* progmodes/etags.el (tags-file-name):
* net/browse-url.el (browse-url-galeon-program)
(browse-url-firefox-program):
* mail/sendmail.el (mail-signature-file)
(mail-citation-prefix-regexp):
* international/mule-conf.el (eight-bit):
* international/latexenc.el (latex-inputenc-coding-alist):
* international/fontset.el (x-pixel-size-width-font-regexp):
* emacs-lisp/warnings.el (warning-type-format):
* emacs-lisp/trace.el (trace-buffer):
* emacs-lisp/lisp-mode.el (lisp-interaction-mode-map)
(emacs-lisp-mode-map):
* calendar/holidays.el (holiday-solar-holidays)
(holiday-bahai-holidays, holiday-islamic-holidays)
(holiday-christian-holidays, holiday-hebrew-holidays)
(hebrew-holidays-4, hebrew-holidays-3, hebrew-holidays-2)
(hebrew-holidays-1, holiday-oriental-holidays)
(holiday-general-holidays):
* x-dnd.el (x-dnd-known-types):
* tool-bar.el (tool-bar):
* startup.el (site-run-file):
* shell.el (shell-dumb-shell-regexp):
* rfn-eshadow.el (file-name-shadow-tty-properties)
(file-name-shadow-properties):
* paths.el (remote-shell-program, news-directory):
* mouse.el ([C-down-mouse-3]):
* menu-bar.el (menu-bar-tools-menu):
* jka-cmpr-hook.el (jka-compr-load-suffixes)
(jka-compr-mode-alist-additions, jka-compr-compression-info-list)
(jka-compr-compression-info-list):
* isearch.el (search-whitespace-regexp):
* image-file.el (image-file-name-extensions):
* find-dired.el (find-ls-option):
* files.el (directory-listing-before-filename-regexp)
(directory-free-space-args, insert-directory-program)
(list-directory-brief-switches, magic-fallback-mode-alist)
(magic-fallback-mode-alist, auto-mode-interpreter-regexp)
(automount-dir-prefix):
* faces.el (face-x-resources, x-font-regexp, x-font-regexp-head)
(x-font-regexp-slant, x-font-regexp-weight, face-x-resources)
(face-font-registry-alternatives, face-font-registry-alternatives)
(face-font-family-alternatives):
* facemenu.el (facemenu-add-new-face, facemenu-background-menu)
(facemenu-foreground-menu, facemenu-face-menu):
* epa-hook.el (epa-file-name-regexp):
* dnd.el (dnd-protocol-alist):
* textmodes/rst.el (auto-mode-alist):
* button.el (default-button): Purecopy strings.
2009-11-06 05:16:23 +00:00
|
|
|
|
(mapcar 'purecopy
|
2022-07-01 08:12:45 +00:00
|
|
|
|
'("XdndDirectSave0"
|
|
|
|
|
"text/uri-list"
|
2022-06-29 12:10:25 +00:00
|
|
|
|
"text/x-moz-url"
|
|
|
|
|
"_NETSCAPE_URL"
|
|
|
|
|
"FILE_NAME"
|
|
|
|
|
"UTF8_STRING"
|
|
|
|
|
"text/plain;charset=UTF-8"
|
|
|
|
|
"text/plain;charset=utf-8"
|
|
|
|
|
"text/unicode"
|
|
|
|
|
"text/plain"
|
|
|
|
|
"COMPOUND_TEXT"
|
|
|
|
|
"STRING"
|
|
|
|
|
"TEXT"
|
|
|
|
|
"DndTypeFile"
|
|
|
|
|
"DndTypeText"))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
"The types accepted by default for dropped data.
|
2004-08-31 11:24:10 +00:00
|
|
|
|
The types are chosen in the order they appear in the list."
|
2005-02-09 15:50:47 +00:00
|
|
|
|
:version "22.1"
|
2004-08-31 11:24:10 +00:00
|
|
|
|
:type '(repeat string)
|
2022-06-13 07:01:06 +00:00
|
|
|
|
:group 'x)
|
2004-08-31 11:24:10 +00:00
|
|
|
|
|
2022-06-16 06:33:30 +00:00
|
|
|
|
(defcustom x-dnd-use-offix-drop 'files
|
2022-06-15 13:00:55 +00:00
|
|
|
|
"If non-nil, use the OffiX protocol to drop files and text.
|
|
|
|
|
This allows dropping (via `dired-mouse-drag-files' or
|
|
|
|
|
`mouse-drag-and-drop-region-cross-program') on some old Java
|
|
|
|
|
applets and old KDE programs. Turning this off allows dropping
|
2022-06-16 06:33:30 +00:00
|
|
|
|
only text on some other programs such as xterm and urxvt.
|
|
|
|
|
|
|
|
|
|
If the symbol `files', use the OffiX protocol when dropping
|
|
|
|
|
files, and the fallback drop method (which is used with programs
|
|
|
|
|
like xterm) for text."
|
2022-06-15 13:00:55 +00:00
|
|
|
|
:version "29.1"
|
2022-06-16 06:41:21 +00:00
|
|
|
|
:type '(choice (const :tag "Don't use the OffiX protocol for drag-and-drop" nil)
|
|
|
|
|
(const :tag "Only use the OffiX protocol to drop files" files)
|
|
|
|
|
(const :tag "Use the OffiX protocol for both files and text" t))
|
2022-06-15 13:00:55 +00:00
|
|
|
|
:group 'x)
|
|
|
|
|
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(defcustom x-dnd-direct-save-function #'x-dnd-save-direct
|
2023-04-08 15:36:23 +00:00
|
|
|
|
"Function called when a file is dropped via XDS protocol.
|
|
|
|
|
The value should be a function of two arguments that supports
|
|
|
|
|
the X Direct Save (XDS) protocol. The function will be called
|
|
|
|
|
twice during the protocol execution.
|
|
|
|
|
|
|
|
|
|
When the function is called with the first argument non-nil,
|
|
|
|
|
it should return an absolute file name whose base name is
|
|
|
|
|
the value of the second argument, a string. The return value
|
|
|
|
|
is the file name for the dragged file to be saved. The function
|
|
|
|
|
can also return nil if saving the file should be refused for some
|
|
|
|
|
reason; in that case the drop will be canceled.
|
|
|
|
|
|
|
|
|
|
When the function is called with the first argument nil, the
|
|
|
|
|
second argument specifies the file name where the file was saved;
|
|
|
|
|
the function should then do whatever is appropriate when such a
|
|
|
|
|
file is saved, like show the file in the Dired buffer or visit
|
|
|
|
|
the file."
|
2022-07-01 08:12:45 +00:00
|
|
|
|
:version "29.1"
|
2023-04-08 15:36:23 +00:00
|
|
|
|
:type '(choice (const :tag "Prompt for file name to save"
|
2022-07-05 06:55:24 +00:00
|
|
|
|
x-dnd-save-direct)
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(const :tag "Save in `default-directory' without prompting"
|
2022-07-05 06:55:24 +00:00
|
|
|
|
x-dnd-save-direct-immediately)
|
|
|
|
|
(function :tag "Other function"))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
:group 'x)
|
|
|
|
|
|
2022-07-02 06:06:28 +00:00
|
|
|
|
(defcustom x-dnd-copy-types '("chromium/x-renderer-taint")
|
|
|
|
|
"List of data types offered by programs that don't support `private'.
|
|
|
|
|
Some programs (such as Chromium) do not support
|
|
|
|
|
`XdndActionPrivate'. The default `x-dnd-test-function' will
|
|
|
|
|
always return `copy' instead, for programs offering one of the
|
|
|
|
|
data types in this list."
|
|
|
|
|
:version "29.1"
|
|
|
|
|
:type '(repeat string)
|
|
|
|
|
:group 'x)
|
|
|
|
|
|
2004-08-31 11:24:10 +00:00
|
|
|
|
;; Internal variables
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2022-07-03 01:41:32 +00:00
|
|
|
|
(defvar x-dnd-debug-errors nil
|
|
|
|
|
"Whether or not to signal protocol errors during drag-and-drop.
|
|
|
|
|
This is useful for debugging errors in the DND code, but makes
|
|
|
|
|
drag-and-drop much slower over network connections with high
|
|
|
|
|
latency.")
|
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(defvar x-dnd-current-state nil
|
|
|
|
|
"The current state for a drop.
|
|
|
|
|
This is an alist with one entry for each display. The value for each display
|
|
|
|
|
is a vector that contains the state for drag and drop for that display.
|
2005-02-09 15:50:47 +00:00
|
|
|
|
Elements in the vector are:
|
2004-02-03 16:55:30 +00:00
|
|
|
|
Last buffer drag was in,
|
|
|
|
|
last window drag was in,
|
2005-02-09 15:50:47 +00:00
|
|
|
|
types available for drop,
|
2004-02-03 16:55:30 +00:00
|
|
|
|
the action suggested by the source,
|
|
|
|
|
the type we want for the drop,
|
2004-02-10 17:27:26 +00:00
|
|
|
|
the action we want for the drop,
|
|
|
|
|
any protocol specific data.")
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2022-03-26 02:15:53 +00:00
|
|
|
|
(declare-function x-get-selection-internal "xselect.c"
|
|
|
|
|
(selection-symbol target-type &optional time-stamp terminal))
|
2022-06-17 02:24:05 +00:00
|
|
|
|
(declare-function x-display-set-last-user-time "xfns.c")
|
2022-03-26 02:15:53 +00:00
|
|
|
|
|
2022-03-26 02:17:12 +00:00
|
|
|
|
(defconst x-dnd-xdnd-to-action
|
|
|
|
|
'(("XdndActionPrivate" . private)
|
|
|
|
|
("XdndActionCopy" . copy)
|
|
|
|
|
("XdndActionMove" . move)
|
|
|
|
|
("XdndActionLink" . link)
|
2022-07-01 08:12:45 +00:00
|
|
|
|
("XdndActionAsk" . ask)
|
|
|
|
|
("XdndActionDirectSave" . direct-save))
|
2022-03-26 02:17:12 +00:00
|
|
|
|
"Mapping from XDND action types to Lisp symbols.")
|
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(defvar x-dnd-empty-state [nil nil nil nil nil nil nil])
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2007-11-22 13:52:35 +00:00
|
|
|
|
(declare-function x-register-dnd-atom "xselect.c")
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(defvar x-fast-protocol-requests)
|
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(defun x-dnd-init-frame (&optional frame)
|
|
|
|
|
"Setup drag and drop for FRAME (i.e. create appropriate properties)."
|
2022-07-24 02:43:52 +00:00
|
|
|
|
(when (and (eq 'x (window-system frame))
|
|
|
|
|
(not (frame-parameter frame 'tooltip)))
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(let ((x-fast-protocol-requests (not x-dnd-debug-errors)))
|
|
|
|
|
(x-register-dnd-atom "DndProtocol" frame)
|
|
|
|
|
(x-register-dnd-atom "_MOTIF_DRAG_AND_DROP_MESSAGE" frame)
|
|
|
|
|
(x-register-dnd-atom "XdndEnter" frame)
|
|
|
|
|
(x-register-dnd-atom "XdndPosition" frame)
|
|
|
|
|
(x-register-dnd-atom "XdndLeave" frame)
|
|
|
|
|
(x-register-dnd-atom "XdndDrop" frame)
|
|
|
|
|
(x-register-dnd-atom "_DND_PROTOCOL" frame)
|
|
|
|
|
(x-dnd-init-xdnd-for-frame frame)
|
|
|
|
|
(x-dnd-init-motif-for-frame frame))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-get-state-cons-for-frame (frame-or-window)
|
2009-02-26 10:26:32 +00:00
|
|
|
|
"Return the entry in `x-dnd-current-state' for a frame or window."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(let* ((frame (if (framep frame-or-window) frame-or-window
|
|
|
|
|
(window-frame frame-or-window)))
|
|
|
|
|
(display (frame-parameter frame 'display)))
|
|
|
|
|
(if (not (assoc display x-dnd-current-state))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(push (cons display (copy-sequence x-dnd-empty-state))
|
|
|
|
|
x-dnd-current-state))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(assoc display x-dnd-current-state)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-get-state-for-frame (frame-or-window)
|
2009-02-26 10:26:32 +00:00
|
|
|
|
"Return the state in `x-dnd-current-state' for a frame or window."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(cdr (x-dnd-get-state-cons-for-frame frame-or-window)))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun x-dnd-default-test-function (_window _action types)
|
2023-04-08 15:36:23 +00:00
|
|
|
|
"The default test function for drag-and-drop.
|
2022-07-02 06:06:28 +00:00
|
|
|
|
WINDOW is where the mouse is when this function is called. It
|
|
|
|
|
may be a frame if the mouse is over the menu bar, scroll bar or
|
|
|
|
|
tool bar. ACTION is the suggested action from the source, and
|
|
|
|
|
TYPES are the types the drop data can have. This function only
|
|
|
|
|
accepts drops with types in `x-dnd-known-types'. It always
|
|
|
|
|
returns the action `private', unless `types' contains a value
|
2023-04-08 15:36:23 +00:00
|
|
|
|
inside `x-dnd-copy-types', in which case it may return `copy'."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(let ((type (x-dnd-choose-type types)))
|
2022-07-02 06:06:28 +00:00
|
|
|
|
(when type (let ((list x-dnd-copy-types))
|
|
|
|
|
(catch 'out
|
|
|
|
|
(while t
|
|
|
|
|
(if (not list)
|
|
|
|
|
(throw 'out (cons 'private type))
|
|
|
|
|
(if (x-dnd-find-type (car list) types)
|
|
|
|
|
(throw 'out (cons 'copy type))
|
|
|
|
|
(setq list (cdr list))))))))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-current-type (frame-or-window)
|
|
|
|
|
"Return the type we want the DND data to be in for the current drop.
|
|
|
|
|
FRAME-OR-WINDOW is the frame or window that the mouse is over."
|
|
|
|
|
(aref (x-dnd-get-state-for-frame frame-or-window) 4))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-forget-drop (frame-or-window)
|
|
|
|
|
"Remove all state for the last drop.
|
|
|
|
|
FRAME-OR-WINDOW is the frame or window that the mouse is over."
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(setcdr (x-dnd-get-state-cons-for-frame frame-or-window)
|
|
|
|
|
(copy-sequence x-dnd-empty-state)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(defun x-dnd-find-type (target types)
|
|
|
|
|
"Find the type TARGET in an array of types TYPES.
|
|
|
|
|
TARGET must be a string, but TYPES can contain either symbols or
|
|
|
|
|
strings."
|
|
|
|
|
(catch 'done
|
|
|
|
|
(dotimes (i (length types))
|
|
|
|
|
(let* ((type (aref types i))
|
|
|
|
|
(typename (if (symbolp type)
|
|
|
|
|
(symbol-name type) type)))
|
|
|
|
|
(when (equal target typename)
|
|
|
|
|
(throw 'done t))))
|
|
|
|
|
nil))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-maybe-call-test-function (window action &optional xdnd)
|
2004-02-03 16:55:30 +00:00
|
|
|
|
"Call `x-dnd-test-function' if something has changed.
|
|
|
|
|
WINDOW is the window the mouse is over. ACTION is the suggested
|
|
|
|
|
action from the source. If nothing has changed, return the last
|
2022-07-01 08:12:45 +00:00
|
|
|
|
action and type we got from `x-dnd-test-function'.
|
|
|
|
|
|
|
|
|
|
XDND means the XDND protocol is being used."
|
2007-06-14 00:09:10 +00:00
|
|
|
|
(let ((buffer (when (window-live-p window)
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(window-buffer window)))
|
|
|
|
|
(current-state (x-dnd-get-state-for-frame window)))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(if (and xdnd (x-dnd-find-type "XdndDirectSave0"
|
|
|
|
|
(aref current-state 2)))
|
|
|
|
|
(setq current-state
|
|
|
|
|
(x-dnd-save-state window 'direct-save
|
|
|
|
|
'(direct-save . "XdndDirectSave0")))
|
|
|
|
|
(unless (and (equal buffer (aref current-state 0))
|
|
|
|
|
(equal window (aref current-state 1))
|
|
|
|
|
(equal action (aref current-state 3)))
|
|
|
|
|
(save-current-buffer
|
|
|
|
|
(when buffer (set-buffer buffer))
|
|
|
|
|
(let* ((action-type (funcall x-dnd-test-function
|
|
|
|
|
window
|
|
|
|
|
action
|
|
|
|
|
(aref current-state 2)))
|
|
|
|
|
(handler (cdr (assoc (cdr action-type) x-dnd-types-alist))))
|
|
|
|
|
;; Ignore action-type if we have no handler.
|
|
|
|
|
(setq current-state
|
|
|
|
|
(x-dnd-save-state window
|
|
|
|
|
action
|
|
|
|
|
(when handler action-type))))))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(let ((current-state (x-dnd-get-state-for-frame window)))
|
|
|
|
|
(cons (aref current-state 5)
|
|
|
|
|
(aref current-state 4))))
|
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(defun x-dnd-save-state (window action action-type &optional types extra-data)
|
2004-02-03 16:55:30 +00:00
|
|
|
|
"Save the state of the current drag and drop.
|
|
|
|
|
WINDOW is the window the mouse is over. ACTION is the action suggested
|
|
|
|
|
by the source. ACTION-TYPE is the result of calling `x-dnd-test-function'.
|
2004-02-10 17:27:26 +00:00
|
|
|
|
If given, TYPES are the types for the drop data that the source supports.
|
|
|
|
|
EXTRA-DATA is data needed for a specific protocol."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(let ((current-state (x-dnd-get-state-for-frame window)))
|
|
|
|
|
(aset current-state 5 (car action-type))
|
|
|
|
|
(aset current-state 4 (cdr action-type))
|
|
|
|
|
(aset current-state 3 action)
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(when types (aset current-state 2 types))
|
|
|
|
|
(when extra-data (aset current-state 6 extra-data))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(aset current-state 1 window)
|
2007-06-14 00:09:10 +00:00
|
|
|
|
(aset current-state 0 (and (window-live-p window) (window-buffer window)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(setcdr (x-dnd-get-state-cons-for-frame window) current-state)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-moz-url (window action data)
|
|
|
|
|
"Handle one item of type text/x-moz-url.
|
|
|
|
|
WINDOW is the window where the drop happened. ACTION is ignored.
|
2009-02-26 10:26:32 +00:00
|
|
|
|
DATA is the moz-url, which is formatted as two strings separated by \\r\\n.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
The first string is the URL, the second string is the title of that URL.
|
|
|
|
|
DATA is encoded in utf-16. Decode the URL and call `x-dnd-handle-uri-list'."
|
browse-url: mark some of the more obsolete stuff as such
* lisp/net/browse-url.el (browse-url-browser-function)
(browse-url-default-browser):
Remove obsolete items from the explicit listing.
(browse-url-new-window-flag, browse-url-of-file-hook): Doc fixes.
(browse-url-netscape-program, browse-url-netscape-arguments)
(browse-url-netscape-startup-arguments)
(browse-url-galeon-program, browse-url-galeon-arguments)
(browse-url-galeon-startup-arguments)
(browse-url-gnome-moz-program, browse-url-gnome-moz-arguments)
(browse-url-galeon-new-window-is-tab)
(browse-url-netscape-new-window-is-tab)
(browse-url-mosaic-program, browse-url-mosaic-arguments)
(browse-url-mosaic-pidfile, browse-url-CCI-port)
(browse-url-CCI-host, browse-url-netscape-version)
(browse-url-netscape, browse-url-netscape-sentinel)
(browse-url-netscape-reload, browse-url-netscape-send)
(browse-url-galeon, browse-url-galeon-sentinel)
(browse-url-gnome-moz, browse-url-mosaic, browse-url-cci)
(browse-url-w3-gnudoit): Make obsolete.
* etc/NEWS: Mention this.
* doc/misc/idlwave.texi (HTML Help Browser Tips): Remove obsolete info.
* lisp/ffap.el (ffap-url-fetcher): Simplify default and doc.
* lisp/x-dnd.el: Comment update.
2015-03-25 06:26:48 +00:00
|
|
|
|
;; Mozilla and applications based on it use text/unicode, but it is
|
|
|
|
|
;; impossible to tell if it is le or be. Use what the machine Emacs
|
|
|
|
|
;; runs on uses. This loses if dropping between machines
|
|
|
|
|
;; with different endian-ness, but it is the best we can do.
|
2004-04-02 17:29:52 +00:00
|
|
|
|
(let* ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le))
|
|
|
|
|
(string (decode-coding-string data coding))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(strings (split-string string "[\r\n]" t))
|
|
|
|
|
;; Can one drop more than one moz-url ?? Assume not.
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(url (car strings)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(x-dnd-handle-uri-list window action url)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-insert-utf8-text (window action text)
|
|
|
|
|
"Decode the UTF-8 text and insert it at point.
|
|
|
|
|
TEXT is the text as a string, WINDOW is the window where the drop happened."
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
(dnd-insert-text window action (decode-coding-string text 'utf-8)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-insert-utf16-text (window action text)
|
|
|
|
|
"Decode the UTF-16 text and insert it at point.
|
|
|
|
|
TEXT is the text as a string, WINDOW is the window where the drop happened."
|
2004-04-02 17:29:52 +00:00
|
|
|
|
;; See comment in x-dnd-handle-moz-url about coding.
|
|
|
|
|
(let ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le)))
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
(dnd-insert-text window action (decode-coding-string text coding))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(defun x-dnd-insert-ctext (window action text)
|
|
|
|
|
"Decode the compound text and insert it at point.
|
|
|
|
|
TEXT is the text as a string, WINDOW is the window where the drop happened."
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
(dnd-insert-text window action
|
|
|
|
|
(decode-coding-string text
|
|
|
|
|
'compound-text-with-extensions)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-uri-list (window action string)
|
* x-dnd.el: Require dnd.
(x-dnd-handle-uri-list, x-dnd-handle-file-name): Call
dnd-handle-one-url.
(x-dnd-types-alist, x-dnd-insert-utf8-text)
(x-dnd-insert-utf16-text, x-dnd-insert-ctext): Change x-dnd-insert-text
to dnd-insert-text.
(x-dnd-protocol-alist, x-dnd-open-file-other-window,
x-dnd-handle-one-url, x-dnd-get-local-file-uri,
x-dnd-get-local-file-name, x-dnd-open-local-file,
x-dnd-open-file, x-dnd-insert-text): Moved to dnd.el (without x-).
2005-04-11 19:25:38 +00:00
|
|
|
|
"Split an uri-list into separate URIs and call `dnd-handle-one-url'.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
WINDOW is the window where the drop happened.
|
2009-02-26 10:26:32 +00:00
|
|
|
|
STRING is the uri-list as a string. The URIs are separated by \\r\\n."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(let ((uri-list (split-string string "[\0\r\n]" t))
|
|
|
|
|
retval)
|
2023-10-26 11:37:58 +00:00
|
|
|
|
(let ((did-action (dnd-handle-multiple-urls window uri-list
|
|
|
|
|
action)))
|
|
|
|
|
(when did-action (setq retval did-action)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
retval))
|
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(defun x-dnd-handle-file-name (window action string)
|
2006-05-20 04:29:18 +00:00
|
|
|
|
"Convert file names to URLs and call `dnd-handle-one-url'.
|
2004-02-10 17:27:26 +00:00
|
|
|
|
WINDOW is the window where the drop happened.
|
|
|
|
|
STRING is the file names as a string, separated by nulls."
|
|
|
|
|
(let ((uri-list (split-string string "[\0\r\n]" t))
|
2018-01-25 18:35:13 +00:00
|
|
|
|
(coding (or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
retval)
|
2023-10-26 11:37:58 +00:00
|
|
|
|
(let ((did-action
|
|
|
|
|
(dnd-handle-multiple-urls
|
2023-10-26 11:49:40 +00:00
|
|
|
|
window
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (item)
|
|
|
|
|
(when coding
|
|
|
|
|
(setq item (encode-coding-string item
|
|
|
|
|
coding)))
|
|
|
|
|
(concat "file://"
|
|
|
|
|
(mapconcat 'url-hexify-string
|
|
|
|
|
(split-string item "/")
|
|
|
|
|
"/")))
|
|
|
|
|
uri-list)
|
|
|
|
|
action)))
|
2023-10-26 11:37:58 +00:00
|
|
|
|
(when did-action (setq retval did-action)))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
retval))
|
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(defun x-dnd-choose-type (types &optional known-types)
|
|
|
|
|
"Choose which type we want to receive for the drop.
|
|
|
|
|
TYPES are the types the source of the drop offers, a vector of type names
|
|
|
|
|
as strings or symbols. Select among the types in `x-dnd-known-types' or
|
2009-02-26 10:26:32 +00:00
|
|
|
|
KNOWN-TYPES if given, and return that type name.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
If no suitable type is found, return nil."
|
|
|
|
|
(let* ((known-list (or known-types x-dnd-known-types))
|
|
|
|
|
(first-known-type (car known-list))
|
|
|
|
|
(types-array types)
|
|
|
|
|
(found (when first-known-type
|
|
|
|
|
(catch 'done
|
|
|
|
|
(dotimes (i (length types-array))
|
|
|
|
|
(let* ((type (aref types-array i))
|
|
|
|
|
(typename (if (symbolp type)
|
|
|
|
|
(symbol-name type) type)))
|
|
|
|
|
(when (equal first-known-type typename)
|
|
|
|
|
(throw 'done first-known-type))))
|
|
|
|
|
nil))))
|
|
|
|
|
|
|
|
|
|
(if (and (not found) (cdr known-list))
|
|
|
|
|
(x-dnd-choose-type types (cdr known-list))
|
|
|
|
|
found)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-drop-data (event frame window data type)
|
|
|
|
|
"Drop one data item onto a frame.
|
2009-02-26 10:26:32 +00:00
|
|
|
|
EVENT is the client message for the drop, FRAME is the frame the drop
|
|
|
|
|
occurred on. WINDOW is the window of FRAME where the drop happened.
|
|
|
|
|
DATA is the data received from the source, and type is the type for DATA,
|
|
|
|
|
see `x-dnd-types-alist').
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
Returns the action used (move, copy, link, private) if drop was successful,
|
|
|
|
|
nil if not."
|
|
|
|
|
(let* ((type-info (assoc type x-dnd-types-alist))
|
|
|
|
|
(handler (cdr type-info))
|
|
|
|
|
(state (x-dnd-get-state-for-frame frame))
|
|
|
|
|
(action (aref state 5))
|
|
|
|
|
(w (posn-window (event-start event))))
|
|
|
|
|
(when handler
|
2007-06-14 00:09:10 +00:00
|
|
|
|
(if (and (window-live-p w)
|
2005-10-04 20:29:50 +00:00
|
|
|
|
(not (window-minibuffer-p w))
|
|
|
|
|
(not (window-dedicated-p w)))
|
|
|
|
|
;; If dropping in an ordinary window which we could use,
|
|
|
|
|
;; let dnd-open-file-other-window specify what to do.
|
2005-10-03 19:41:49 +00:00
|
|
|
|
(progn
|
2022-06-07 02:39:55 +00:00
|
|
|
|
(when (and (not mouse-yank-at-point)
|
|
|
|
|
;; If dropping on top of the mode line, insert
|
|
|
|
|
;; the text at point instead.
|
|
|
|
|
(posn-point (event-start event)))
|
2006-08-22 06:14:45 +00:00
|
|
|
|
(goto-char (posn-point (event-start event))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(funcall handler window action data))
|
2005-10-04 20:29:50 +00:00
|
|
|
|
;; If we can't display the file here,
|
|
|
|
|
;; make a new window for it.
|
|
|
|
|
(let ((dnd-open-file-other-window t))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(select-frame frame)
|
|
|
|
|
(funcall handler window action data))))))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-drag-n-drop-event (event)
|
|
|
|
|
"Receive drag and drop events (X client messages).
|
2004-02-15 12:30:04 +00:00
|
|
|
|
Currently XDND, Motif and old KDE 1.x protocols are recognized."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(interactive "e")
|
|
|
|
|
(let* ((client-message (car (cdr (cdr event))))
|
2022-07-03 01:41:32 +00:00
|
|
|
|
(x-fast-protocol-requests (not x-dnd-debug-errors))
|
2022-03-26 02:15:53 +00:00
|
|
|
|
(window (posn-window (event-start event))))
|
|
|
|
|
(if (eq (and (consp client-message)
|
|
|
|
|
(car client-message))
|
|
|
|
|
'XdndSelection)
|
|
|
|
|
;; This is an internal Emacs message caused by something being
|
|
|
|
|
;; dropped on top of a frame.
|
|
|
|
|
(progn
|
|
|
|
|
(let ((action (cdr (assoc (symbol-name (cadr client-message))
|
|
|
|
|
x-dnd-xdnd-to-action)))
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(targets (cddr client-message))
|
|
|
|
|
(local-value (nth 2 client-message)))
|
2022-07-02 01:06:36 +00:00
|
|
|
|
(when (windowp window)
|
|
|
|
|
(select-window window))
|
2022-03-26 02:15:53 +00:00
|
|
|
|
(x-dnd-save-state window nil nil
|
|
|
|
|
(apply #'vector targets))
|
|
|
|
|
(x-dnd-maybe-call-test-function window action)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(x-dnd-drop-data event (if (framep window) window
|
|
|
|
|
(window-frame window))
|
|
|
|
|
window
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(x-get-local-selection
|
|
|
|
|
local-value
|
2022-03-26 02:15:53 +00:00
|
|
|
|
(intern (x-dnd-current-type window)))
|
|
|
|
|
(x-dnd-current-type window))
|
|
|
|
|
(x-dnd-forget-drop window))))
|
|
|
|
|
(let ((message-atom (aref client-message 0))
|
|
|
|
|
(frame (aref client-message 1))
|
|
|
|
|
(format (aref client-message 2))
|
|
|
|
|
(data (aref client-message 3)))
|
|
|
|
|
(cond ((equal "DndProtocol" message-atom) ; Old KDE 1.x.
|
|
|
|
|
(x-dnd-handle-old-kde event frame window message-atom format data))
|
2022-06-15 12:08:51 +00:00
|
|
|
|
((equal "_DND_PROTOCOL" message-atom) ; OffiX protocol.
|
|
|
|
|
(x-dnd-handle-offix event frame window message-atom format data))
|
2022-03-26 02:15:53 +00:00
|
|
|
|
((equal "_MOTIF_DRAG_AND_DROP_MESSAGE" message-atom) ; Motif
|
|
|
|
|
(x-dnd-handle-motif event frame window message-atom format data))
|
|
|
|
|
|
|
|
|
|
((and (> (length message-atom) 4) ; XDND protocol.
|
|
|
|
|
(equal "Xdnd" (substring message-atom 0 4)))
|
|
|
|
|
(x-dnd-handle-xdnd event frame window message-atom format data)))))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2022-06-16 06:33:30 +00:00
|
|
|
|
;;; Old KDE protocol.
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
|
(declare-function x-window-property "xfns.c"
|
|
|
|
|
(prop &optional frame type source delete-p vector-ret-p))
|
|
|
|
|
|
2022-06-16 06:33:30 +00:00
|
|
|
|
(defvar x-dnd-offix-old-kde-to-name '((-1 . DndTypeInvalid)
|
|
|
|
|
(0 . DndTypeUnknown)
|
|
|
|
|
(1 . DndTypeRawData)
|
|
|
|
|
(2 . DndTypeFile)
|
|
|
|
|
(3 . DndTypeFiles)
|
|
|
|
|
(4 . DndTypeText)
|
|
|
|
|
(5 . DndTypeDir)
|
|
|
|
|
(6 . DndTypeLink)
|
|
|
|
|
(7 . DndTypeExe)
|
|
|
|
|
(8 . DndTypeUrl))
|
|
|
|
|
"Alist of old KDE data types to their names.")
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-old-kde (event frame window _message _format data)
|
|
|
|
|
"Handle an old KDE (OffiX) drop.
|
|
|
|
|
EVENT, FRAME, WINDOW and DATA mean the same thing they do in
|
|
|
|
|
`x-dnd-handle-offix.'"
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(let ((proto (aref data 4)))
|
|
|
|
|
;; If PROTO > 0, this is an old KDE drop emulated by a program
|
|
|
|
|
;; supporting a newer version of the OffiX protocol, so we should
|
|
|
|
|
;; wait for the corresponding modern event instead.
|
|
|
|
|
(when (zerop proto)
|
2022-06-16 06:33:30 +00:00
|
|
|
|
(let ((type (cdr (assq (aref data 0) x-dnd-offix-old-kde-to-name)))
|
|
|
|
|
(data (x-window-property "DndSelection" frame nil 0 t)))
|
|
|
|
|
;; First save state.
|
|
|
|
|
(x-dnd-save-state window nil nil (vector type) nil)
|
|
|
|
|
;; Now call the test function to decide what action to perform.
|
|
|
|
|
(x-dnd-maybe-call-test-function window 'private)
|
|
|
|
|
(unwind-protect
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(when (windowp window)
|
|
|
|
|
(select-window window))
|
2022-06-16 06:33:30 +00:00
|
|
|
|
(x-dnd-drop-data event frame window data
|
|
|
|
|
(symbol-name type))
|
|
|
|
|
(x-dnd-forget-drop window))))))
|
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2022-06-15 12:08:51 +00:00
|
|
|
|
;;; New OffiX protocol.
|
|
|
|
|
|
|
|
|
|
(defvar x-dnd-offix-id-to-name '((-1 . DndTypeInvalid)
|
|
|
|
|
(0 . DndTypeUnknown)
|
|
|
|
|
(1 . DndTypeRawData)
|
|
|
|
|
(2 . DndTypeFile)
|
|
|
|
|
(3 . DndTypeFiles)
|
|
|
|
|
(4 . DndTypeText)
|
|
|
|
|
(5 . DndTypeDir)
|
2022-06-16 02:39:01 +00:00
|
|
|
|
(6 . DndTypeLink)
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(7 . DndTypeExe)
|
|
|
|
|
(8 . DndTypeUrl)
|
|
|
|
|
(9 . DndTypeMime)
|
|
|
|
|
(10 . DndTypePixmap))
|
2022-06-16 06:33:30 +00:00
|
|
|
|
"Alist of OffiX data types to their names.")
|
2022-06-15 12:08:51 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-offix-file (window action string)
|
|
|
|
|
"Convert OffiX file name to a regular file name.
|
|
|
|
|
Then, call `x-dnd-handle-file-name'.
|
|
|
|
|
|
|
|
|
|
WINDOW and ACTION mean the same as in `x-dnd-handle-file-name'.
|
2022-06-16 02:39:01 +00:00
|
|
|
|
STRING is the raw OffiX file name data."
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(x-dnd-handle-file-name window action
|
|
|
|
|
(replace-regexp-in-string "\0$" "" string)))
|
|
|
|
|
|
2022-06-16 02:39:01 +00:00
|
|
|
|
(defun x-dnd-handle-offix-files (window action string)
|
|
|
|
|
"Convert OffiX file name list to a URI list.
|
|
|
|
|
Then, call `x-dnd-handle-file-name'.
|
|
|
|
|
|
|
|
|
|
WINDOW and ACTION mean the same as in `x-dnd-handle-file-name'.
|
|
|
|
|
STRING is the raw OffiX file name data."
|
|
|
|
|
(x-dnd-handle-file-name window action
|
|
|
|
|
;; OffiX file name lists contain one extra
|
|
|
|
|
;; NULL byte at the end.
|
|
|
|
|
(if (string-suffix-p "\0\0" string)
|
|
|
|
|
(substring string 0 (1- (length string)))
|
|
|
|
|
string)))
|
|
|
|
|
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(defun x-dnd-handle-offix (event frame window _message-atom _format data)
|
|
|
|
|
"Handle OffiX drop event EVENT.
|
|
|
|
|
FRAME is the frame where the drop happened.
|
|
|
|
|
WINDOW is the window where the drop happened.
|
|
|
|
|
_MESSAGE-ATOM and _FORMAT are unused.
|
|
|
|
|
DATA is the vector containing the contents of the client
|
|
|
|
|
message (format 32) that caused EVENT to be generated."
|
|
|
|
|
(let ((type (cdr (assq (aref data 0) x-dnd-offix-id-to-name)))
|
|
|
|
|
(data (x-window-property "_DND_SELECTION" frame nil 0 t)))
|
|
|
|
|
;; First save state.
|
|
|
|
|
(x-dnd-save-state window nil nil (vector type) nil)
|
|
|
|
|
;; Now call the test function to decide what action to perform.
|
|
|
|
|
(x-dnd-maybe-call-test-function window 'private)
|
|
|
|
|
(unwind-protect
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(when (windowp window)
|
|
|
|
|
(select-window window))
|
2022-06-15 12:08:51 +00:00
|
|
|
|
(x-dnd-drop-data event frame window data
|
|
|
|
|
(symbol-name type))
|
|
|
|
|
(x-dnd-forget-drop window))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;; XDND protocol.
|
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
|
(declare-function x-change-window-property "xfns.c"
|
2022-05-14 13:19:12 +00:00
|
|
|
|
(prop value &optional frame type format outer-P window-id))
|
2022-07-15 08:19:41 +00:00
|
|
|
|
(declare-function x-translate-coordinates "xfns.c")
|
2008-06-12 03:56:20 +00:00
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(defun x-dnd-init-xdnd-for-frame (frame)
|
2004-02-10 17:27:26 +00:00
|
|
|
|
"Set the XdndAware property for FRAME to indicate that we do XDND."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(x-change-window-property "XdndAware"
|
|
|
|
|
'(5) ;; The version of XDND we support.
|
|
|
|
|
frame "ATOM" 32 t))
|
|
|
|
|
|
2022-07-15 08:19:41 +00:00
|
|
|
|
(defun x-dnd-after-move-frame (frame)
|
|
|
|
|
"Handle FRAME moving to a different position.
|
|
|
|
|
Clear any cached root window position."
|
2023-05-06 11:16:36 +00:00
|
|
|
|
(and (frame-live-p frame)
|
|
|
|
|
(set-frame-parameter frame 'dnd-root-window-position
|
|
|
|
|
nil)))
|
2022-07-15 08:19:41 +00:00
|
|
|
|
|
|
|
|
|
(add-hook 'move-frame-functions #'x-dnd-after-move-frame)
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-compute-root-window-position (frame)
|
|
|
|
|
"Return the position of FRAME's edit widget relative to the root window.
|
|
|
|
|
The value is a cons of (X . Y), describing the position of
|
|
|
|
|
FRAME's edit widget (inner window) relative to the root window of
|
|
|
|
|
its screen."
|
|
|
|
|
(or (frame-parameter frame 'dnd-root-window-position)
|
|
|
|
|
(let* ((result (x-translate-coordinates frame))
|
|
|
|
|
(param (cons (car result) (cadr result))))
|
|
|
|
|
(unless result
|
|
|
|
|
(error "Frame isn't on the same screen as its root window"))
|
|
|
|
|
(prog1 param
|
|
|
|
|
(set-frame-parameter frame 'dnd-root-window-position param)))))
|
|
|
|
|
|
2022-07-16 10:55:49 +00:00
|
|
|
|
(defun x-dnd-get-window-rectangle (window)
|
|
|
|
|
"Return the bounds of WINDOW as a rectangle.
|
|
|
|
|
The coordinates in the rectangle are relative to its frame's root
|
|
|
|
|
window. Return the bounds as a list of (X Y WIDTH HEIGHT)."
|
|
|
|
|
(let* ((frame (window-frame window))
|
|
|
|
|
(frame-pos (x-dnd-compute-root-window-position frame))
|
|
|
|
|
(edges (window-inside-pixel-edges window)))
|
|
|
|
|
(list (+ (car frame-pos) (nth 0 edges))
|
|
|
|
|
(+ (cdr frame-pos) (nth 1 edges))
|
|
|
|
|
(- (nth 2 edges) (nth 0 edges))
|
|
|
|
|
(- (nth 3 edges) (nth 1 edges)))))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-intersect-rectangles (r1 r2)
|
|
|
|
|
"Return the intersection of R1 and R2, both rectangles."
|
|
|
|
|
(let ((left (if (< (car r1) (car r2)) r1 r2))
|
|
|
|
|
(right (if (> (car r2) (car r1)) r2 r1))
|
|
|
|
|
(upper (if (< (cadr r1) (cadr r2)) r1 r2))
|
|
|
|
|
(lower (if (> (cadr r2) (cadr r1)) r2 r1))
|
|
|
|
|
(result (list 0 0 0 0)))
|
|
|
|
|
(when (<= (car right) (+ (car left) (nth 2 left)))
|
|
|
|
|
(setcar result (car right))
|
|
|
|
|
(setcar (nthcdr 2 result)
|
|
|
|
|
(- (min (+ (car left) (nth 2 left))
|
|
|
|
|
(+ (car right) (nth 2 right)))
|
|
|
|
|
(car result)))
|
|
|
|
|
(when (<= (cadr lower) (+ (cadr upper) (nth 3 upper)))
|
|
|
|
|
(setcar (cdr result) (cadr lower))
|
|
|
|
|
(setcar (nthcdr 3 result)
|
|
|
|
|
(- (min (+ (cadr lower) (nth 3 lower))
|
|
|
|
|
(+ (cadr upper) (nth 3 upper)))
|
|
|
|
|
(cadr result)))))
|
|
|
|
|
result))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-get-object-rectangle (window posn)
|
|
|
|
|
"Return the rectangle of the object (character or image) under POSN.
|
|
|
|
|
WINDOW is the window POSN represents. The rectangle is returned
|
|
|
|
|
with coordinates relative to the root window."
|
|
|
|
|
(if (posn-point posn)
|
|
|
|
|
(with-selected-window window
|
2022-07-17 03:06:14 +00:00
|
|
|
|
(if-let* ((new-posn (posn-at-point (posn-point posn)))
|
|
|
|
|
(posn-x-y (posn-x-y new-posn))
|
|
|
|
|
(object-width-height (posn-object-width-height new-posn))
|
|
|
|
|
(edges (window-inside-pixel-edges window))
|
|
|
|
|
(frame-pos (x-dnd-compute-root-window-position
|
|
|
|
|
(window-frame window))))
|
|
|
|
|
(list (+ (car frame-pos) (car posn-x-y)
|
|
|
|
|
(car edges))
|
|
|
|
|
(+ (cdr frame-pos) (cdr posn-x-y)
|
|
|
|
|
(cadr edges))
|
|
|
|
|
(car object-width-height)
|
|
|
|
|
(cdr object-width-height))
|
|
|
|
|
'(0 0 0 0)))
|
2022-07-16 10:55:49 +00:00
|
|
|
|
'(0 0 0 0)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-get-drop-rectangle (window posn)
|
|
|
|
|
"Return the drag-and-drop rectangle at POSN on WINDOW."
|
|
|
|
|
(if (or dnd-scroll-margin
|
2022-10-25 11:50:57 +00:00
|
|
|
|
(not (windowp window))
|
|
|
|
|
;; Drops on the scroll bar aren't allowed, but the mouse
|
|
|
|
|
;; rectangle can be set while still on the scroll bar,
|
|
|
|
|
;; causing the drag initiator to never send an XdndPosition
|
|
|
|
|
;; event that will an XdndStatus message with the accept
|
|
|
|
|
;; flag set to be set, even after the mouse enters the
|
|
|
|
|
;; window text area. To prevent that, simply don't generate
|
|
|
|
|
;; a mouse rectangle when an area is set.
|
|
|
|
|
(posn-area posn))
|
2022-07-16 10:55:49 +00:00
|
|
|
|
'(0 0 0 0)
|
|
|
|
|
(let ((window-rectangle (x-dnd-get-window-rectangle window))
|
|
|
|
|
object-rectangle)
|
|
|
|
|
(when dnd-indicate-insertion-point
|
|
|
|
|
(setq object-rectangle (x-dnd-get-object-rectangle window posn)
|
|
|
|
|
window-rectangle (x-dnd-intersect-rectangles object-rectangle
|
|
|
|
|
window-rectangle)))
|
|
|
|
|
window-rectangle)))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
2008-06-12 03:56:20 +00:00
|
|
|
|
(declare-function x-get-atom-name "xselect.c" (value &optional frame))
|
|
|
|
|
(declare-function x-send-client-message "xselect.c"
|
|
|
|
|
(display dest from message-type format values))
|
2007-11-22 13:52:35 +00:00
|
|
|
|
|
2011-06-20 20:49:12 +00:00
|
|
|
|
(defun x-dnd-version-from-flags (flags)
|
lisp/*.el: Fix typos and other trivial doc fixes
* lisp/allout-widgets.el (allout-widgets-auto-activation)
(allout-current-decorated-p):
* lisp/auth-source.el (auth-source-protocols):
* lisp/autorevert.el (auto-revert-set-timer):
* lisp/battery.el (battery-mode-line-limit):
* lisp/calc/calcalg3.el (math-map-binop):
* lisp/calendar/cal-dst.el (calendar-dst-find-startend):
* lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute):
* lisp/calendar/calendar.el (calendar-date-echo-text)
(calendar-generate-month, calendar-string-spread)
(calendar-cursor-to-date, calendar-read, calendar-read-date)
(calendar-mark-visible-date, calendar-dayname-on-or-before):
* lisp/calendar/diary-lib.el (diary-ordinal-suffix):
* lisp/cedet/ede/autoconf-edit.el (autoconf-new-program)
(autoconf-find-last-macro, autoconf-parameter-strip):
* lisp/cedet/ede/config.el (ede-target-with-config-build):
* lisp/cedet/ede/linux.el (ede-linux--detect-architecture)
(ede-linux--get-architecture):
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache)
(semantic-displayer-abstract, semantic-displayer-point-position):
* lisp/cedet/semantic/format.el (semantic-format-face-alist)
(semantic-format-tag-short-doc):
* lisp/cedet/semantic/fw.el (semantic-find-file-noselect):
* lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time)
(semantic-idle-breadcrumbs-display-function)
(semantic-idle-breadcrumbs-format-tag-list-function):
* lisp/cedet/semantic/lex.el (semantic-lex-map-types)
(define-lex, define-lex-block-type-analyzer):
* lisp/cedet/semantic/senator.el (senator-search-default-tag-filter):
* lisp/cedet/semantic/symref.el (semantic-symref-result)
(semantic-symref-hit-to-tag-via-db):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass):
* lisp/cedet/semantic/tag.el (semantic-tag-new-variable)
(semantic-tag-new-include, semantic-tag-new-package)
(semantic-tag-set-faux, semantic-create-tag-proxy)
(semantic-tag-function-parent)
(semantic-tag-components-with-overlays):
* lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces)
(srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict):
* lisp/cedet/srecode/dictionary.el (srecode-create-dictionary)
(srecode-dictionary-add-entries, srecode-dictionary-lookup-name)
(srecode-create-dictionaries-from-tags):
* lisp/cmuscheme.el (scheme-compile-region):
* lisp/color.el (color-lab-to-lch):
* lisp/doc-view.el (doc-view-image-width)
(doc-view-set-up-single-converter):
* lisp/dynamic-setting.el (font-setting-change-default-font)
(dynamic-setting-handle-config-changed-event):
* lisp/elec-pair.el (electric-pair-text-pairs)
(electric-pair-skip-whitespace-function)
(electric-pair-string-bound-function):
* lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance)
(avl-tree-member, avl-tree-mapcar, avl-tree-iter):
* lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree):
* lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag)
(checkdoc-spellcheck-documentation-flag, checkdoc-ispell)
(checkdoc-ispell-current-buffer, checkdoc-ispell-interactive)
(checkdoc-ispell-message-interactive)
(checkdoc-ispell-message-text, checkdoc-ispell-start)
(checkdoc-ispell-continue, checkdoc-ispell-comments)
(checkdoc-ispell-defun):
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method):
* lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group):
* lisp/emacs-lisp/lisp.el (forward-sexp, up-list):
* lisp/emacs-lisp/package-x.el (package--archive-contents-from-file):
* lisp/emacs-lisp/package.el (package-desc)
(package--make-autoloads-and-stuff, package-hidden-regexps):
* lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup):
* lisp/emacs-lisp/testcover.el (testcover-nohits)
(testcover-1value):
* lisp/epg.el (epg-receive-keys, epg-start-edit-key):
* lisp/erc/erc-backend.el (erc-server-processing-p)
(erc-split-line-length, erc-server-coding-system)
(erc-server-send, erc-message):
* lisp/erc/erc-button.el (erc-button-face, erc-button-alist)
(erc-browse-emacswiki):
* lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login):
* lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation):
* lisp/erc/erc-log.el (erc-current-logfile):
* lisp/erc/erc-match.el (erc-log-match-format)
(erc-text-matched-hook):
* lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug):
* lisp/erc/erc-networks.el (erc-server-alist)
(erc-networks-alist, erc-current-network):
* lisp/erc/erc-ring.el (erc-input-ring-index):
* lisp/erc/erc-speedbar.el (erc-speedbar)
(erc-speedbar-update-channel):
* lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag):
* lisp/erc/erc-track.el (erc-track-position-in-mode-line)
(erc-track-remove-from-mode-line, erc-modified-channels-update)
(erc-track-last-non-erc-buffer, erc-track-sort-by-importance)
(erc-track-get-active-buffer):
* lisp/erc/erc.el (erc-get-channel-user-list)
(erc-echo-notice-hook, erc-echo-notice-always-hook)
(erc-wash-quit-reason, erc-format-@nick):
* lisp/ffap.el (ffap-latex-mode):
* lisp/files.el (abort-if-file-too-large)
(dir-locals--get-sort-score, buffer-stale--default-function):
* lisp/filesets.el (filesets-tree-max-level, filesets-data)
(filesets-update-pre010505):
* lisp/gnus/gnus-agent.el (gnus-agent-flush-cache):
* lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol)
(gnus-button-prefer-mid-or-mail):
* lisp/gnus/gnus-cus.el (gnus-group-parameters):
* lisp/gnus/gnus-demon.el (gnus-demon-handlers)
(gnus-demon-run-callback):
* lisp/gnus/gnus-dired.el (gnus-dired-print):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer):
* lisp/gnus/gnus-range.el (gnus-range-normalize):
* lisp/gnus/gnus-spec.el (gnus-pad-form):
* lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud)
(gnus-server-opened, gnus-server-closed, gnus-server-denied)
(gnus-server-offline):
* lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir)
(gnus-refer-thread-limit-to-thread)
(gnus-summary-limit-include-thread, gnus-summary-refer-thread)
(gnus-summary-find-matching):
* lisp/gnus/gnus-util.el (gnus-rescale-image):
* lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server):
* lisp/gnus/mail-source.el (mail-source-incoming-file-prefix):
* lisp/gnus/message.el (message-cite-reply-position)
(message-cite-style-outlook, message-cite-style-thunderbird)
(message-cite-style-gmail, message--send-mail-maybe-partially):
* lisp/gnus/mm-extern.el (mm-inline-external-body):
* lisp/gnus/mm-partial.el (mm-inline-partial):
* lisp/gnus/mml-sec.el (mml-secure-message-sign)
(mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
* lisp/gnus/mml2015.el (mml2015-epg-key-image)
(mml2015-epg-key-image-to-string):
* lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail):
* lisp/gnus/nnheader.el (nnheader-directory-files-is-safe):
* lisp/gnus/nnir.el (nnir-search-history)
(nnir-imap-search-other, nnir-artlist-length)
(nnir-artlist-article, nnir-artitem-group, nnir-artitem-number)
(nnir-artitem-rsv, nnir-article-group, nnir-article-number)
(nnir-article-rsv, nnir-article-ids, nnir-categorize)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-hyrex-additional-switches)
(gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms)
(nnir-read-parm, nnir-read-server-parm, nnir-search-thread):
* lisp/gnus/nnmairix.el (nnmairix-default-group)
(nnmairix-propagate-marks):
* lisp/gnus/smime.el (smime-keys, smime-crl-check)
(smime-verify-buffer, smime-noverify-buffer):
* lisp/gnus/spam-report.el (spam-report-url-ping-mm-url):
* lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header)
(spam-spamassassin-spam-status-header, spam-sa-learn-rebuild)
(spam-classifications, spam-check-stat, spam-spamassassin-score):
* lisp/help.el (describe-minor-mode-from-symbol):
* lisp/hippie-exp.el (hippie-expand-ignore-buffers):
* lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face)
(hfy-begin-span):
* lisp/ibuf-ext.el (ibuffer-update-saved-filters-format)
(ibuffer-saved-filters, ibuffer-old-saved-filters-warning)
(ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters)
(eval, ibuffer-unary-operand, file-extension, directory):
* lisp/image-dired.el (image-dired-cmd-pngcrush-options):
* lisp/image-mode.el (image-toggle-display):
* lisp/international/ccl.el (ccl-compile-read-multibyte-character)
(ccl-compile-write-multibyte-character):
* lisp/international/kkc.el (kkc-save-init-file):
* lisp/international/latin1-disp.el (latin1-display):
* lisp/international/ogonek.el (ogonek-name-encoding-alist)
(ogonek-information, ogonek-lookup-encoding)
(ogonek-deprefixify-region):
* lisp/isearch.el (isearch-filter-predicate)
(isearch--momentary-message):
* lisp/jsonrpc.el (jsonrpc-connection-send)
(jsonrpc-process-connection, jsonrpc-shutdown)
(jsonrpc--async-request-1):
* lisp/language/tibet-util.el (tibetan-char-p):
* lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date)
(feedmail-last-chance-hook, feedmail-before-fcc-hook)
(feedmail-send-it-immediately-wrapper, feedmail-find-eoh):
* lisp/mail/hashcash.el (hashcash-generate-payment)
(hashcash-generate-payment-async, hashcash-insert-payment)
(hashcash-verify-payment):
* lisp/mail/rmail.el (rmail-movemail-variant-in-use)
(rmail-get-attr-value):
* lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime):
* lisp/mail/rmailsum.el (rmail-summary-show-message):
* lisp/mail/supercite.el (sc-raw-mode-toggle):
* lisp/man.el (Man-start-calling):
* lisp/mh-e/mh-acros.el (mh-do-at-event-location)
(mh-iterate-on-messages-in-region, mh-iterate-on-range):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases)
(mh-alias-reload, mh-alias-ali)
(mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file)
(mh-alias-add-alias):
* lisp/mouse.el (mouse-save-then-kill):
* lisp/net/browse-url.el (browse-url-default-macosx-browser):
* lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value)
(eudc-variable-server-value, eudc-update-variable)
(eudc-expand-inline):
* lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result):
* lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list):
* lisp/net/pop3.el (pop3-list):
* lisp/net/soap-client.el (soap-namespace-put)
(soap-xs-parse-sequence, soap-parse-envelope):
* lisp/net/soap-inspect.el (soap-inspect-xs-complex-type):
* lisp/nxml/rng-xsd.el (rng-xsd-date-to-days):
* lisp/org/ob-C.el (org-babel-prep-session:C)
(org-babel-load-session:C):
* lisp/org/ob-J.el (org-babel-execute:J):
* lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* lisp/org/ob-core.el (org-babel-process-file-name):
* lisp/org/ob-ebnf.el (org-babel-execute:ebnf):
* lisp/org/ob-forth.el (org-babel-execute:forth):
* lisp/org/ob-fortran.el (org-babel-execute:fortran)
(org-babel-prep-session:fortran, org-babel-load-session:fortran):
* lisp/org/ob-groovy.el (org-babel-execute:groovy):
* lisp/org/ob-io.el (org-babel-execute:io):
* lisp/org/ob-js.el (org-babel-execute:js):
* lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond)
(org-babel-lilypond-compile-post-tangle)
(org-babel-lilypond-display-pdf-post-tangle)
(org-babel-lilypond-tangle)
(org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-compile-lilyfile)
(org-babel-lilypond-check-for-compile-error)
(org-babel-lilypond-process-compile-error)
(org-babel-lilypond-mark-error-line)
(org-babel-lilypond-parse-error-line)
(org-babel-lilypond-attempt-to-open-pdf)
(org-babel-lilypond-attempt-to-play-midi)
(org-babel-lilypond-switch-extension)
(org-babel-lilypond-set-header-args):
* lisp/org/ob-lua.el (org-babel-prep-session:lua):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-processing.el (org-babel-prep-session:processing):
* lisp/org/ob-python.el (org-babel-prep-session:python):
* lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message)
(org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/org-agenda.el (org-agenda-entry-types)
(org-agenda-move-date-from-past-immediately-to-today)
(org-agenda-time-grid, org-agenda-sorting-strategy)
(org-agenda-filter-by-category, org-agenda-forward-block):
* lisp/org/org-colview.el (org-columns--overlay-text):
* lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces):
* lisp/org/org-indent.el (org-indent-set-line-properties):
* lisp/org/org-macs.el (org-get-limited-outline-regexp):
* lisp/org/org-mobile.el (org-mobile-files):
* lisp/org/org.el (org-use-fast-todo-selection)
(org-extend-today-until, org-use-property-inheritance)
(org-refresh-effort-properties, org-open-at-point-global)
(org-track-ordered-property-with-tag, org-shiftright):
* lisp/org/ox-html.el (org-html-checkbox-type):
* lisp/org/ox-man.el (org-man-source-highlight)
(org-man-verse-block):
* lisp/org/ox-publish.el (org-publish-sitemap-default):
* lisp/outline.el (outline-head-from-level):
* lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-calc-command-indent, dcl-indent-to):
* lisp/progmodes/flymake.el (flymake-make-diagnostic)
(flymake--overlays, flymake-diagnostic-functions)
(flymake-diagnostic-types-alist, flymake--backend-state)
(flymake-is-running, flymake--collect, flymake-mode):
* lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop)
(gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer):
* lisp/progmodes/grep.el (grep-error-screen-columns):
* lisp/progmodes/gud.el (gud-prev-expr):
* lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column)
(ps-run-goto-error):
* lisp/progmodes/python.el (python-eldoc-get-doc)
(python-eldoc-function-timeout-permanent, python-eldoc-function):
* lisp/shadowfile.el (shadow-make-group):
* lisp/speedbar.el (speedbar-obj-do-check):
* lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook):
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib):
* lisp/textmodes/reftex-index.el (reftex-index-goto-entry)
(reftex-index-kill, reftex-index-undo):
* lisp/textmodes/reftex-parse.el (reftex-context-substring):
* lisp/textmodes/reftex.el (reftex-TeX-master-file):
* lisp/textmodes/rst.el (rst-next-hdr, rst-toc)
(rst-uncomment-region, rst-font-lock-extend-region-internal):
* lisp/thumbs.el (thumbs-mode):
* lisp/vc/ediff-util.el (ediff-restore-diff):
* lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag):
* lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p):
* lisp/wid-edit.el (widget-field-value-set, string):
* lisp/x-dnd.el (x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
|
|
|
|
"Return the version byte from the 32 bit FLAGS in an XDndEnter message."
|
2020-01-05 03:07:02 +00:00
|
|
|
|
(ash flags -24))
|
2011-06-20 20:49:12 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-more-than-3-from-flags (flags)
|
lisp/*.el: Fix typos and other trivial doc fixes
* lisp/allout-widgets.el (allout-widgets-auto-activation)
(allout-current-decorated-p):
* lisp/auth-source.el (auth-source-protocols):
* lisp/autorevert.el (auto-revert-set-timer):
* lisp/battery.el (battery-mode-line-limit):
* lisp/calc/calcalg3.el (math-map-binop):
* lisp/calendar/cal-dst.el (calendar-dst-find-startend):
* lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute):
* lisp/calendar/calendar.el (calendar-date-echo-text)
(calendar-generate-month, calendar-string-spread)
(calendar-cursor-to-date, calendar-read, calendar-read-date)
(calendar-mark-visible-date, calendar-dayname-on-or-before):
* lisp/calendar/diary-lib.el (diary-ordinal-suffix):
* lisp/cedet/ede/autoconf-edit.el (autoconf-new-program)
(autoconf-find-last-macro, autoconf-parameter-strip):
* lisp/cedet/ede/config.el (ede-target-with-config-build):
* lisp/cedet/ede/linux.el (ede-linux--detect-architecture)
(ede-linux--get-architecture):
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache)
(semantic-displayer-abstract, semantic-displayer-point-position):
* lisp/cedet/semantic/format.el (semantic-format-face-alist)
(semantic-format-tag-short-doc):
* lisp/cedet/semantic/fw.el (semantic-find-file-noselect):
* lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time)
(semantic-idle-breadcrumbs-display-function)
(semantic-idle-breadcrumbs-format-tag-list-function):
* lisp/cedet/semantic/lex.el (semantic-lex-map-types)
(define-lex, define-lex-block-type-analyzer):
* lisp/cedet/semantic/senator.el (senator-search-default-tag-filter):
* lisp/cedet/semantic/symref.el (semantic-symref-result)
(semantic-symref-hit-to-tag-via-db):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass):
* lisp/cedet/semantic/tag.el (semantic-tag-new-variable)
(semantic-tag-new-include, semantic-tag-new-package)
(semantic-tag-set-faux, semantic-create-tag-proxy)
(semantic-tag-function-parent)
(semantic-tag-components-with-overlays):
* lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces)
(srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict):
* lisp/cedet/srecode/dictionary.el (srecode-create-dictionary)
(srecode-dictionary-add-entries, srecode-dictionary-lookup-name)
(srecode-create-dictionaries-from-tags):
* lisp/cmuscheme.el (scheme-compile-region):
* lisp/color.el (color-lab-to-lch):
* lisp/doc-view.el (doc-view-image-width)
(doc-view-set-up-single-converter):
* lisp/dynamic-setting.el (font-setting-change-default-font)
(dynamic-setting-handle-config-changed-event):
* lisp/elec-pair.el (electric-pair-text-pairs)
(electric-pair-skip-whitespace-function)
(electric-pair-string-bound-function):
* lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance)
(avl-tree-member, avl-tree-mapcar, avl-tree-iter):
* lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree):
* lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag)
(checkdoc-spellcheck-documentation-flag, checkdoc-ispell)
(checkdoc-ispell-current-buffer, checkdoc-ispell-interactive)
(checkdoc-ispell-message-interactive)
(checkdoc-ispell-message-text, checkdoc-ispell-start)
(checkdoc-ispell-continue, checkdoc-ispell-comments)
(checkdoc-ispell-defun):
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method):
* lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group):
* lisp/emacs-lisp/lisp.el (forward-sexp, up-list):
* lisp/emacs-lisp/package-x.el (package--archive-contents-from-file):
* lisp/emacs-lisp/package.el (package-desc)
(package--make-autoloads-and-stuff, package-hidden-regexps):
* lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup):
* lisp/emacs-lisp/testcover.el (testcover-nohits)
(testcover-1value):
* lisp/epg.el (epg-receive-keys, epg-start-edit-key):
* lisp/erc/erc-backend.el (erc-server-processing-p)
(erc-split-line-length, erc-server-coding-system)
(erc-server-send, erc-message):
* lisp/erc/erc-button.el (erc-button-face, erc-button-alist)
(erc-browse-emacswiki):
* lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login):
* lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation):
* lisp/erc/erc-log.el (erc-current-logfile):
* lisp/erc/erc-match.el (erc-log-match-format)
(erc-text-matched-hook):
* lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug):
* lisp/erc/erc-networks.el (erc-server-alist)
(erc-networks-alist, erc-current-network):
* lisp/erc/erc-ring.el (erc-input-ring-index):
* lisp/erc/erc-speedbar.el (erc-speedbar)
(erc-speedbar-update-channel):
* lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag):
* lisp/erc/erc-track.el (erc-track-position-in-mode-line)
(erc-track-remove-from-mode-line, erc-modified-channels-update)
(erc-track-last-non-erc-buffer, erc-track-sort-by-importance)
(erc-track-get-active-buffer):
* lisp/erc/erc.el (erc-get-channel-user-list)
(erc-echo-notice-hook, erc-echo-notice-always-hook)
(erc-wash-quit-reason, erc-format-@nick):
* lisp/ffap.el (ffap-latex-mode):
* lisp/files.el (abort-if-file-too-large)
(dir-locals--get-sort-score, buffer-stale--default-function):
* lisp/filesets.el (filesets-tree-max-level, filesets-data)
(filesets-update-pre010505):
* lisp/gnus/gnus-agent.el (gnus-agent-flush-cache):
* lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol)
(gnus-button-prefer-mid-or-mail):
* lisp/gnus/gnus-cus.el (gnus-group-parameters):
* lisp/gnus/gnus-demon.el (gnus-demon-handlers)
(gnus-demon-run-callback):
* lisp/gnus/gnus-dired.el (gnus-dired-print):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer):
* lisp/gnus/gnus-range.el (gnus-range-normalize):
* lisp/gnus/gnus-spec.el (gnus-pad-form):
* lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud)
(gnus-server-opened, gnus-server-closed, gnus-server-denied)
(gnus-server-offline):
* lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir)
(gnus-refer-thread-limit-to-thread)
(gnus-summary-limit-include-thread, gnus-summary-refer-thread)
(gnus-summary-find-matching):
* lisp/gnus/gnus-util.el (gnus-rescale-image):
* lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server):
* lisp/gnus/mail-source.el (mail-source-incoming-file-prefix):
* lisp/gnus/message.el (message-cite-reply-position)
(message-cite-style-outlook, message-cite-style-thunderbird)
(message-cite-style-gmail, message--send-mail-maybe-partially):
* lisp/gnus/mm-extern.el (mm-inline-external-body):
* lisp/gnus/mm-partial.el (mm-inline-partial):
* lisp/gnus/mml-sec.el (mml-secure-message-sign)
(mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
* lisp/gnus/mml2015.el (mml2015-epg-key-image)
(mml2015-epg-key-image-to-string):
* lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail):
* lisp/gnus/nnheader.el (nnheader-directory-files-is-safe):
* lisp/gnus/nnir.el (nnir-search-history)
(nnir-imap-search-other, nnir-artlist-length)
(nnir-artlist-article, nnir-artitem-group, nnir-artitem-number)
(nnir-artitem-rsv, nnir-article-group, nnir-article-number)
(nnir-article-rsv, nnir-article-ids, nnir-categorize)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-hyrex-additional-switches)
(gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms)
(nnir-read-parm, nnir-read-server-parm, nnir-search-thread):
* lisp/gnus/nnmairix.el (nnmairix-default-group)
(nnmairix-propagate-marks):
* lisp/gnus/smime.el (smime-keys, smime-crl-check)
(smime-verify-buffer, smime-noverify-buffer):
* lisp/gnus/spam-report.el (spam-report-url-ping-mm-url):
* lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header)
(spam-spamassassin-spam-status-header, spam-sa-learn-rebuild)
(spam-classifications, spam-check-stat, spam-spamassassin-score):
* lisp/help.el (describe-minor-mode-from-symbol):
* lisp/hippie-exp.el (hippie-expand-ignore-buffers):
* lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face)
(hfy-begin-span):
* lisp/ibuf-ext.el (ibuffer-update-saved-filters-format)
(ibuffer-saved-filters, ibuffer-old-saved-filters-warning)
(ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters)
(eval, ibuffer-unary-operand, file-extension, directory):
* lisp/image-dired.el (image-dired-cmd-pngcrush-options):
* lisp/image-mode.el (image-toggle-display):
* lisp/international/ccl.el (ccl-compile-read-multibyte-character)
(ccl-compile-write-multibyte-character):
* lisp/international/kkc.el (kkc-save-init-file):
* lisp/international/latin1-disp.el (latin1-display):
* lisp/international/ogonek.el (ogonek-name-encoding-alist)
(ogonek-information, ogonek-lookup-encoding)
(ogonek-deprefixify-region):
* lisp/isearch.el (isearch-filter-predicate)
(isearch--momentary-message):
* lisp/jsonrpc.el (jsonrpc-connection-send)
(jsonrpc-process-connection, jsonrpc-shutdown)
(jsonrpc--async-request-1):
* lisp/language/tibet-util.el (tibetan-char-p):
* lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date)
(feedmail-last-chance-hook, feedmail-before-fcc-hook)
(feedmail-send-it-immediately-wrapper, feedmail-find-eoh):
* lisp/mail/hashcash.el (hashcash-generate-payment)
(hashcash-generate-payment-async, hashcash-insert-payment)
(hashcash-verify-payment):
* lisp/mail/rmail.el (rmail-movemail-variant-in-use)
(rmail-get-attr-value):
* lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime):
* lisp/mail/rmailsum.el (rmail-summary-show-message):
* lisp/mail/supercite.el (sc-raw-mode-toggle):
* lisp/man.el (Man-start-calling):
* lisp/mh-e/mh-acros.el (mh-do-at-event-location)
(mh-iterate-on-messages-in-region, mh-iterate-on-range):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases)
(mh-alias-reload, mh-alias-ali)
(mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file)
(mh-alias-add-alias):
* lisp/mouse.el (mouse-save-then-kill):
* lisp/net/browse-url.el (browse-url-default-macosx-browser):
* lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value)
(eudc-variable-server-value, eudc-update-variable)
(eudc-expand-inline):
* lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result):
* lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list):
* lisp/net/pop3.el (pop3-list):
* lisp/net/soap-client.el (soap-namespace-put)
(soap-xs-parse-sequence, soap-parse-envelope):
* lisp/net/soap-inspect.el (soap-inspect-xs-complex-type):
* lisp/nxml/rng-xsd.el (rng-xsd-date-to-days):
* lisp/org/ob-C.el (org-babel-prep-session:C)
(org-babel-load-session:C):
* lisp/org/ob-J.el (org-babel-execute:J):
* lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* lisp/org/ob-core.el (org-babel-process-file-name):
* lisp/org/ob-ebnf.el (org-babel-execute:ebnf):
* lisp/org/ob-forth.el (org-babel-execute:forth):
* lisp/org/ob-fortran.el (org-babel-execute:fortran)
(org-babel-prep-session:fortran, org-babel-load-session:fortran):
* lisp/org/ob-groovy.el (org-babel-execute:groovy):
* lisp/org/ob-io.el (org-babel-execute:io):
* lisp/org/ob-js.el (org-babel-execute:js):
* lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond)
(org-babel-lilypond-compile-post-tangle)
(org-babel-lilypond-display-pdf-post-tangle)
(org-babel-lilypond-tangle)
(org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-compile-lilyfile)
(org-babel-lilypond-check-for-compile-error)
(org-babel-lilypond-process-compile-error)
(org-babel-lilypond-mark-error-line)
(org-babel-lilypond-parse-error-line)
(org-babel-lilypond-attempt-to-open-pdf)
(org-babel-lilypond-attempt-to-play-midi)
(org-babel-lilypond-switch-extension)
(org-babel-lilypond-set-header-args):
* lisp/org/ob-lua.el (org-babel-prep-session:lua):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-processing.el (org-babel-prep-session:processing):
* lisp/org/ob-python.el (org-babel-prep-session:python):
* lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message)
(org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/org-agenda.el (org-agenda-entry-types)
(org-agenda-move-date-from-past-immediately-to-today)
(org-agenda-time-grid, org-agenda-sorting-strategy)
(org-agenda-filter-by-category, org-agenda-forward-block):
* lisp/org/org-colview.el (org-columns--overlay-text):
* lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces):
* lisp/org/org-indent.el (org-indent-set-line-properties):
* lisp/org/org-macs.el (org-get-limited-outline-regexp):
* lisp/org/org-mobile.el (org-mobile-files):
* lisp/org/org.el (org-use-fast-todo-selection)
(org-extend-today-until, org-use-property-inheritance)
(org-refresh-effort-properties, org-open-at-point-global)
(org-track-ordered-property-with-tag, org-shiftright):
* lisp/org/ox-html.el (org-html-checkbox-type):
* lisp/org/ox-man.el (org-man-source-highlight)
(org-man-verse-block):
* lisp/org/ox-publish.el (org-publish-sitemap-default):
* lisp/outline.el (outline-head-from-level):
* lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-calc-command-indent, dcl-indent-to):
* lisp/progmodes/flymake.el (flymake-make-diagnostic)
(flymake--overlays, flymake-diagnostic-functions)
(flymake-diagnostic-types-alist, flymake--backend-state)
(flymake-is-running, flymake--collect, flymake-mode):
* lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop)
(gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer):
* lisp/progmodes/grep.el (grep-error-screen-columns):
* lisp/progmodes/gud.el (gud-prev-expr):
* lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column)
(ps-run-goto-error):
* lisp/progmodes/python.el (python-eldoc-get-doc)
(python-eldoc-function-timeout-permanent, python-eldoc-function):
* lisp/shadowfile.el (shadow-make-group):
* lisp/speedbar.el (speedbar-obj-do-check):
* lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook):
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib):
* lisp/textmodes/reftex-index.el (reftex-index-goto-entry)
(reftex-index-kill, reftex-index-undo):
* lisp/textmodes/reftex-parse.el (reftex-context-substring):
* lisp/textmodes/reftex.el (reftex-TeX-master-file):
* lisp/textmodes/rst.el (rst-next-hdr, rst-toc)
(rst-uncomment-region, rst-font-lock-extend-region-internal):
* lisp/thumbs.el (thumbs-mode):
* lisp/vc/ediff-util.el (ediff-restore-diff):
* lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag):
* lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p):
* lisp/wid-edit.el (widget-field-value-set, string):
* lisp/x-dnd.el (x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
|
|
|
|
"Return the nmore-than3 bit from the 32 bit FLAGS in an XDndEnter message."
|
2020-01-05 03:07:02 +00:00
|
|
|
|
(logand flags 1))
|
2011-11-15 07:55:13 +00:00
|
|
|
|
|
2022-07-18 01:20:05 +00:00
|
|
|
|
(declare-function x-get-modifier-masks "xfns.c")
|
|
|
|
|
|
2022-07-17 03:06:14 +00:00
|
|
|
|
(defun x-dnd-modifier-mask (mods)
|
|
|
|
|
"Return the X modifier mask for the Emacs modifier state MODS.
|
|
|
|
|
MODS is a single symbol, or a list of symbols such as `shift' or
|
|
|
|
|
`control'."
|
2022-07-18 01:20:05 +00:00
|
|
|
|
(let ((virtual-modifiers (x-get-modifier-masks))
|
|
|
|
|
(mask 0))
|
2022-07-17 03:06:14 +00:00
|
|
|
|
(unless (consp mods)
|
|
|
|
|
(setq mods (list mods)))
|
|
|
|
|
(dolist (modifier mods)
|
|
|
|
|
(cond ((eq modifier 'shift)
|
2022-07-18 01:20:05 +00:00
|
|
|
|
(setq mask (logior mask 1))) ; ShiftMask
|
2022-07-17 03:06:14 +00:00
|
|
|
|
((eq modifier 'control)
|
2022-07-18 01:20:05 +00:00
|
|
|
|
(setq mask (logior mask 4))) ; ControlMask
|
|
|
|
|
((eq modifier 'meta)
|
|
|
|
|
(setq mask (logior mask (nth 4 virtual-modifiers))))
|
|
|
|
|
((eq modifier 'hyper)
|
|
|
|
|
(setq mask (car virtual-modifiers)))
|
|
|
|
|
((eq modifier 'super)
|
|
|
|
|
(setq mask (cadr virtual-modifiers)))
|
|
|
|
|
((eq modifier 'alt)
|
|
|
|
|
(setq mask (nth 2 virtual-modifiers)))))
|
2022-07-17 03:06:14 +00:00
|
|
|
|
mask))
|
|
|
|
|
|
2022-07-22 07:37:28 +00:00
|
|
|
|
(defun x-dnd-get-modifiers ()
|
|
|
|
|
"Obtain an X modifier mask containing all modifiers.
|
|
|
|
|
Value is an X modifier mask containing all modifiers that can
|
|
|
|
|
modify an Emacs keyboard or mouse event."
|
|
|
|
|
(let ((mods (x-get-modifier-masks))
|
|
|
|
|
(mask 5)) ; ShiftMask | ControlMask
|
|
|
|
|
(dolist (mod mods)
|
|
|
|
|
(setq mask (logior mask mod)))
|
|
|
|
|
mask))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-wheel-modifier-type (flags)
|
|
|
|
|
"Return the modifier type of an X modifier mask.
|
|
|
|
|
FLAGS is the X modifier mask of a turn of the mouse wheel."
|
|
|
|
|
(let ((modifiers (x-dnd-get-modifiers)))
|
|
|
|
|
(catch 'type
|
|
|
|
|
(dolist (modifier mouse-wheel-scroll-amount)
|
|
|
|
|
(when (and (consp modifier)
|
|
|
|
|
(eq (x-dnd-modifier-mask (car modifier))
|
|
|
|
|
(logand flags modifiers)))
|
|
|
|
|
(throw 'type (cdr modifier))))
|
|
|
|
|
nil)))
|
2022-07-17 03:06:14 +00:00
|
|
|
|
|
|
|
|
|
(defvar x-dnd-click-count nil
|
|
|
|
|
"Alist of button numbers to click counters during drag-and-drop.
|
|
|
|
|
The cdr of each association's cdr is the timestamp of the last
|
|
|
|
|
button press event for the given button, and the car is the
|
|
|
|
|
number of clicks in quick succession currently received.")
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-note-click (button timestamp)
|
|
|
|
|
"Note that button BUTTON was pressed at TIMESTAMP during drag-and-drop.
|
|
|
|
|
Return the number of clicks that were made in quick succession."
|
|
|
|
|
(if (not (integerp double-click-time))
|
|
|
|
|
1
|
|
|
|
|
(let ((cell (cdr (assq button x-dnd-click-count))))
|
|
|
|
|
(unless cell
|
|
|
|
|
(setq cell (cons 0 timestamp))
|
|
|
|
|
(push (cons button cell)
|
|
|
|
|
x-dnd-click-count))
|
|
|
|
|
(when (< (cdr cell) (- timestamp double-click-time))
|
|
|
|
|
(setcar cell 0))
|
|
|
|
|
(setcar cell (1+ (car cell)))
|
|
|
|
|
(setcdr cell timestamp)
|
|
|
|
|
(car cell))))
|
|
|
|
|
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(defun x-dnd-mwheel-scroll (button count modifiers)
|
|
|
|
|
"Call the appropriate wheel scrolling function for BUTTON.
|
|
|
|
|
Use MODIFIERS, an X modifier mask, to determine if any
|
|
|
|
|
alternative operation (such as scrolling horizontally) should be
|
|
|
|
|
taken. COUNT is the number of times in quick succession BUTTON
|
|
|
|
|
has been pressed."
|
2022-07-22 07:37:28 +00:00
|
|
|
|
(let* ((type (x-dnd-wheel-modifier-type modifiers))
|
|
|
|
|
(hscroll (eq type 'hscroll))
|
|
|
|
|
(amt (or (and (not mouse-wheel-progressive-speed) 1)
|
|
|
|
|
(* 1 count))))
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(unless (and (not mouse-wheel-tilt-scroll)
|
|
|
|
|
(or (eq button 6) (eq button 7)))
|
2022-07-23 06:18:18 +00:00
|
|
|
|
(let ((function (cond ((eq type 'text-scale)
|
|
|
|
|
#'text-scale-adjust)
|
|
|
|
|
((eq type 'global-text-scale)
|
|
|
|
|
#'global-text-scale-adjust)
|
|
|
|
|
((eq button 4)
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(if hscroll
|
2022-07-22 07:37:28 +00:00
|
|
|
|
mwheel-scroll-right-function
|
2022-07-17 12:14:02 +00:00
|
|
|
|
mwheel-scroll-down-function))
|
|
|
|
|
((eq button 5)
|
|
|
|
|
(if hscroll
|
2022-07-22 07:37:28 +00:00
|
|
|
|
mwheel-scroll-left-function
|
2022-07-17 12:14:02 +00:00
|
|
|
|
mwheel-scroll-up-function))
|
|
|
|
|
((eq button 6)
|
|
|
|
|
(if mouse-wheel-flip-direction
|
|
|
|
|
mwheel-scroll-right-function
|
|
|
|
|
mwheel-scroll-left-function))
|
|
|
|
|
((eq button 7)
|
|
|
|
|
(if mouse-wheel-flip-direction
|
|
|
|
|
mwheel-scroll-left-function
|
|
|
|
|
mwheel-scroll-right-function)))))
|
2022-07-23 06:18:18 +00:00
|
|
|
|
;; Button5 should decrease the text scale, not increase it.
|
|
|
|
|
(when (and (memq type '(text-scale global-text-scale))
|
|
|
|
|
(eq button 5))
|
|
|
|
|
(setq amt (- amt)))
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(when function
|
|
|
|
|
(condition-case nil
|
2022-07-23 06:18:18 +00:00
|
|
|
|
;; Don't overwrite any echo-area message that might
|
|
|
|
|
;; already be shown, since this can be called from
|
|
|
|
|
;; `x-begin-drag'.
|
|
|
|
|
(let ((inhibit-message t))
|
|
|
|
|
(funcall function amt))
|
2022-07-17 12:14:02 +00:00
|
|
|
|
;; Do not error at buffer limits. Show a message instead.
|
2022-11-18 12:06:55 +00:00
|
|
|
|
;; This is especially important here because signaling an
|
2022-07-17 12:14:02 +00:00
|
|
|
|
;; error will mess up the drag-and-drop operation.
|
|
|
|
|
(beginning-of-buffer
|
|
|
|
|
(message (error-message-string '(beginning-of-buffer))))
|
|
|
|
|
(end-of-buffer
|
|
|
|
|
(message (error-message-string '(end-of-buffer))))))))))
|
|
|
|
|
|
2011-04-19 13:44:55 +00:00
|
|
|
|
(defun x-dnd-handle-xdnd (event frame window message _format data)
|
2004-02-03 16:55:30 +00:00
|
|
|
|
"Receive one XDND event (client message) and send the appropriate reply.
|
|
|
|
|
EVENT is the client message. FRAME is where the mouse is now.
|
|
|
|
|
WINDOW is the window within FRAME where the mouse is now.
|
2022-07-17 12:14:02 +00:00
|
|
|
|
DATA is the vector containing the data of the client message as a
|
|
|
|
|
vector of cardinals.
|
|
|
|
|
MESSAGE is the type of the ClientMessage that was sent."
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(cond ((equal "XdndEnter" message)
|
2005-02-05 16:53:22 +00:00
|
|
|
|
(let* ((flags (aref data 1))
|
2011-06-20 20:49:12 +00:00
|
|
|
|
(version (x-dnd-version-from-flags flags))
|
|
|
|
|
(more-than-3 (x-dnd-more-than-3-from-flags flags))
|
2005-02-05 16:53:22 +00:00
|
|
|
|
(dnd-source (aref data 0)))
|
2022-06-17 07:29:59 +00:00
|
|
|
|
(when version ;; If flags is bad, version will be nil.
|
|
|
|
|
(x-dnd-save-state
|
|
|
|
|
window nil nil
|
|
|
|
|
(if (> more-than-3 0)
|
|
|
|
|
(x-window-property "XdndTypeList"
|
|
|
|
|
frame "AnyPropertyType"
|
|
|
|
|
dnd-source nil t)
|
|
|
|
|
(vector (x-get-atom-name (aref data 2))
|
|
|
|
|
(x-get-atom-name (aref data 3))
|
|
|
|
|
(x-get-atom-name (aref data 4))))
|
|
|
|
|
version))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
((equal "XdndPosition" message)
|
2022-07-17 03:06:14 +00:00
|
|
|
|
;; If (flags >> 10) & 1, then Emacs should scroll according
|
|
|
|
|
;; to the button passed in bits 8 and 9, and the state passed
|
|
|
|
|
;; in bits 0 to 7.
|
|
|
|
|
(let ((state (x-dnd-get-state-for-frame window)))
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(when (windowp (posn-window (event-start event)))
|
|
|
|
|
(let ((flags (aref data 1))
|
|
|
|
|
(version (aref state 6)))
|
2022-07-19 11:57:47 +00:00
|
|
|
|
(when (not (zerop (logand (ash flags -10) 1)))
|
|
|
|
|
(let* ((button (+ 4 (logand (ash flags -8) #x3)))
|
2022-07-17 12:14:02 +00:00
|
|
|
|
(count (or (and (>= version 1)
|
|
|
|
|
(x-dnd-note-click button
|
|
|
|
|
(aref data 3)))
|
|
|
|
|
1))
|
|
|
|
|
(state (logand flags #xff)))
|
|
|
|
|
(with-selected-window (posn-window (event-start event))
|
|
|
|
|
(x-dnd-mwheel-scroll button count state)
|
|
|
|
|
(let ((old-x-y (posn-x-y (event-start event))))
|
|
|
|
|
(setcar (cdr event)
|
|
|
|
|
(posn-at-x-y (max (car old-x-y) 0)
|
|
|
|
|
(max (cdr old-x-y) 0)))))))))
|
2022-07-17 03:06:14 +00:00
|
|
|
|
(let* ((version (aref state 6))
|
|
|
|
|
(action (if (< version 2) 'copy ; `copy' is the default action.
|
|
|
|
|
(x-get-atom-name (aref data 4))))
|
|
|
|
|
(dnd-source (aref data 0))
|
|
|
|
|
(action-type (x-dnd-maybe-call-test-function
|
|
|
|
|
window
|
|
|
|
|
(cdr (assoc action x-dnd-xdnd-to-action)) t))
|
|
|
|
|
(reply-action (car (rassoc
|
|
|
|
|
;; Mozilla and some other programs
|
|
|
|
|
;; support XDS, but only if we
|
|
|
|
|
;; reply with `copy'. We can
|
|
|
|
|
;; recognize these broken programs
|
|
|
|
|
;; by checking to see if
|
|
|
|
|
;; `XdndActionDirectSave' was
|
|
|
|
|
;; originally specified.
|
|
|
|
|
(if (and (eq (car action-type)
|
|
|
|
|
'direct-save)
|
|
|
|
|
(not (eq action 'direct-save)))
|
|
|
|
|
'copy
|
|
|
|
|
(car action-type))
|
|
|
|
|
x-dnd-xdnd-to-action)))
|
|
|
|
|
(accept ;; 1 = accept, 0 = reject
|
|
|
|
|
(if (and reply-action action-type
|
|
|
|
|
;; Only allow drops on the text area of a
|
|
|
|
|
;; window.
|
|
|
|
|
(not (posn-area (event-start event))))
|
|
|
|
|
1 0))
|
|
|
|
|
(rect (x-dnd-get-drop-rectangle window
|
|
|
|
|
(event-start event)))
|
|
|
|
|
(list-to-send
|
|
|
|
|
(list (string-to-number
|
|
|
|
|
(frame-parameter frame 'outer-window-id))
|
|
|
|
|
;; 1 = accept, 0 = reject. 2 = "want position
|
|
|
|
|
;; updates even for movement inside the given
|
|
|
|
|
;; widget bounds".
|
|
|
|
|
accept
|
|
|
|
|
(cons (car rect) (cadr rect))
|
|
|
|
|
(cons (nth 2 rect) (nth 3 rect))
|
|
|
|
|
;; The no-toolkit Emacs build can actually
|
|
|
|
|
;; receive drops from programs that speak
|
|
|
|
|
;; versions of XDND earlier than 3 (such as
|
|
|
|
|
;; GNUstep), since the toplevel window is the
|
|
|
|
|
;; innermost window.
|
|
|
|
|
(if (>= version 2)
|
|
|
|
|
(or reply-action 0)
|
|
|
|
|
0))))
|
|
|
|
|
(x-send-client-message
|
|
|
|
|
frame dnd-source frame "XdndStatus" 32 list-to-send)
|
|
|
|
|
(dnd-handle-movement (event-start event)))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
((equal "XdndLeave" message)
|
|
|
|
|
(x-dnd-forget-drop window))
|
|
|
|
|
|
|
|
|
|
((equal "XdndDrop" message)
|
|
|
|
|
(if (windowp window) (select-window window))
|
2022-06-17 07:29:59 +00:00
|
|
|
|
(let* ((state (x-dnd-get-state-for-frame frame))
|
|
|
|
|
(version (aref state 6))
|
|
|
|
|
(dnd-source (aref data 0))
|
2020-01-20 07:40:45 +00:00
|
|
|
|
(timestamp (aref data 2))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(current-action (aref state 5))
|
|
|
|
|
(current-type (aref state 4))
|
|
|
|
|
success action value)
|
2022-06-17 02:24:05 +00:00
|
|
|
|
(x-display-set-last-user-time timestamp)
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(if (and (eq current-action 'direct-save)
|
|
|
|
|
(equal current-type "XdndDirectSave0"))
|
|
|
|
|
(x-dnd-handle-xds-drop event window dnd-source version)
|
|
|
|
|
(setq value (and (x-dnd-current-type window)
|
|
|
|
|
(x-get-selection-internal
|
|
|
|
|
'XdndSelection
|
|
|
|
|
(intern (x-dnd-current-type window))
|
|
|
|
|
timestamp)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(setq action (if value
|
|
|
|
|
(condition-case info
|
|
|
|
|
(x-dnd-drop-data
|
|
|
|
|
event frame window value
|
|
|
|
|
(x-dnd-current-type window))
|
|
|
|
|
(error
|
|
|
|
|
(message "Error: %s" info)
|
|
|
|
|
nil))))
|
|
|
|
|
(setq success (if action 1 0))
|
|
|
|
|
(when (>= version 2)
|
|
|
|
|
(x-send-client-message
|
|
|
|
|
frame dnd-source frame "XdndFinished" 32
|
|
|
|
|
(list (string-to-number
|
|
|
|
|
(frame-parameter frame 'outer-window-id))
|
|
|
|
|
(if (>= version 5) success 0) ;; 1 = Success, 0 = Error
|
|
|
|
|
(if (or (not action) (< version 5)) 0
|
|
|
|
|
(or (car (rassoc action
|
|
|
|
|
x-dnd-xdnd-to-action))
|
|
|
|
|
0)))))
|
|
|
|
|
(x-dnd-forget-drop window)))))
|
2004-02-03 16:55:30 +00:00
|
|
|
|
|
|
|
|
|
(t (error "Unknown XDND message %s %s" message data))))
|
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;; Motif protocol.
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-init-motif-for-frame (frame)
|
2009-02-26 10:26:32 +00:00
|
|
|
|
"Set _MOTIF_DRAG_RECEIVER_INFO for FRAME to indicate that we do Motif DND."
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(x-change-window-property "_MOTIF_DRAG_RECEIVER_INFO"
|
|
|
|
|
(list
|
|
|
|
|
(byteorder)
|
|
|
|
|
0 ; The Motif DND version.
|
|
|
|
|
5 ; We want drag dynamic.
|
|
|
|
|
0 0 0 0 0 0 0
|
|
|
|
|
0 0 0 0 0 0) ; Property must be 16 bytes.
|
|
|
|
|
frame "_MOTIF_DRAG_RECEIVER_INFO" 8 t))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-get-motif-value (data offset size byteorder)
|
|
|
|
|
(cond ((eq size 2)
|
|
|
|
|
(if (eq byteorder ?l)
|
|
|
|
|
(+ (ash (aref data (1+ offset)) 8)
|
|
|
|
|
(aref data offset))
|
|
|
|
|
(+ (ash (aref data offset) 8)
|
|
|
|
|
(aref data (1+ offset)))))
|
|
|
|
|
|
|
|
|
|
((eq size 4)
|
|
|
|
|
(if (eq byteorder ?l)
|
2020-01-05 03:07:02 +00:00
|
|
|
|
(+ (ash (aref data (+ 3 offset)) 24)
|
|
|
|
|
(ash (aref data (+ 2 offset)) 16)
|
|
|
|
|
(ash (aref data (1+ offset)) 8)
|
|
|
|
|
(aref data offset))
|
|
|
|
|
(+ (ash (aref data offset) 24)
|
2020-01-05 11:22:05 +00:00
|
|
|
|
(ash (aref data (1+ offset)) 16)
|
2020-01-05 03:07:02 +00:00
|
|
|
|
(ash (aref data (+ 2 offset)) 8)
|
|
|
|
|
(aref data (+ 3 offset)))))))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-motif-value-to-list (value size byteorder)
|
|
|
|
|
(let ((bytes (cond ((eq size 2)
|
Audit use of lsh and fix glitches
I audited use of lsh in the Lisp source code, and fixed the
glitches that I found. While I was at it, I replaced uses of lsh
with ash when either will do. Replacement is OK when either
argument is known to be nonnegative, or when only the low-order
bits of the result matter, and is a (minor) win since ash is a bit
more solid than lsh nowadays, and is a bit faster.
* lisp/calc/calc-ext.el (math-check-fixnum):
Prefer most-positive-fixnum to (lsh -1 -1).
* lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width,
prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1
32)) (Bug#32485#11).
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode):
Tighten sanity-check for bytecode overflow, by checking that the
result of (ash pc -8) is nonnegative. Formerly this check was not
needed since lsh was used and the number overflowed differently.
* lisp/net/dns.el (dns-write): Fix some obvious sign typos in
shift counts. Evidently this part of the code has never been
exercised.
* lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright):
* lisp/term/common-win.el (x-setup-function-keys):
Simplify.
* admin/unidata/unidata-gen.el, admin/unidata/uvs.el:
* doc/lispref/keymaps.texi, doc/lispref/syntax.texi:
* doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19:
* lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el:
* lisp/calc/calc-ext.el, lisp/calc/calc-math.el:
* lisp/cedet/semantic/wisent/comp.el, lisp/composite.el:
* lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el:
* lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el:
* lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el:
* lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el:
* lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el:
* lisp/international/ccl.el, lisp/international/fontset.el:
* lisp/international/mule-cmds.el, lisp/international/mule.el:
* lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el:
* lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el:
* lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el:
* lisp/net/tramp.el, lisp/obsolete/levents.el:
* lisp/obsolete/pgg-parse.el, lisp/org/org.el:
* lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el:
* lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el:
* lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el:
* lisp/tar-mode.el, lisp/term/common-win.el:
* lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el:
* lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el:
Prefer ash to lsh when either will do.
2018-08-21 20:44:03 +00:00
|
|
|
|
(list (logand (ash value -8) ?\xff)
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(logand value ?\xff)))
|
|
|
|
|
|
|
|
|
|
((eq size 4)
|
2020-01-05 03:07:02 +00:00
|
|
|
|
(list (logand (ash value -24) ?\xff)
|
|
|
|
|
(logand (ash value -16) ?\xff)
|
|
|
|
|
(logand (ash value -8) ?\xff)
|
|
|
|
|
(logand value ?\xff))))))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(if (eq byteorder ?l)
|
|
|
|
|
(reverse bytes)
|
|
|
|
|
bytes)))
|
|
|
|
|
|
2022-06-10 03:45:27 +00:00
|
|
|
|
(defun x-dnd-xm-unpack-targets-table-header (data)
|
|
|
|
|
"Decode the header of DATA, a Motif targets table.
|
|
|
|
|
Return a list of the following fields with the given types:
|
|
|
|
|
|
|
|
|
|
Field name Type
|
|
|
|
|
- BYTE_ORDER BYTE
|
|
|
|
|
- PROTOCOL BYTE
|
|
|
|
|
- TARGET_LIST_COUNT CARD16
|
|
|
|
|
- TOTAL_DATA_SIZE CARD32"
|
|
|
|
|
(let* ((byte-order (aref data 0))
|
|
|
|
|
(protocol (aref data 1))
|
|
|
|
|
(target-list-count (x-dnd-get-motif-value
|
|
|
|
|
data 2 2 byte-order))
|
|
|
|
|
(total-data-size (x-dnd-get-motif-value
|
|
|
|
|
data 4 4 byte-order)))
|
|
|
|
|
(list byte-order protocol target-list-count
|
|
|
|
|
total-data-size)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-xm-read-single-rec (data i)
|
|
|
|
|
"Read a single rec from DATA, a Motif targets table.
|
|
|
|
|
I is the offset into DATA to begin reading at. Return a list
|
|
|
|
|
of (CONSUMED NTARGETS TARGETS), where CONSUMED is the number of
|
|
|
|
|
bytes read from DATA, NTARGETS is the total number of targets
|
|
|
|
|
inside the current rec, and TARGETS is a vector of atoms
|
|
|
|
|
describing the selection targets in the current rec."
|
|
|
|
|
(let* ((byte-order (aref data 0))
|
|
|
|
|
(n-targets (x-dnd-get-motif-value
|
|
|
|
|
data i 2 byte-order))
|
|
|
|
|
(targets (make-vector n-targets nil))
|
|
|
|
|
(consumed 0))
|
|
|
|
|
(while (< consumed n-targets)
|
|
|
|
|
(aset targets consumed (x-dnd-get-motif-value
|
|
|
|
|
data (+ i 2 (* consumed 4))
|
|
|
|
|
4 byte-order))
|
|
|
|
|
(setq consumed (1+ consumed)))
|
|
|
|
|
(list (+ 2 (* consumed 4)) n-targets targets)))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-xm-read-targets-table (frame)
|
|
|
|
|
"Read the Motif targets table on FRAME.
|
2022-06-10 07:27:07 +00:00
|
|
|
|
Return a vector of vectors of numbers, which are the atoms of the
|
|
|
|
|
available selection targets for each index into the selection
|
|
|
|
|
table."
|
2022-06-10 03:45:27 +00:00
|
|
|
|
(let* ((drag-window (x-window-property "_MOTIF_DRAG_WINDOW"
|
|
|
|
|
frame "WINDOW" 0 nil t))
|
|
|
|
|
(targets-data (x-window-property "_MOTIF_DRAG_TARGETS"
|
|
|
|
|
frame "_MOTIF_DRAG_TARGETS"
|
|
|
|
|
drag-window nil t))
|
|
|
|
|
(header (x-dnd-xm-unpack-targets-table-header targets-data))
|
|
|
|
|
(vec (make-vector (nth 2 header) nil))
|
|
|
|
|
(current-byte 8)
|
|
|
|
|
(i 0))
|
|
|
|
|
(unless (stringp targets-data)
|
|
|
|
|
(error "Expected format 8, got %s" (type-of targets-data)))
|
|
|
|
|
(prog1 vec
|
|
|
|
|
(while (< i (nth 2 header))
|
|
|
|
|
(let ((rec (x-dnd-xm-read-single-rec targets-data
|
|
|
|
|
current-byte)))
|
|
|
|
|
(aset vec i (nth 2 rec))
|
|
|
|
|
(setq current-byte (+ current-byte (car rec)))
|
|
|
|
|
(setq i (1+ i))))
|
|
|
|
|
(unless (eq current-byte (nth 3 header))
|
|
|
|
|
(error "Targets table header says size is %d, but it is actually %d"
|
|
|
|
|
(nth 3 header) current-byte)))))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-xm-read-targets (frame window selection)
|
|
|
|
|
"Read targets of SELECTION on FRAME from the targets table.
|
|
|
|
|
WINDOW should be the drag-and-drop operation's initiator.
|
|
|
|
|
Return a vector of atoms containing the selection targets."
|
|
|
|
|
(let* ((targets-table (x-dnd-xm-read-targets-table frame))
|
|
|
|
|
(initiator-info (x-window-property selection frame
|
|
|
|
|
"_MOTIF_DRAG_INITIATOR_INFO"
|
|
|
|
|
window nil nil))
|
|
|
|
|
(byte-order (aref initiator-info 0))
|
|
|
|
|
(idx (x-dnd-get-motif-value initiator-info
|
|
|
|
|
2 2 byte-order))
|
|
|
|
|
(vector (aref targets-table idx))
|
|
|
|
|
(i 0))
|
|
|
|
|
(prog1 vector
|
|
|
|
|
(while (< i (length vector))
|
|
|
|
|
(aset vector i
|
|
|
|
|
(intern (x-get-atom-name (aref vector i))))
|
|
|
|
|
(setq i (1+ i))))))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
|
|
|
|
|
(defvar x-dnd-motif-message-types
|
|
|
|
|
'((0 . XmTOP_LEVEL_ENTER)
|
|
|
|
|
(1 . XmTOP_LEVEL_LEAVE)
|
|
|
|
|
(2 . XmDRAG_MOTION)
|
|
|
|
|
(3 . XmDROP_SITE_ENTER)
|
|
|
|
|
(4 . XmDROP_SITE_LEAVE)
|
|
|
|
|
(5 . XmDROP_START)
|
|
|
|
|
(6 . XmDROP_FINISH)
|
|
|
|
|
(7 . XmDRAG_DROP_FINISH)
|
|
|
|
|
(8 . XmOPERATION_CHANGED))
|
|
|
|
|
"Mapping from numbers to Motif DND message types.")
|
|
|
|
|
|
|
|
|
|
(defvar x-dnd-motif-to-action
|
|
|
|
|
'((1 . move)
|
|
|
|
|
(2 . copy)
|
|
|
|
|
(3 . link) ; Both 3 and 4 has been seen as link.
|
|
|
|
|
(4 . link)
|
|
|
|
|
(2 . private)) ; Motif does not have private, so use copy for private.
|
|
|
|
|
"Mapping from number to operation for Motif DND.")
|
|
|
|
|
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(defun x-dnd-handle-motif (event frame window _message-atom _format data)
|
|
|
|
|
(let* ((message-type (cdr (assoc (logand (aref data 0) #x3f)
|
|
|
|
|
x-dnd-motif-message-types)))
|
2022-07-19 11:57:47 +00:00
|
|
|
|
(initiator-p (eq (ash (aref data 0) -7) 0))
|
2004-02-10 17:27:26 +00:00
|
|
|
|
(source-byteorder (aref data 1))
|
|
|
|
|
(my-byteorder (byteorder))
|
|
|
|
|
(source-flags (x-dnd-get-motif-value data 2 2 source-byteorder))
|
|
|
|
|
(source-action (cdr (assoc (logand ?\xF source-flags)
|
|
|
|
|
x-dnd-motif-to-action))))
|
|
|
|
|
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(when initiator-p
|
|
|
|
|
(cond ((eq message-type 'XmTOP_LEVEL_ENTER)
|
|
|
|
|
(let* ((dnd-source (x-dnd-get-motif-value
|
|
|
|
|
data 8 4 source-byteorder))
|
|
|
|
|
(selection-atom (x-dnd-get-motif-value
|
|
|
|
|
data 12 4 source-byteorder))
|
2022-06-10 03:45:27 +00:00
|
|
|
|
(atom-name (x-get-atom-name selection-atom))
|
|
|
|
|
(types (x-dnd-xm-read-targets frame dnd-source
|
|
|
|
|
atom-name)))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(x-dnd-forget-drop frame)
|
|
|
|
|
(when types (x-dnd-save-state window nil nil
|
2022-06-10 03:45:27 +00:00
|
|
|
|
types dnd-source))))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
|
|
|
|
|
;; Can not forget drop here, LEAVE comes before DROP_START and
|
|
|
|
|
;; we need the state in DROP_START.
|
|
|
|
|
((eq message-type 'XmTOP_LEVEL_LEAVE)
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
((eq message-type 'XmDRAG_MOTION)
|
|
|
|
|
(let* ((state (x-dnd-get-state-for-frame frame))
|
|
|
|
|
(timestamp (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 4 4
|
|
|
|
|
source-byteorder)
|
|
|
|
|
4 my-byteorder))
|
|
|
|
|
(x (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 8 2 source-byteorder)
|
|
|
|
|
2 my-byteorder))
|
|
|
|
|
(y (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 10 2 source-byteorder)
|
|
|
|
|
2 my-byteorder))
|
|
|
|
|
(dnd-source (aref state 6))
|
|
|
|
|
(first-move (not (aref state 3)))
|
|
|
|
|
(action-type (x-dnd-maybe-call-test-function
|
|
|
|
|
window
|
|
|
|
|
source-action))
|
|
|
|
|
(reply-action (car (rassoc (car action-type)
|
|
|
|
|
x-dnd-motif-to-action)))
|
|
|
|
|
(reply-flags
|
2022-06-07 02:39:55 +00:00
|
|
|
|
(if (posn-area (event-start event))
|
|
|
|
|
(x-dnd-motif-value-to-list ?\x20 ; 20: invalid drop site
|
|
|
|
|
2 my-byteorder)
|
|
|
|
|
(x-dnd-motif-value-to-list
|
|
|
|
|
(if reply-action
|
|
|
|
|
(+ reply-action
|
|
|
|
|
?\x30 ; 30: valid drop site
|
|
|
|
|
?\x700) ; 700: can do copy, move or link
|
|
|
|
|
?\x30) ; 30: drop site, but noop.
|
|
|
|
|
2 my-byteorder)))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(reply (append
|
|
|
|
|
(list
|
|
|
|
|
(+ ?\x80 ; 0x80 indicates a reply.
|
|
|
|
|
(if first-move
|
|
|
|
|
3 ; First time, reply is SITE_ENTER.
|
|
|
|
|
2)) ; Not first time, reply is DRAG_MOTION.
|
|
|
|
|
my-byteorder)
|
|
|
|
|
reply-flags
|
|
|
|
|
timestamp
|
|
|
|
|
x
|
|
|
|
|
y)))
|
2022-06-17 02:24:05 +00:00
|
|
|
|
(x-display-set-last-user-time timestamp)
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(x-send-client-message frame
|
|
|
|
|
dnd-source
|
|
|
|
|
frame
|
|
|
|
|
"_MOTIF_DRAG_AND_DROP_MESSAGE"
|
|
|
|
|
8
|
2022-04-03 01:14:24 +00:00
|
|
|
|
reply)
|
|
|
|
|
(dnd-handle-movement (event-start event))))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
|
|
|
|
|
((eq message-type 'XmOPERATION_CHANGED)
|
|
|
|
|
(let* ((state (x-dnd-get-state-for-frame frame))
|
|
|
|
|
(timestamp (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 4 4 source-byteorder)
|
|
|
|
|
4 my-byteorder))
|
|
|
|
|
(dnd-source (aref state 6))
|
|
|
|
|
(action-type (x-dnd-maybe-call-test-function
|
|
|
|
|
window
|
|
|
|
|
source-action))
|
|
|
|
|
(reply-action (car (rassoc (car action-type)
|
|
|
|
|
x-dnd-motif-to-action)))
|
|
|
|
|
(reply-flags
|
2022-06-07 02:39:55 +00:00
|
|
|
|
(if (posn-area (event-start event))
|
|
|
|
|
(x-dnd-motif-value-to-list ?\x20 ; 20: invalid drop site
|
|
|
|
|
2 my-byteorder)
|
|
|
|
|
(x-dnd-motif-value-to-list
|
|
|
|
|
(if reply-action
|
|
|
|
|
(+ reply-action
|
|
|
|
|
?\x30 ; 30: valid drop site
|
|
|
|
|
?\x700) ; 700: can do copy, move or link
|
|
|
|
|
?\x30) ; 30: drop site, but noop.
|
|
|
|
|
2 my-byteorder)))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(reply (append
|
|
|
|
|
(list
|
|
|
|
|
(+ ?\x80 ; 0x80 indicates a reply.
|
|
|
|
|
8) ; 8 is OPERATION_CHANGED
|
|
|
|
|
my-byteorder)
|
|
|
|
|
reply-flags
|
|
|
|
|
timestamp)))
|
2022-06-17 02:24:05 +00:00
|
|
|
|
(x-display-set-last-user-time timestamp)
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(x-send-client-message frame
|
|
|
|
|
dnd-source
|
|
|
|
|
frame
|
|
|
|
|
"_MOTIF_DRAG_AND_DROP_MESSAGE"
|
|
|
|
|
8
|
|
|
|
|
reply)))
|
|
|
|
|
|
|
|
|
|
((eq message-type 'XmDROP_START)
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(when (windowp window)
|
|
|
|
|
(select-window window))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
(let* ((x (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 8 2 source-byteorder)
|
|
|
|
|
2 my-byteorder))
|
|
|
|
|
(y (x-dnd-motif-value-to-list
|
|
|
|
|
(x-dnd-get-motif-value data 10 2 source-byteorder)
|
|
|
|
|
2 my-byteorder))
|
|
|
|
|
(selection-atom (x-dnd-get-motif-value
|
|
|
|
|
data 12 4 source-byteorder))
|
|
|
|
|
(atom-name (x-get-atom-name selection-atom))
|
2022-06-10 07:27:07 +00:00
|
|
|
|
(dnd-source (x-dnd-get-motif-value
|
|
|
|
|
data 16 4 source-byteorder)))
|
|
|
|
|
|
|
|
|
|
;; This might be a drop from a program that doesn't use
|
|
|
|
|
;; the Motif drag protocol. Compute all the necessary
|
|
|
|
|
;; state here if that is true.
|
|
|
|
|
(unless (and (x-dnd-get-state-for-frame frame)
|
|
|
|
|
(aref (x-dnd-get-state-for-frame frame) 2))
|
|
|
|
|
(x-dnd-forget-drop frame)
|
|
|
|
|
(let ((types (x-dnd-xm-read-targets frame dnd-source
|
|
|
|
|
atom-name)))
|
|
|
|
|
(x-dnd-save-state window nil nil types dnd-source)))
|
|
|
|
|
|
|
|
|
|
(let* ((action-type (x-dnd-maybe-call-test-function
|
|
|
|
|
window
|
|
|
|
|
source-action))
|
|
|
|
|
(reply-action (and (not (posn-area (event-start event)))
|
|
|
|
|
(car (rassoc (car action-type)
|
|
|
|
|
x-dnd-motif-to-action))))
|
|
|
|
|
(reply-flags
|
|
|
|
|
(x-dnd-motif-value-to-list
|
|
|
|
|
(if (posn-area (event-start event))
|
|
|
|
|
(+ ?\x20 ; 20: invalid drop site
|
|
|
|
|
?\x200) ; 200: drop cancel
|
|
|
|
|
(if reply-action
|
|
|
|
|
(+ reply-action
|
|
|
|
|
?\x30 ; 30: valid drop site
|
|
|
|
|
?\x700) ; 700: can do copy, move or link
|
|
|
|
|
(+ ?\x30 ; 30: drop site, but noop.
|
|
|
|
|
?\x200))) ; 200: drop cancel.
|
2022-06-07 02:39:55 +00:00
|
|
|
|
2 my-byteorder))
|
2022-06-10 07:27:07 +00:00
|
|
|
|
(reply (append
|
|
|
|
|
(list
|
|
|
|
|
(+ ?\x80 ; 0x80 indicates a reply.
|
|
|
|
|
5) ; DROP_START.
|
|
|
|
|
my-byteorder)
|
|
|
|
|
reply-flags
|
|
|
|
|
x y))
|
|
|
|
|
(timestamp (x-dnd-get-motif-value
|
|
|
|
|
data 4 4 source-byteorder))
|
|
|
|
|
action)
|
2022-06-17 02:24:05 +00:00
|
|
|
|
(x-display-set-last-user-time timestamp)
|
2022-06-10 07:27:07 +00:00
|
|
|
|
(x-send-client-message frame
|
|
|
|
|
dnd-source
|
|
|
|
|
frame
|
|
|
|
|
"_MOTIF_DRAG_AND_DROP_MESSAGE"
|
|
|
|
|
8
|
|
|
|
|
reply)
|
2022-06-19 04:22:12 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(setq action
|
|
|
|
|
(when (and reply-action atom-name)
|
|
|
|
|
(let* ((value (x-get-selection-internal
|
|
|
|
|
(intern atom-name)
|
|
|
|
|
(intern (x-dnd-current-type window))
|
|
|
|
|
timestamp)))
|
|
|
|
|
(when value
|
|
|
|
|
(condition-case info
|
|
|
|
|
(x-dnd-drop-data event frame window value
|
|
|
|
|
(x-dnd-current-type window))
|
|
|
|
|
(error
|
|
|
|
|
(message "Error: %s" info)
|
|
|
|
|
nil))))))
|
|
|
|
|
(x-get-selection-internal
|
|
|
|
|
(intern atom-name)
|
|
|
|
|
(if action 'XmTRANSFER_SUCCESS 'XmTRANSFER_FAILURE)
|
|
|
|
|
timestamp)
|
|
|
|
|
(x-dnd-forget-drop frame)))))
|
Implement Motif drop protocol
This is the second most widely implemented drag-and-drop
protocol on X Windows, but seems to have some unsolvable
problems (i.e. stuff will keep accumulating in the drag window
as long the target lists keep changing.) The implementation is
not yet complete and doesn't work with some programs.
* lisp/select.el (xselect-convert-xm-special): New functions.
(selection-converter-alist): Add new converters.
* lisp/x-dnd.el (x-dnd-handle-motif): Ignore messages sent by
the receiver.
* src/xterm.c (xm_targets_table_byte_order): New enum;
(SWAPCARD32, SWAPCARD16): New macros.
(xm_targets_table_rec, xm_drop_start_message)
(xm_drag_initiator_info, xm_drag_receiver_info): New structures.
(XM_DRAG_SIDE_EFFECT, xm_read_targets_table_header)
(xm_read_targets_table_rec, xm_find_targets_table_idx)
(x_atoms_compare, xm_write_targets_table)
(xm_write_drag_initiator_info, xm_get_drag_window)
(xm_setup_dnd_targets, xm_send_drop_message)
(xm_read_drag_receiver_info): New functions.
(x_dnd_compute_toplevels): Correctly free some temp data.
(x_dnd_get_window_proxy, x_dnd_get_window_proto)
(x_set_frame_alpha): Likewise.
(handle_one_xevent): If the window has no XDND proto but has
motif drag receiver data, send a motif drop protocol request.
(x_term_init): New atoms for Motif DND support.
* src/xterm.h (struct x_display_info): Add new atoms.
2022-03-31 09:21:37 +00:00
|
|
|
|
|
2022-06-07 02:39:55 +00:00
|
|
|
|
(t (message "Unknown Motif drag-and-drop message: %s"
|
|
|
|
|
(logand (aref data 0) #x3f)))))))
|
2005-02-09 15:50:47 +00:00
|
|
|
|
|
2004-02-10 17:27:26 +00:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
2022-04-06 12:29:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Handling drops.
|
|
|
|
|
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(defvar x-treat-local-requests-remotely)
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(declare-function x-get-local-selection "xfns.c")
|
2022-06-15 13:00:55 +00:00
|
|
|
|
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(defun x-dnd-convert-to-offix (targets local-selection)
|
|
|
|
|
"Convert local selection data to OffiX data.
|
2022-06-15 13:00:55 +00:00
|
|
|
|
TARGETS should be the list of targets currently available in
|
|
|
|
|
`XdndSelection'. Return a list of an OffiX type, and data
|
|
|
|
|
suitable for passing to `x-change-window-property', or nil if the
|
2022-06-29 02:24:14 +00:00
|
|
|
|
data could not be converted.
|
|
|
|
|
LOCAL-SELECTION should be the local selection data describing the
|
|
|
|
|
selection data to convert."
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(let ((x-treat-local-requests-remotely t)
|
|
|
|
|
file-name-data string-data)
|
|
|
|
|
(cond
|
|
|
|
|
((and (member "FILE_NAME" targets)
|
|
|
|
|
(setq file-name-data
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(x-get-local-selection local-selection 'FILE_NAME)))
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(if (string-match-p "\0" file-name-data)
|
|
|
|
|
;; This means there are multiple file names in
|
|
|
|
|
;; XdndSelection. Convert the file name data to a format
|
|
|
|
|
;; that OffiX understands.
|
2022-06-16 02:39:01 +00:00
|
|
|
|
(cons 'DndTypeFiles (concat file-name-data "\0\0"))
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(cons 'DndTypeFile (concat file-name-data "\0"))))
|
|
|
|
|
((and (member "STRING" targets)
|
|
|
|
|
(setq string-data
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(x-get-local-selection local-selection 'STRING)))
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(cons 'DndTypeText (encode-coding-string string-data
|
|
|
|
|
'latin-1))))))
|
|
|
|
|
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(defun x-dnd-do-offix-drop (targets x y frame window-id contents)
|
|
|
|
|
"Perform an OffiX drop on WINDOW-ID with the given selection contents.
|
2022-06-15 13:00:55 +00:00
|
|
|
|
Return non-nil if the drop succeeded, or nil if it did not
|
|
|
|
|
happen, which can happen if TARGETS didn't contain anything that
|
|
|
|
|
the OffiX protocol can represent.
|
|
|
|
|
|
|
|
|
|
X and Y are the root window coordinates of the drop. TARGETS is
|
2022-06-29 02:24:14 +00:00
|
|
|
|
the list of targets CONTENTS can be converted to, and CONTENTS is
|
|
|
|
|
the local selection data to drop onto the target window.
|
|
|
|
|
|
|
|
|
|
FRAME is the frame that will act as a source window for the
|
|
|
|
|
drop."
|
|
|
|
|
(if-let* ((data (x-dnd-convert-to-offix targets contents))
|
2022-06-15 13:00:55 +00:00
|
|
|
|
(type-id (car (rassq (car data)
|
|
|
|
|
x-dnd-offix-id-to-name)))
|
|
|
|
|
(source-id (string-to-number
|
|
|
|
|
(frame-parameter frame 'window-id)))
|
|
|
|
|
(message-data (list type-id ; l[0] = DataType
|
|
|
|
|
0 ; l[1] = event->xbutton.state
|
|
|
|
|
source-id ; l[2] = window
|
|
|
|
|
(+ x (* 65536 y)) ; l[3] = drop_x + 65536 * drop_y
|
|
|
|
|
1))) ; l[4] = protocol version
|
|
|
|
|
(prog1 t
|
|
|
|
|
;; Send a legacy (old KDE) message first. Newer clients will
|
|
|
|
|
;; ignore it, since the protocol version is 1.
|
|
|
|
|
(x-change-window-property "DndSelection"
|
|
|
|
|
(cdr data) frame
|
|
|
|
|
"STRING" 8 nil 0)
|
|
|
|
|
(x-send-client-message frame window-id
|
|
|
|
|
frame "DndProtocol"
|
|
|
|
|
32 message-data)
|
|
|
|
|
;; Now send a modern _DND_PROTOCOL message.
|
|
|
|
|
(x-change-window-property "_DND_SELECTION"
|
|
|
|
|
(cdr data) frame
|
|
|
|
|
"STRING" 8 nil 0)
|
|
|
|
|
(x-send-client-message frame window-id
|
|
|
|
|
frame "_DND_PROTOCOL"
|
|
|
|
|
32 message-data))))
|
|
|
|
|
|
2022-06-29 02:24:14 +00:00
|
|
|
|
(defun x-dnd-handle-unsupported-drop (targets x y action window-id frame _time local-selection-data)
|
2022-06-15 13:00:55 +00:00
|
|
|
|
"Return non-nil if the drop described by TARGETS and ACTION should not proceed.
|
|
|
|
|
X and Y are the root window coordinates of the drop.
|
|
|
|
|
FRAME is the frame the drop originated on.
|
2022-06-29 02:24:14 +00:00
|
|
|
|
WINDOW-ID is the X window the drop should happen to.
|
|
|
|
|
LOCAL-SELECTION-DATA is the local selection data of the drop."
|
2022-07-02 01:06:36 +00:00
|
|
|
|
(let ((chosen-action nil))
|
|
|
|
|
(not (and (or (eq action 'XdndActionCopy)
|
|
|
|
|
(eq action 'XdndActionMove))
|
|
|
|
|
(not (and x-dnd-use-offix-drop local-selection-data
|
|
|
|
|
(or (not (eq x-dnd-use-offix-drop 'files))
|
|
|
|
|
(member "FILE_NAME" targets))
|
|
|
|
|
(when (x-dnd-do-offix-drop targets x
|
|
|
|
|
y frame window-id
|
|
|
|
|
local-selection-data)
|
|
|
|
|
(setq chosen-action 'XdndActionCopy))))
|
|
|
|
|
(let ((delegate-p (or (member "STRING" targets)
|
|
|
|
|
(member "UTF8_STRING" targets)
|
|
|
|
|
(member "COMPOUND_TEXT" targets)
|
|
|
|
|
(member "TEXT" targets))))
|
|
|
|
|
(prog1 delegate-p
|
|
|
|
|
;; A string will avoid the drop emulation done in C
|
|
|
|
|
;; code, but won't be returned from `x-begin-drag'.
|
|
|
|
|
(setq chosen-action (unless delegate-p ""))))))
|
|
|
|
|
chosen-action))
|
2022-04-06 12:29:30 +00:00
|
|
|
|
|
2022-06-13 07:01:06 +00:00
|
|
|
|
(defvar x-dnd-targets-list)
|
|
|
|
|
(defvar x-dnd-native-test-function)
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-native-drop (pos action)
|
|
|
|
|
"Compute the action for a drop at POS.
|
|
|
|
|
Return the appropriate drag-and-drop action for a local drop at POS.
|
|
|
|
|
ACTION is the action given to `x-begin-drag'."
|
|
|
|
|
(let ((state (funcall x-dnd-test-function
|
|
|
|
|
(posn-window pos)
|
|
|
|
|
(cdr (assoc (symbol-name action)
|
|
|
|
|
x-dnd-xdnd-to-action))
|
|
|
|
|
(apply #'vector x-dnd-targets-list))))
|
|
|
|
|
(when state
|
|
|
|
|
(intern (car (rassq (car state) x-dnd-xdnd-to-action))))))
|
|
|
|
|
|
|
|
|
|
(setq x-dnd-native-test-function #'x-dnd-handle-native-drop)
|
|
|
|
|
|
2022-06-29 12:10:25 +00:00
|
|
|
|
;;; XDS protocol support.
|
|
|
|
|
|
|
|
|
|
(declare-function x-begin-drag "xfns.c")
|
2022-06-29 12:16:44 +00:00
|
|
|
|
(declare-function x-delete-window-property "xfns.c")
|
|
|
|
|
(defvar selection-converter-alist)
|
2022-06-29 12:10:25 +00:00
|
|
|
|
|
|
|
|
|
(defvar x-dnd-xds-current-file nil
|
|
|
|
|
"The file name for which a direct save is currently being performed.")
|
|
|
|
|
|
|
|
|
|
(defvar x-dnd-xds-source-frame nil
|
|
|
|
|
"The frame from which a direct save is currently being performed.")
|
|
|
|
|
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(defvar x-dnd-xds-performed nil
|
|
|
|
|
"Whether or not the drop target made a request for `XdndDirectSave0'.")
|
|
|
|
|
|
2022-06-30 08:41:58 +00:00
|
|
|
|
(defvar x-dnd-disable-motif-protocol)
|
2022-07-01 01:10:34 +00:00
|
|
|
|
(defvar x-dnd-use-unsupported-drop)
|
2022-06-30 08:41:58 +00:00
|
|
|
|
|
2022-07-24 13:32:42 +00:00
|
|
|
|
(defvar x-dnd-xds-testing nil
|
|
|
|
|
"Whether or not XDS is being tested from ERT.
|
|
|
|
|
When non-nil, throw errors from the `XdndDirectSave0' converters
|
|
|
|
|
instead of returning \"E\".")
|
|
|
|
|
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(defun x-dnd-handle-direct-save (_selection _type _value)
|
|
|
|
|
"Handle a selection request for `XdndDirectSave'."
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(setq x-dnd-xds-performed t)
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(let* ((uri (x-window-property "XdndDirectSave0"
|
|
|
|
|
x-dnd-xds-source-frame
|
|
|
|
|
"AnyPropertyType" nil t))
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(local-file-uri (if (and (string-match "^file://\\([^/]*\\)" uri)
|
|
|
|
|
(not (equal (match-string 1 uri) "")))
|
|
|
|
|
(dnd-get-local-file-uri uri)
|
|
|
|
|
uri))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(local-name (and local-file-uri
|
|
|
|
|
(dnd-get-local-file-name local-file-uri))))
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(if (not local-name)
|
|
|
|
|
'(STRING . "F")
|
2022-11-18 12:06:55 +00:00
|
|
|
|
;; We want errors to be signaled immediately during ERT
|
2022-07-24 13:32:42 +00:00
|
|
|
|
;; testing, instead of being silently handled. (bug#56712)
|
|
|
|
|
(if x-dnd-xds-testing
|
|
|
|
|
(prog1 '(STRING . "S")
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(copy-file x-dnd-xds-current-file
|
|
|
|
|
local-name t)
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(when (equal x-dnd-xds-current-file
|
|
|
|
|
dnd-last-dragged-remote-file)
|
|
|
|
|
(dnd-remove-last-dragged-remote-file)))
|
2022-07-24 13:32:42 +00:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(copy-file x-dnd-xds-current-file
|
|
|
|
|
local-name t)
|
|
|
|
|
(when (equal x-dnd-xds-current-file
|
|
|
|
|
dnd-last-dragged-remote-file)
|
|
|
|
|
(dnd-remove-last-dragged-remote-file)))
|
|
|
|
|
(:success '(STRING . "S"))
|
|
|
|
|
(error '(STRING . "E")))))))
|
2022-06-30 06:13:30 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-octet-stream (_selection _type _value)
|
2022-08-08 12:08:47 +00:00
|
|
|
|
"Handle a selection request for `application/octet-stream'.
|
2022-06-30 06:13:30 +00:00
|
|
|
|
Return the contents of the XDS file."
|
|
|
|
|
(cons 'application/octet-stream
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
|
(setq buffer-file-coding-system 'binary)
|
|
|
|
|
(insert-file-contents-literally x-dnd-xds-current-file)
|
|
|
|
|
(buffer-substring-no-properties (point-min)
|
|
|
|
|
(point-max))))))
|
2022-06-29 12:10:25 +00:00
|
|
|
|
|
|
|
|
|
(defun x-dnd-do-direct-save (file name frame allow-same-frame)
|
|
|
|
|
"Perform a direct save operation on FILE, from FRAME.
|
|
|
|
|
FILE is the file containing the contents to drop.
|
|
|
|
|
NAME is the name that should be given to the file after dropping.
|
|
|
|
|
FRAME is the frame from which the drop will originate.
|
|
|
|
|
ALLOW-SAME-FRAME means whether or not dropping will be allowed
|
|
|
|
|
on FRAME.
|
|
|
|
|
|
2022-06-30 06:13:30 +00:00
|
|
|
|
Return the action taken by the drop target, or nil if no action
|
|
|
|
|
was taken, or the direct save failed."
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(dnd-remove-last-dragged-remote-file)
|
|
|
|
|
(let ((file-name file)
|
|
|
|
|
(original-file-name file)
|
|
|
|
|
(selection-converter-alist
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(append '((XdndDirectSave0 . x-dnd-handle-direct-save)
|
|
|
|
|
(application/octet-stream . x-dnd-handle-octet-stream))
|
|
|
|
|
selection-converter-alist))
|
2022-06-29 12:10:25 +00:00
|
|
|
|
(x-dnd-xds-current-file nil)
|
|
|
|
|
(x-dnd-xds-source-frame frame)
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(x-dnd-xds-performed nil)
|
2022-06-30 08:41:58 +00:00
|
|
|
|
;; The XDS protocol is built on top of XDND, and cannot
|
|
|
|
|
;; possibly work with Motif or OffiX programs.
|
|
|
|
|
(x-dnd-disable-motif-protocol t)
|
|
|
|
|
(x-dnd-use-offix-drop nil)
|
2022-07-01 01:10:34 +00:00
|
|
|
|
(x-dnd-use-unsupported-drop nil)
|
2022-06-30 06:13:30 +00:00
|
|
|
|
(prop-deleted nil)
|
2022-06-29 12:10:25 +00:00
|
|
|
|
encoded-name)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(when (file-remote-p file)
|
|
|
|
|
(setq file-name (file-local-copy file))
|
|
|
|
|
(setq dnd-last-dragged-remote-file file-name)
|
|
|
|
|
(add-hook 'kill-emacs-hook
|
|
|
|
|
#'dnd-remove-last-dragged-remote-file))
|
|
|
|
|
(setq encoded-name
|
|
|
|
|
(encode-coding-string name
|
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system)))
|
|
|
|
|
(setq x-dnd-xds-current-file file-name)
|
|
|
|
|
(x-change-window-property "XdndDirectSave0" encoded-name
|
|
|
|
|
frame "text/plain" 8 nil)
|
|
|
|
|
(gui-set-selection 'XdndSelection (concat "file://" file-name))
|
|
|
|
|
;; FIXME: this does not work with GTK file managers, since
|
|
|
|
|
;; they always reach for `text/uri-list' first, contrary to
|
|
|
|
|
;; the spec.
|
2022-07-02 06:06:28 +00:00
|
|
|
|
(let ((action (x-begin-drag '("XdndDirectSave0" "text/uri-list"
|
|
|
|
|
"application/octet-stream")
|
2022-06-30 06:13:30 +00:00
|
|
|
|
'XdndActionDirectSave
|
|
|
|
|
frame nil allow-same-frame)))
|
|
|
|
|
(if (not x-dnd-xds-performed)
|
|
|
|
|
action
|
|
|
|
|
(let ((property (x-window-property "XdndDirectSave0" frame
|
|
|
|
|
"AnyPropertyType" nil t)))
|
|
|
|
|
(setq prop-deleted t)
|
|
|
|
|
;; "System-G" deletes the property upon success.
|
|
|
|
|
(and (or (null property)
|
|
|
|
|
(and (stringp property)
|
|
|
|
|
(not (equal property ""))))
|
|
|
|
|
action)))))
|
|
|
|
|
(unless prop-deleted
|
|
|
|
|
(x-delete-window-property "XdndDirectSave0" frame))
|
2022-06-29 12:10:25 +00:00
|
|
|
|
;; Delete any remote copy that was made.
|
|
|
|
|
(when (not (equal file-name original-file-name))
|
|
|
|
|
(delete-file file-name)))))
|
|
|
|
|
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(defun x-dnd-save-direct (need-name filename)
|
|
|
|
|
"Handle dropping a file FILENAME that should be saved first, asking the user.
|
|
|
|
|
NEED-NAME non-nil means the caller requests the full absolute
|
|
|
|
|
file name of FILENAME under which to save it; FILENAME is just
|
|
|
|
|
the base name in that case. The function then prompts the user
|
|
|
|
|
for where to save to file and returns the result to the caller.
|
|
|
|
|
|
|
|
|
|
NEED-NAME nil means the file was saved as FILENAME (which should
|
|
|
|
|
be the full absolute file name in that case). The function then
|
|
|
|
|
refreshes the Dired display, if the current buffer is in Dired
|
|
|
|
|
mode, or visits the file otherwise.
|
2022-07-01 08:12:45 +00:00
|
|
|
|
|
2023-04-08 15:36:23 +00:00
|
|
|
|
This function is intended to be the value of `x-dnd-direct-save-function',
|
|
|
|
|
which see."
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(if need-name
|
|
|
|
|
(let ((file-name (read-file-name "Write file: "
|
|
|
|
|
default-directory
|
2023-04-08 15:36:23 +00:00
|
|
|
|
nil nil filename)))
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(when (file-exists-p file-name)
|
|
|
|
|
(unless (y-or-n-p (format-message
|
|
|
|
|
"File `%s' exists; overwrite? " file-name))
|
|
|
|
|
(setq file-name nil)))
|
|
|
|
|
file-name)
|
|
|
|
|
;; TODO: move this to dired.el once a platform-agonistic
|
|
|
|
|
;; interface can be found.
|
|
|
|
|
(if (derived-mode-p 'dired-mode)
|
|
|
|
|
(revert-buffer)
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(find-file filename))))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(defun x-dnd-save-direct-immediately (need-name filename)
|
|
|
|
|
"Handle dropping a file FILENAME that should be saved first.
|
|
|
|
|
Like `x-dnd-save-direct', but do not prompt for the file name;
|
|
|
|
|
instead, return its absolute file name for saving in the current
|
|
|
|
|
directory.
|
2022-07-05 06:55:24 +00:00
|
|
|
|
|
2023-04-08 15:36:23 +00:00
|
|
|
|
This function is intended to be the value of `x-dnd-direct-save-function',
|
|
|
|
|
which see."
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(if need-name
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(let ((file-name (expand-file-name filename)))
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(when (file-exists-p file-name)
|
|
|
|
|
(unless (y-or-n-p (format-message
|
|
|
|
|
"File `%s' exists; overwrite? " file-name))
|
|
|
|
|
(setq file-name nil)))
|
|
|
|
|
file-name)
|
|
|
|
|
;; TODO: move this to dired.el once a platform-agonistic
|
|
|
|
|
;; interface can be found.
|
|
|
|
|
(if (derived-mode-p 'dired-mode)
|
|
|
|
|
(revert-buffer)
|
2023-04-08 15:36:23 +00:00
|
|
|
|
(find-file filename))))
|
2022-07-05 06:55:24 +00:00
|
|
|
|
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(defun x-dnd-handle-octet-stream-for-drop (save-to)
|
|
|
|
|
"Save the contents of the XDS selection to SAVE-TO.
|
|
|
|
|
Return non-nil if successful, nil otherwise."
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(let ((coding-system-for-write 'raw-text)
|
|
|
|
|
(data (x-get-selection-internal 'XdndSelection
|
|
|
|
|
'application/octet-stream)))
|
|
|
|
|
(when data
|
|
|
|
|
(write-region data nil save-to)
|
|
|
|
|
t))))
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-handle-xds-drop (event window source version)
|
|
|
|
|
"Handle an XDS (X Direct Save) protocol drop.
|
|
|
|
|
EVENT is the drag-n-drop event containing the drop.
|
|
|
|
|
WINDOW is the window on top of which the drop is supposed to happen.
|
|
|
|
|
SOURCE is the X window that sent the drop.
|
|
|
|
|
VERSION is the version of the XDND protocol understood by SOURCE."
|
|
|
|
|
(if (not (windowp window))
|
|
|
|
|
;; We can't perform an XDS drop if there's no window from which
|
|
|
|
|
;; to determine the current directory.
|
|
|
|
|
(let* ((start (event-start event))
|
|
|
|
|
(frame (posn-window start)))
|
|
|
|
|
(x-send-client-message frame source frame
|
|
|
|
|
"XdndFinished" 32
|
|
|
|
|
(list (string-to-number
|
|
|
|
|
(frame-parameter frame
|
|
|
|
|
'outer-window-id)))))
|
|
|
|
|
(let ((desired-name (x-window-property "XdndDirectSave0"
|
|
|
|
|
(window-frame window)
|
|
|
|
|
;; We currently don't handle
|
|
|
|
|
;; any alternative character
|
|
|
|
|
;; encodings.
|
|
|
|
|
"text/plain" source))
|
|
|
|
|
(frame (window-frame window))
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(success nil) save-to save-to-remote hostname)
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(when (stringp desired-name)
|
|
|
|
|
(setq desired-name (decode-coding-string
|
|
|
|
|
desired-name
|
|
|
|
|
(or file-name-coding-system
|
|
|
|
|
default-file-name-coding-system)))
|
2022-10-15 05:27:05 +00:00
|
|
|
|
(let ((name (expand-file-name
|
|
|
|
|
(funcall x-dnd-direct-save-function
|
|
|
|
|
t desired-name))))
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(setq save-to name save-to-remote name))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(when save-to
|
2022-07-05 06:55:24 +00:00
|
|
|
|
(if (file-remote-p save-to)
|
|
|
|
|
(setq hostname (file-remote-p save-to 'host)
|
|
|
|
|
save-to (file-local-name save-to))
|
|
|
|
|
(setq hostname (system-name)))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(with-selected-window window
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(let ((uri (format "file://%s%s" hostname save-to)))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(x-change-window-property "XdndDirectSave0"
|
|
|
|
|
(encode-coding-string
|
|
|
|
|
(url-encode-url uri) 'ascii)
|
|
|
|
|
frame "text/plain" 8 nil source)
|
|
|
|
|
(let ((result (x-get-selection-internal 'XdndSelection
|
|
|
|
|
'XdndDirectSave0)))
|
|
|
|
|
(cond ((equal result "F")
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(setq success
|
|
|
|
|
(x-dnd-handle-octet-stream-for-drop save-to-remote))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
(unless success
|
|
|
|
|
(x-change-window-property "XdndDirectSave0" ""
|
|
|
|
|
frame "text/plain" 8
|
|
|
|
|
nil source)))
|
|
|
|
|
((equal result "S")
|
|
|
|
|
(setq success t))
|
|
|
|
|
((equal result "E")
|
|
|
|
|
(setq success nil))
|
|
|
|
|
(t (error "Broken implementation of XDS: got %s in reply"
|
|
|
|
|
result)))
|
|
|
|
|
(when success
|
2022-07-05 02:40:32 +00:00
|
|
|
|
(funcall x-dnd-direct-save-function nil save-to-remote)))))))
|
2022-07-01 08:12:45 +00:00
|
|
|
|
;; We assume XDS always comes from a client supporting version 2
|
|
|
|
|
;; or later, since custom actions aren't present before.
|
|
|
|
|
(x-send-client-message frame source frame
|
|
|
|
|
"XdndFinished" 32
|
|
|
|
|
(list (string-to-number
|
|
|
|
|
(frame-parameter frame
|
|
|
|
|
'outer-window-id))
|
|
|
|
|
(if (>= version 5)
|
|
|
|
|
(if success 1 0)
|
|
|
|
|
0)
|
|
|
|
|
(if (or (not success)
|
|
|
|
|
(< version 5))
|
|
|
|
|
0
|
|
|
|
|
"XdndDirectSave0")))))))
|
|
|
|
|
|
2022-07-19 01:33:09 +00:00
|
|
|
|
;; Internal wheel movement.
|
|
|
|
|
|
|
|
|
|
(defvar x-dnd-wheel-function)
|
|
|
|
|
|
|
|
|
|
(defun x-dnd-note-wheel-movement (position button state time)
|
|
|
|
|
"Note wheel movement at POSITION.
|
|
|
|
|
POSITION is a mouse position list describing the position of the
|
|
|
|
|
wheel movement.
|
|
|
|
|
BUTTON is the wheel button that was pressed.
|
|
|
|
|
STATE is the X modifier state at the time of the wheel movement.
|
|
|
|
|
TIME is the X server time at which the wheel moved."
|
|
|
|
|
(when (posn-window position)
|
|
|
|
|
(with-selected-window (posn-window position)
|
|
|
|
|
(let ((count (x-dnd-note-click button time)))
|
|
|
|
|
(x-dnd-mwheel-scroll button count state)))))
|
|
|
|
|
|
|
|
|
|
(setq x-dnd-wheel-function #'x-dnd-note-wheel-movement)
|
|
|
|
|
|
2004-02-03 16:55:30 +00:00
|
|
|
|
(provide 'x-dnd)
|
|
|
|
|
|
|
|
|
|
;;; x-dnd.el ends here
|