Commit graph

46495 commits

Author SHA1 Message Date
Po Lu
ce51354432 Fix flicker during mouse DND on Haiku as well
* src/haikuterm.c (haiku_read_socket): Don't clear tooltips on
crossing if track-mouse is drag-source and the display is
grabbed.
2022-06-02 05:44:46 +00:00
Po Lu
1b9aca0ea8 Fix typos in last change
* src/xterm.c (handle_one_xevent): Fix typos.
2022-06-02 13:37:52 +08:00
Po Lu
2a40fa3d85 Fix tooltips flickering on X during `mouse-drag-and-drop-region'
* src/xterm.c (x_get_window_below): New function.
(XTmouse_position): If track-mouse is drag-source and a window
is a tooltip, look below it.
(handle_one_xevent): Don't generate a nil help-echo event on
LeaveNotify if the display is grabbed and track-mouse is
drag-source.
2022-06-02 13:33:38 +08:00
Po Lu
d9e106c72e Clean up Motif drag-and-drop code
* src/xterm.c (enum xm_drag_operation, enum xm_drag_action)
(enum xm_drag_reason, enum xm_drag_originator, enum xm_drag_style)
(enum xm_drop_site_status): Turn macros into enums.
(x_next_event_from_any_display): Fix initial value of rc.
2022-06-02 09:02:55 +08:00
Po Lu
47b8c3f0b9 Fix decoding of XdndStatus rectangles on 64-bit systems
* src/xterm.c (handle_one_xevent): Make data.l[2] and data.l[3]
unsigned.
2022-06-02 08:32:23 +08:00
Mattias Engdegård
f71cfd3084 Revert "Fix reader char escape bugs (bug#55738)"
This reverts commit c50718dcfa.

It may have caused bootstrap problems. Sorry about that.
2022-06-01 22:49:34 +02:00
Eli Zaretskii
58965d91e7 Avoid segfaults on MS-Windows when invoked with --version
* src/emacs.c (main): If invoked with --version, call
'init_bignum' before calling 'format-time-string', as that is
needed for safe manipulation of bignums in timefns.c.
2022-06-01 21:57:07 +03:00
Mattias Engdegård
c50718dcfa Fix reader char escape bugs (bug#55738)
Make the character literal ?\LF (linefeed) generate 10, not -1.

Ensure that Control escape sequences in character literals are
idempotent: ?\C-\C-a and ?\^\^a mean the same thing as ?\C-a and ?\^a,
generating the control character with value 1.  "\C-\C-a" no longer
signals an error.

* src/lread.c (read_escape): Make nonrecursive and only combine
the base char with modifiers at the end, creating control chars
if applicable.  Remove the `stringp` argument; assume character
literal syntax.  Never return -1.
(read_string_literal): Handle string-specific escape semantics here
and simplify.
* test/src/lread-tests.el (lread-misc-2): New test.
2022-06-01 19:47:30 +02:00
Po Lu
65ffb115b4 ; * src/xterm.c (x_wait_for_cell_change): Don't call ConnectionNumber twice. 2022-06-01 21:28:35 +08:00
Po Lu
873bcd6d5d Minor fixes to x_next_event_from_any_display
* src/xterm.c (x_next_event_from_any_display): Don't call
XPending unless there is input to be read on the connection, and
don't call ConnectionNumber twice.
2022-06-01 20:52:07 +08:00
Po Lu
e9bb2d7f4e Fix Motif DND return value upon transfer failure
* src/xterm.c (handle_one_xevent): Make XmTRANSFER_FAILURE clear
DND action.
2022-06-01 18:24:05 +08:00
Po Lu
f5fadbbfec Clean up text/uri-list mess inside the Dired drag-and-drop code
* doc/lispref/frames.texi (Window System Selections):
* etc/NEWS: Document new changes to `gui-get-selection'.
* lisp/dired.el (dired-mouse-drag): Specify text/uri-list value
explicitly.
* lisp/select.el (gui-set-selection): Update doc string.
(xselect-convert-to-text-uri-list): Update to handle either a
single URL (as a string) or a vector of URLs, instead of file
names.
(xselect-uri-list-available-p): Likewise.
* src/xselect.c (x_get_local_selection): Look in tem's text
properties (if it is a string) for a local value before using
tem itself.
2022-06-01 16:25:53 +08:00
Po Lu
a3d3fef2bc Fix hangs when explicitly moving frames with input blocked
* src/xterm.c (x_check_expected_move): Fix indent.
(x_sync_with_move): Use pselect to wait the 0.5 seconds instead
of wait_reading_process_output if input is blocked.
2022-06-01 14:13:57 +08:00
Po Lu
76850b26b9 Implement `allow-same-frame' for NS drag-and-drop
* lisp/term/ns-win.el (x-begin-drag): Implement
`allow-same-frame'.
* src/nsselect.m (Fns_begin_drag): New parameter
`allow-same-frame'.
* src/nsterm.h (@interface EmacsWindow): Update prototypes.
* src/nsterm.m ([EmacsView draggingEntered:]):
([EmacsView prepareForDragOperation:]):
([EmacsView performDragOperation:]): Respect new parameter.
([EmacsWindow beginDrag:forPasteboard:withMode:returnFrameTo:]):
Likewise.
2022-06-01 13:50:40 +08:00
Po Lu
f610b4b509 Fix creation of menu items without help text on Haiku
* src/haiku_support.cc (EmacsMenuItem): Don't mistakenly assume
help is non-NULL.
2022-06-01 05:06:14 +00:00
Po Lu
8a2dbf9f86 Fix pselect usage mistakes
* src/xterm.c (x_next_event_from_any_display):
(x_wait_for_cell_change): Fix calls to pselect and tests against
return value.
2022-06-01 12:51:52 +08:00
Po Lu
3b9bbb24eb Fix the GTK build
* src/xterm.c (x_wait_for_cell_change): Don't initialize rfds
on GTK.
2022-06-01 08:57:52 +08:00
Po Lu
5ed566cae0 Improve x_wait_for_cell_change
* src/xterm.c (x_wait_for_cell_change): Keep processing events
while still XPending.
2022-06-01 08:57:08 +08:00
Eli Zaretskii
576d750915 Remove unused w32-* variables
* src/w32fns.c (syms_of_w32fns) <w32-bdf-filename-alist>
<w32-strict-fontnames>: Remove unused variables.
2022-05-31 20:28:50 +03:00
Po Lu
90957dfb7a Slightly optimize x_check_errors as well
* src/xterm.c (x_check_errors): Don't sync if no requests were
made since the error trap was installed.
2022-05-31 20:56:55 +08:00
Po Lu
fbe7ac16d7 Fix replying to _NET_WM_PING during drag-and-drop
* src/xterm.c (handle_one_xevent): Test client window against
root window instead of using nonstandard event mask.
2022-05-31 18:18:52 +08:00
Po Lu
f8d07fbeb3 Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs 2022-05-31 18:06:15 +08:00
Po Lu
2021835326 Implement `return-frame' for DND on NS
* src/nsselect.m (Fns_begin_drag): New argument `return-frame'.
(syms_of_nsselect): New defsym.
* src/nsterm.h (EmacsWindow): New fields.
* src/nsterm.m (ns_read_socket): Split parts off to
ns_read_socket_1.
(ns_read_socket_1): New function.
(ns_flush_display): Use that function instead.

([EmacsWindow beginDrag:forPasteboard:]): Update for
return-frame.
2022-05-31 18:05:41 +08:00
Po Lu
7263b10efb Fix autorelease pool "straddling" during DND on NS
* src/nsterm.m (ns_mouse_position): Implement `drag-source'
on NS.
([EmacsView draggingUpdated:]): Add autorelease pool around
callbacks.
([EmacsWindow beginDrag:forPasteboard:]): Block input around
dragImage.
2022-05-31 16:40:57 +08:00
Paul Eggert
a55a0483c9 Pacify GCC 12 in x_get_current_wm_state
* src/xterm.c (x_get_current_wm_state): When lint checking,
initialize reply_data to a non-null dummy value instead of to a
null one.  This pacifies GCC 12 -Wanalyzer-null-dereference.
2022-05-31 01:26:47 -07:00
Paul Eggert
0614e0f3e9 Pacify GCC 12 in dump_queue_enqueue
* src/pdumper.c (dump_queue_enqueue): Use BASE_EQ, not EQ.
This pacifies GCC 12 -Wanalyzer-null-dereference.
2022-05-31 01:26:47 -07:00
Paul Eggert
569d4c7ad6 Be more robust if doc file is corrupted
* src/doc.c (Fsnarf_documentation): Don’t dump core on a corrupted
doc file.  Problem found by GCC 12 -Wanalyzer-null-argument.
2022-05-31 01:26:47 -07:00
Paul Eggert
c4da5db04b Pacify GCC 12 in Fmove_overlay
* src/buffer.c (Fmove_overlay): Use BASE_EQ, not EQ.
This pacifies GCC 12 -Wanalyzer-null-dereference.
2022-05-31 01:26:47 -07:00
Paul Eggert
1f6973241a Pacify GCC 12 in Fx_show_tip
* src/xfns.c (Fx_show_tip): Use BASE_EQ, not EQ.
This pacifies GCC 12 -Wanalyzer-null-dereference.
2022-05-31 01:26:47 -07:00
Paul Eggert
920f1e68b8 Pacify GCC 12 in xrdb.c
* src/xrdb.c (x_get_resource): Simply assign the return	value.
This pacifies GCC 12 -Wanalyzer-use-of-uninitialized-value.
2022-05-31 01:26:47 -07:00
Paul Eggert
13dac6f3e9 Pacify GCC 12 false positive in ccl.c
* src/ccl.c: Suppress -Wanalyzer-use-of-uninitialized-value
in GCC 12 or later.
2022-05-31 01:26:47 -07:00
Paul Eggert
30966a6e67 Simplify CHAR_TABLE_REF_ASCII
* src/lisp.h (CHAR_TABLE_REF_ASCII): Refactor as a straightforward
for-loop.  Redo an if-then-else to be an (!if)-else-then as this
is a bit cleaner, and it also works around GCC bug 105755.
2022-05-31 01:26:47 -07:00
Paul Eggert
82c05c034e Avoid undefined behavior in detect_coding routines
* src/coding.c (detect_coding): Always initialize all
components of detect_info, so that detect_coding_utf_8 etc.
do not have undefined behavior when they read detect_info.checked.
This bug is not likely to cause problems on real systems.
Problem found by GCC 12 -fanalyzer.
(detect_coding_system): Use consistent style with detect_coding
initialization.
2022-05-31 01:26:47 -07:00
Paul Eggert
877be9098e Pacify GCC 12 -fanalyzer in x_popup_menu_1
* src/menu.c (x_popup_menu_1): Rework to avoid unnecessary
initialization and test.  This also pacifies GCC 12.
2022-05-31 01:26:47 -07:00
Po Lu
d94890404e Fix crashes displaying menu help text on NS
* src/nsterm.m (ns_flush_display): Run event loop manually,
avoiding a double free of an autorelease pool.
2022-05-31 16:25:20 +08:00
Po Lu
b7bbf88642 Fix processing of DND events on GTK
* src/xterm.c (x_dnd_begin_drag_and_drop): Clear `current_count'
and `current_hold_quit' after calling gtk_main_iteration.
2022-05-31 13:24:27 +08:00
Po Lu
75bf80e2b1 Fix unused variables on GTK
* src/xterm.c (x_wait_for_cell_change): Fix unused variables
on GTK builds.
2022-05-31 10:17:12 +08:00
Po Lu
dae936f504 Fix initialization of `hold_quit' during DND
* src/xterm.c (x_dnd_begin_drag_and_drop): Use `EVENT_INIT'
instead of just setting type to NO_EVENT.
2022-05-31 10:15:29 +08:00
Po Lu
81b174cace Prevent events from being lost waiting for selections on GTK
* src/xterm.c (x_wait_for_cell_change): Use GTK to iterate the
main loop so events reach the toolkit.
2022-05-31 08:47:30 +08:00
Eli Zaretskii
c9e5e79ac2 Fix 'debug-timer-check' on MS-Windows
* src/w32proc.c (w32_raise): New function.
* src/atimer.c (raise) [WINDOWSNT]: Redirect to 'w32_raise'.
2022-05-30 20:51:19 +03:00
Mattias Engdegård
b903507b36 Nonrecursive Lisp reader (bug#55676)
Restructure the reader to be nonrecursive so that it is not limited by
the C stack or crashes Emacs when reading deeply nested data.
This also improves performance.
A few minor bugs were fixed:

- (a .{NBSP}b) where {NBSP} is a non-breaking space (U+00A0) is now
  the dotted pair (a . b), not the 3-element list (a \. b), since U+00A0
  is treated as whitespace everywhere else.
- #_ with no symbol following is now equivalent to ## (empty interned
  symbol), not #: (empty uninterned symbol).

