Commit graph

662 commits

Author SHA1 Message Date
Po Lu
dd8db560c2 Disable tooltip timeouts for drag-and-drop tooltips
* lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip):
Don't time out the created tooltip.
2022-06-09 16:44:17 +08:00
Po Lu
0ba43e15d9 Note caveats of `follow-tooltip' with system tooltips
* lisp/mouse.el (mouse-drag-and-drop-region): Turn off system
tooltips inside.
* src/xfns.c (Fx_begin_drag): Say that follow-tooltip doesn't
work with system tooltips.
2022-06-09 15:44:51 +08:00
Po Lu
2f31dbeadf Also show mouse DND tooltip contents during interprogram drag-and-drop
* doc/lispref/frames.texi (Drag and Drop): Document new
parameter to `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Don't hide tooltip
when initiating interprogram drag-and-drop.
* lisp/term/haiku-win.el (x-begin-drag):
* lisp/term/ns-win.el (x-begin-drag): Add stubs for new
parameter.
* src/xfns.c (Fx_begin_drag): New parameter `follow-tooltip'.
(Fx_show_tip, syms_of_xfns): Add records of the last dx and dy
given to `x-show-tip'.
* src/xterm.c (x_clear_dnd_monitors): New function.
(x_dnd_begin_drag_and_drop): Save monitor attributes list if
appropriate.
(x_dnd_compute_tip_xy, x_dnd_update_tooltip_position): New
function.
(x_dnd_update_state, handle_one_xevent): Update tooltip position
during DND mouse movement.
(syms_of_xterm): Update staticpros.
* src/xterm.h: Update prototypes.
2022-06-09 13:11:08 +08:00
Po Lu
cbc0d8f7c7 Don't display mouse face during mouse drag-and-drop
* lisp/mouse.el (mouse-drag-and-drop-region): Don't display
mouse face, since it leads to a lot of flicker.
2022-06-07 10:27:03 +08:00
Po Lu
eaff6569e2 Improve doc of `mouse-drag-mode-line-buffer'
* doc/emacs/frames.texi (Mouse Commands): Document
`mouse-drag-mode-line-buffer'.
* etc/NEWS: Explain where that option is supported.
* lisp/mouse.el (mouse-drag-mode-line-buffer): Likewise.
2022-06-04 13:27:03 +08:00
Po Lu
4f56ca6376 Add new user option `mouse-drag-mode-line-buffer'
* etc/NEWS: Announce new option.  Also add missing entries for
an earlier change.
* lisp/mouse.el (mouse-drag-mode-line-buffer): New user option.
(mouse-drag-mode-line): Implement that option.
2022-06-03 15:20:23 +08:00
Po Lu
2244dc5ce9 Fix help-echo tooltips interfering with mouse drag-and-drop
* lisp/mouse.el (mouse-drag-and-drop-region): Disable
tooltip-mode while mouse drag-and-drop is in progress.  Also
restore state correctly in some more cases.
2022-06-02 14:27:38 +08:00
Po Lu
5743b74d4b Improve mouse dragging
* lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip):
Respect foreground and background parameters.
(mouse-drag-and-drop-region): Enable fine grained tracking.
2022-05-12 14:56:32 +08:00
Stefan Kangas
2fba71cf1f Fix handling double-click-time nil or t
* lisp/mouse.el (mouse-double-click-time): New function to always
return a number for `double-click-time'.
* lisp/emulation/viper-mous.el (viper-multiclick-timeout):
* lisp/foldout.el (foldout-mouse-swallow-events):
* lisp/help.el (help--read-key-sequence):
* lisp/org/org-mouse.el (org-mouse-show-context-menu): Use
'mouse-double-click-time' instead of 'double-click-time'.
* src/keyboard.c (syms_of_keyboard): Mention
'mouse-double-click-time' in doc string of 'double-click-time'.
* test/lisp/mouse-tests.el (mouse-test-mouse-double-click-time):
New test.
2022-05-02 12:03:08 +02:00
Lars Ingebrigtsen
a7f2eb3054 Make isearch respond to 'mouse-yank-at-point'
* doc/emacs/killing.texi (Secondary Selection): Document it.
* lisp/isearch.el (isearch-mouse-2): Make isearch respond to
mouse-yank-at-point (bug#7787).

* lisp/mouse.el (mouse-yank-at-point): Mention it.
2022-04-27 14:02:23 +02:00
Po Lu
1e1a66831b Respect new DND options when dragging to ourselves on Haiku
* lisp/mouse.el (mouse-drag-and-drop-region): Allow dragging to
the current frame if we know `return-frame' doesn't work.
* lisp/term/haiku-win.el (haiku-dnd-drag-handler): New function.
* src/haiku_support.cc (MouseMoved): Don't send drag motion
events for the drag frame.
* src/haikuselect.c (haiku_note_drag_motion_1)
(haiku_note_drag_motion_2, haiku_note_drag_motion): New
functions.
(syms_of_haikuselect): New variable `haiku-drag-track-function'.
* src/haikuterm.c (haiku_read_socket): Note mouse motion in that
case.q
* src/haikuterm.h: Update prototypes.
2022-04-05 00:54:03 +00:00
Po Lu
aea799838b Improve behavior of dragging text to windows on top of frames
* doc/lispref/frames.texi (Drag and Drop): Document new meaning
of `return-frame' in `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Use `now' when
calling `x-begin-drag'.
* src/xfns.c (Fx_begin_drag): Update doc string.
* src/xterm.c (x_dnd_begin_drag_and_drop): Accept return_frame
as a Lisp_Object and handle Qnow correctly.
(XTmouse_position): Ignore tooltip frames when processing
`drag-source'.
(syms_of_xterm): New defsym `now'.
* src/xterm.h: Update prototypes.
2022-04-04 13:10:01 +08:00
Po Lu
28f720e7c4 Make dragging stuff to a window above a frame work
* doc/lispref/frames.texi (Mouse Tracking):
* etc/NEWS: Announce new `drag-source' value of `track-mouse'.
* lisp/mouse.el (mouse-drag-and-drop-region): Use new value of
`track-mouse' during interprogram drag and drop.

* src/keyboard.c (make_lispy_position): Handle nil values of f
correctly.
* src/xdisp.c (define_frame_cursor1): Ignore if `drag-source' as
well.
(syms_of_xdisp): New defsym `drag-source'.
* src/xterm.c (XTmouse_position): Implement `drag-source'.
(mouse_or_wdesc_frame): Likewise.
2022-04-03 18:59:12 +08:00
Po Lu
7899e8daff Fix error on mouse move over something not a window while dragging text
* lisp/mouse.el (mouse-drag-and-drop-region): Handle non-window
values of `posn-window' correctly.
2022-04-02 15:59:15 +08:00
Po Lu
c8a49b69ab ; * lisp/mouse.el (mouse-drag-and-drop-region-scroll-margin): Fix type. 2022-04-02 15:48:57 +08:00
Po Lu
e351e9037c Add new option `mouse-drag-and-drop-region-scroll-margin'
* etc/NEWS: Announce new user option.
* lisp/mouse.el (mouse-drag-and-drop-region-scroll-margin): New
user option.
(mouse-drag-and-drop-region): Implement "scroll margin" like
behavior during mouse movement.
2022-04-02 15:45:00 +08:00
Po Lu
0a32037c92 Implement DELETE selection target for cross program drags
* lisp/mouse.el (mouse-drag-and-drop-region): Make sure mark
stays deactivated if a "cut" operation was performed.
* lisp/select.el (xselect-convert-to-delete): Don't clear
selection contents if it's the XdndSelection.
2022-04-02 14:59:08 +08:00
Po Lu
8aff4c0a36 Handle quitting correctly during interprogram drag-and-drop
* lisp/mouse.el (mouse-drag-and-drop-region): Handle quit
correctly by exiting the cross program drag and drop.
2022-03-23 11:30:13 +08:00
Lars Ingebrigtsen
c8bde5b0a3 Fix two no-X compilation warnings
* lisp/mouse.el (x-hide-tip, x-show-tip): Declare to avoid no-X
build compilation warnings (bug#54524).

* lisp/term/pgtk-win.el (window-system-initialization): Avoid no-X
compilation warning.
2022-03-22 21:14:21 +01:00
Po Lu
13762d24b8 Display drag-and-drop messages in echo area on non-graphics displays
* lisp/mouse.el (mouse-drag-and-drop-region-display-tooltip)
(mouse-drag-and-drop-region-hide-tooltip): New functions.
(mouse-drag-and-drop-region): Use them instead of calling
`x-hide-tip' and `x-show-tip' directly.
2022-03-17 15:12:23 +08:00
Po Lu
e8d7139b4e Fix minor bugs with XDND support
* lisp/mouse.el (mouse-drag-and-drop-region): Report more
selection targets for the benefit of Qt and Mozilla.
* lisp/select.el (xselect--encode-string)
(selection-converter-alist): Add new selection targets.

* src/xterm.c (x_dnd_get_window_proxy): New function.
(x_dnd_get_target_window): New argument proto_out, and return
first window with XdndAware instead of bottommost window.
(handle_one_xevent): Use new argument `proto_out'.
2022-03-16 17:03:19 +08:00
Po Lu
47dcf72dec Fix tooltip text properties showing up in dragged text
* lisp/mouse.el (mouse-drag-and-drop-region): Directly call
x-show-tip and x-hide-tip instead of going through tooltip-show.
2022-03-16 15:20:10 +08:00
Po Lu
f62a6acd00 Better handle drag-and-drop from one Emacs frame to another
* doc/lispref/frames.texi (Drag and Drop): Document new
parameter `return-frame' to `x-begin-drag'.
* lisp/mouse.el (mouse-drag-and-drop-region): Utilize new
feature.

* src/xfns.c (Fx_begin_drag): New parameter `return-frame'.
* src/xterm.c (x_dnd_begin_drag_and_drop): New parameter
return_frame_p.
(handle_one_xevent): Set new flags and return frame whenever
appropriate.
* src/xterm.h: Update prototypes.
2022-03-16 12:33:15 +08:00
Po Lu
e53fba3fd4 Add support for dragging text from Emacs to other programs
This still probably needs some more protection from
malfunctioning clients which delete windows at random, but I
don't know if that's a problem in practice.

* doc/emacs/frames.texi (Drag and Drop):
* doc/lispref/frames.texi (Drag and Drop): Document new
features.

* etc/NEWS: Announce new function `x-begin-drag' and new user
option `mouse-drag-and-drop-region-cross-program'.

* lisp/mouse.el (mouse-drag-and-drop-region-cross-program): New
user option.
(x-begin-drag): New variable declaration.
(mouse-drag-and-drop-region): If the mouse moves out of an Emacs
frame, begin a window system drag.
* lisp/x-dnd.el (x-dnd-handle-xdnd): Remove left-over debugging
code.

* src/xfns.c (Fx_set_mouse_absolute_pixel_position): Fix
indentation of opening paren.
(Fx_begin_drag): New function.
(syms_of_xfns): Define new subr.
* src/xselect.c (x_timestamp_for_selection): New function.

* src/xterm.c (X_DND_SUPPORTED_VERSION): New preprocessor
declaration.
(x_dnd_get_window_proto, x_dnd_send_enter, x_dnd_send_position)
(x_dnd_send_leave, x_dnd_send_drop, x_set_dnd_targets)
(x_dnd_begin_drag_and_drop): New functions.
(handle_one_xevent): Handle drag-and-drop motion and button
events when active.
(x_free_frame_resources): If f is the DND source, stop
drag-and-drop.
(x_term_init): Intern new atoms.
(syms_of_xterm): New symbol QXdndSelection.

* src/xterm.h (struct x_display_info): New atoms
Xatom_XdndAware, Xatom_XdndSelection, Xatom_XdndTypeList,
Xatom_XdndActionCopy, Xatom_XdndActionMove,
Xatom_XdndActionLink, Xatom_XdndActionAsk,
Xatom_XdndActionPrivate, Xatom_XdndActionList,
Xatom_XdndActionDescription, Xatom_XdndProxy, Xatom_XdndEnter,
Xatom_XdndPosition, Xatom_XdndStatus, Xatom_XdndLeave,
Xatom_XdndDrop, and Xatom_XdndFinished.
2022-03-16 11:31:29 +08:00
Juri Linkov
17c75146a4 * lisp/mouse.el (context-menu-entry): Remove help-buffer-under-preparation.
(bug#53910)
2022-02-20 20:56:06 +02:00
Juri Linkov
3d0f5bc219 * lisp/mouse.el (context-menu-entry): Don't create menu for Help commands.
Help commands that describe keybindings call context-menu-entry bound to
a key.  This causes too much trouble when trying to build the context menu
in a temporary Help buffer that is not displayed in a window.
OTOH, there is no information in context menus useful for Help commands.
So `help-buffer-under-preparation' is added to filter out such calls.
(bug#53910)
2022-02-17 20:28:43 +02:00
Juri Linkov
437382734a * lisp/mouse.el (context-menu-map): Select only unselected window (bug#53910) 2022-02-10 20:57:42 +02:00
Po Lu
d41a5e7e33 Improve selection of fonts available from `mouse-set-font'
People get confused on a build without font dialogs (such as a
Lucid build) if `menu-set-font' and `mouse-set-font' don't
present them a list of the fonts actually available on their
system.

* lisp/mouse.el (mouse-generate-font-name-for-menu)
(mouse-generate-font-menu): New functions.
(mouse-select-font): Allow the user to select from all fonts
available on the system.
(mouse-set-font): Use `mouse-select-font' to display font menu.
2022-02-09 11:27:15 +08:00
Juri Linkov
791694c5fe * lisp/mouse.el (context-menu-map): Select clicked window (bug#53249). 2022-01-15 20:37:15 +02:00
Juri Linkov
f19b34376a More fixes for recently committed context-menu additions from bug#52973
* lisp/hi-lock.el (highlight-symbol-at-mouse): New defalias.
(hi-lock-face-symbol-at-mouse): Rename from hi-lock-symbol-at-mouse.
(hi-lock-context-menu): Use thing-at-mouse and middle-separator.

* lisp/man.el (Man-context-menu): Fix Man-at-mouse and use middle-separator.

* lisp/mouse.el (context-menu-functions): Remove context-menu-online-search.
Add occur-context-menu and dictionary-context-menu (bug#50552).
2022-01-15 20:33:45 +02:00
Lars Ingebrigtsen
639488b55a Revert "Add command to invoke a search engine"
This reverts commit 3f36d08362.

Similar functionality has been added to webjump, so this commit duplicated that.
2022-01-15 09:06:50 +01:00
Lars Ingebrigtsen
373618d3a8 Add new context menu functions to the context-menu-functions type
* lisp/mouse.el (context-menu-functions): Add new menu functions
to the defcustom type list (bug#52973).
2022-01-14 09:49:44 +01:00
Philip Kaludercic
3f36d08362 Add command to invoke a search engine
* mouse.el (context-menu-online-search): Add new function
(eww-search-prefix): Declare variable from eww.el
(mouse-online-search-at-point): Add new command
2022-01-14 09:47:02 +01:00
Jim Porter
3eaf3aeec8 Prevent further cases of duplicated separators in context menus
In some cases, context menu items are added before the overall prompt
string.  This could cause multiple consecutive separators to appear if
they "surround" the prompt string.  (Bug#52293)

* lisp/mouse.el (context-menu-map): Improve the de-duplication logic
to ignore non-menu-items when checking for consecutive separators.

* test/lisp/mouse-tests.el
(context-menu-map-remove-consecutive-separators)
(context-menu-map-remove-separators-at-beginning-or-end): New tests.
2022-01-04 10:18:15 +02:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Stefan Monnier
aa3434369e lisp/mouse.el: Fix some lambdas quoted with ` or '
Also prefer #' to quote named functions.

* lisp/mouse.el (minor-mode-menu-from-indicator, context-menu-entry)
([C-down-mouse-3]): Don't abuse lambda lists for functions.
(context-menu-mode): Remove redundant `:group`.
(mouse-drag-line): Remove unused var `draggable`.
(mouse-yank-primary): Make it work for non-mouse events.
2021-12-08 16:14:03 -05:00
Juri Linkov
00d107ebea * lisp/mouse.el (context-menu-entry): Bind to make-sparse-keymap, not ignore.
Then where-is-internal does not run context-menu-map from the :filter,
and no context menu functions are called by e.g. describe-mode in wrong buffer
(bug#9923)
2021-12-08 22:31:55 +02:00
Stefan Kangas
abf06a46b4 Merge from origin/emacs-28
da23e607d3 Select the right buffer for event in context-menu function...
2021-12-07 06:47:32 +01:00
Juri Linkov
da23e607d3 Select the right buffer for event in context-menu functions (bug#9923)
* lisp/mouse.el (context-menu-region):
* lisp/progmodes/prog-mode.el (prog-context-menu):
Switch to the buffer displayed by the window of the event
before using syntax-ppss, char-after.
2021-12-06 19:24:09 +02:00
Lars Ingebrigtsen
6980a4fa45 Fix regression introduced by previous context-menu-map change
* lisp/mouse.el (context-menu-map): Make the context mode work
with flyspell again  (bug#52237).
2021-12-05 21:20:03 +01:00
Jim Porter
4a303c4dca Remove separators at the beginning and end of the context menu
* lisp/mouse.el (context-menu-map): Remove beginning/end
seperators (bug#52237).
2021-12-03 17:22:59 +01:00
Jim Porter
5db380abad Ensure there are no duplicate separators when creating a context menu
Previously, if there were three or more consecutive menu separators,
not all of them would be removed.

* lisp/mouse.el (context-menu-map): Ensure no duplicate separators
(bug#52237).
2021-12-02 09:23:06 +01:00
Stefan Kangas
1de6a86553 Merge from origin/emacs-28
0dd3883def Update to Org 9.5-72-gc5d6656
e3d5337970 Fix mouse handling with several TTY frames on MS-Windows
7e437af413 Fix temacs invocation from outside of the 'src' directory
0fbfd4253e ; Avoid byte-compilation warnings in edmacro.el
c22c988b1f Fix mouse events on tab bar or tool bar when 'track-mouse'...
354c834fba Fix `browse-url-interactive-arg' for certain kinds of events

# Conflicts:
#	lisp/mouse.el
2021-11-21 11:18:23 +01:00
martin rudalics
c22c988b1f Fix mouse events on tab bar or tool bar when 'track-mouse' is t
* lisp/mouse.el (mouse-drag-track):
* lisp/mouse-drag.el (mouse-drag-drag): Set 'track-mouse' to some
value neither t nor nil.
* src/keyboard.c (make_lispy_position): If track_mouse is Qt,
report event on tool or tab bar (Bug#51794).
2021-11-20 12:05:36 +02:00
Stefan Kangas
c6d5fccc92 Merge from origin/emacs-28
02853edba7 Fix sorting of menus in `context-menu-local' (bug#50067).
14271d050a Fix flyspell-correct-word selected from context menu opene...
bf824843f4 * lisp/repeat.el (describe-repeat-maps): Print all bound k...
6fc94fb99e * lisp/tab-bar.el: Use 'mouse-1' for history buttons like ...
5eeaf85767 Improve documentation of window hooks
7404f4b4e0 Improve doc string of 'highlight-nonselected-windows'
2021-11-19 07:00:24 +01:00
Juri Linkov
02853edba7 Fix sorting of menus in `context-menu-local' (bug#50067).
* lisp/menu-bar.el (menu-bar-keymap): Don't use `lookup-key'
on the `keymap' arg.

* lisp/mouse.el (context-menu-global): Use `lookup-key global-map'
for the `keymap' arg of `menu-bar-keymap'.
(context-menu-local): Use `menu-bar-keymap' to sort `keymap'.
2021-11-18 20:36:55 +02:00
Juri Linkov
14271d050a Fix flyspell-correct-word selected from context menu opened with the keyboard
* lisp/mouse.el (context-menu-open): Call interactively a command
returned by `context-menu-map' such as `flyspell-correct-word' (bug#50067).

* lisp/textmodes/flyspell.el (flyspell-correct-word): Handle the
case when it's called by a key bound to `context-menu-open'.
Then it should work the same way as `C-c $' typed on misspelled word
where the arg `event' of `flyspell-correct-word-before-point' is nil.
2021-11-18 20:23:58 +02:00
Stefan Kangas
ba0e4f3ad3 Merge from origin/emacs-28
307d164c9c * lisp/mouse.el (mouse-buffer-menu-mode-groups): Tighten "...
818211ed89 * doc/emacs/search.texi (Isearch Yank): Add isearch-forwar...

# Conflicts:
#	etc/NEWS
2021-11-09 06:59:24 +01:00
Juri Linkov
307d164c9c * lisp/mouse.el (mouse-buffer-menu-mode-groups): Tighten "Version Control".
Use word boundaries in the "Version Control" regexp to match mode names
"Log-Edit", "Log-View", "Git-Log-View", "Change Log", "VC dir",
but not "Verilog", "Prolog", "Rlogin" (bug#51337).
2021-11-08 21:23:44 +02:00