* src/alloc.c (garbage_collect): Call mark_lread.
* src/lread.c (readevalloop): Use read0 instead of read_list.
(stackbufsize): Increase to 1024, now that read0 isn't recursive.
(invalid_radix_integer): Buffer overflow check.
(read1, read_list, read_vector): Remove.
(read_char_literal, read_string_literal)
(hash_table_from_plist, record_from_list, vector_from_rev_list)
(bytecode_from_rev_list, char_table_from_rev_list)
(sub_char_table_from_rev_list, string_props_from_rev_list)
(read_bool_vector, skip_lazy_string, symbol_char_span)
(skip_space_and_comments)
(enum read_entry_type, struct read_stack_entry, struct read_stack)
(rdstack, mark_lread, read_stack_top, read_stack_pop)
(read_stack_empty_p, grow_read_stack, read_stack_push): New.
(read0): Rewrite to be nonrecursive.
* test/src/lread-tests.el (lread-deeply-nested, lread-misc): New tests.
2022-05-30 15:56:59 +02:00
Mattias Engdegård
169797a300 Fix atimer setting and overdue expiration (bug#55628)
* src/atimer.c (set_alarm): If the atimer has already expired, signal
it right away instead of postponing it further.  Previously this could
occur repeatedly, blocking atimers indefinitely.
Also only use `alarm` as fallback if `setitimer` is unavailable, not
both at the same time (which makes no sense, and they both typically
use the same mechanism behind the curtains).

* test/src/eval-tests.el (eval-tests/funcall-with-delayed-message):
New test, verifying proper functioning of funcall-with-delayed-message
which also serves as test for this bug (which also caused
debug-timer-check to fail, but that test is only run when Emacs is
built with enable-checking).
2022-05-30 15:52:02 +02:00
Po Lu
f81065a91b Fix `dnd-indicate-insertion-point' on Mac OS
* lisp/term/ns-win.el (ns-handle-drag-motion): Remove debugging
code.

* src/nsterm.m ([EmacsView draggingUpdated:]): Redisplay here
instead.
2022-05-30 16:03:11 +08:00
Po Lu
3eca30bc50 Update frame positions on Haiku after changing Z group
* src/haiku_support.cc (EmacsScreenChangeMonitor): Fix comment.
* src/haikufns.c (haiku_set_z_group): Ask for a position update,
since changing the Z group might change the feel of the window.
2022-05-30 07:55:13 +00:00
Po Lu
d8adce56a0 Fix cursor flushing inside minibuffers on NS
* src/nsterm.m (EV_TRAILER): Fix coding style.
(ns_flush_display): New function.
(ns_redisplay_interface): Register `flush_display'.
2022-05-30 15:06:55 +08:00
Po Lu
fd510f1239 Fix hangs when x-get-selection is called inside a popup menu
* src/xselect.c (wait_for_property_change):
(x_get_foreign_selection): Use `x_wait_for_cell_change' if input
is blocked.  (bug#22214)
* src/xterm.c (x_wait_for_cell_change): New function.
* src/xterm.h: Update prototypes.
2022-05-30 14:05:30 +08:00
Po Lu
48ef8ab15f Try to implement `dnd-indicate-insertion-point' on macOS
* lisp/term/ns-win.el (ns-handle-drag-motion): New function.
* src/nsterm.m ([EmacsView draggingUpdated:]): Call that
function instead.
(syms_of_nsterm): Clean up old style defvars and add new
defvar for the DND drag function.
2022-05-30 10:36:43 +08:00
Po Lu
5b770b60f4 Further clean up DND target handling
* src/xfns.c (Fx_begin_drag): Alloca target list.

* src/xterm.c (x_set_dnd_targets): Copy the given targets list.
(x_dnd_begin_drag_and_drop): Record freeing the targets list on
the specpdl.
(handle_one_xevent, x_dnd_cleanup_drag_and_drop)
(x_connection_closed, x_delete_terminal): Stop calling
`x_set_dnd_targets' manually to free the targets list.
2022-05-30 09:25:03 +08:00
Po Lu
e2e232933c Fix crash when loading Postscript images
* src/xterm.c (handle_one_xevent): Catch errors around
`x_kill_gs_process'.
2022-05-30 09:07:27 +08:00
Po Lu
b6a4766388 Use XDrawPoint to clear relief rect corners
* xterm.c (x_clear_point): New function.
(x_draw_relief_rect): Use that instead.
2022-05-30 08:49:24 +08:00