Commit graph

45694 commits

Author SHA1 Message Date
Po Lu
1babe5fb2d Fix XI 2.0 build
* src/xterm.c (handle_one_xevent): Move declaration of dummy out
of HAVE_XINPUT2_1.
2022-03-16 15:51:02 +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
5ff13718a5 * src/xfns.c (Fx_begin_drag): Improve doc string. 2022-03-16 11:45:57 +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
Po Lu
bf7d66aa1a Fix build with GTK 3.18.0 or earlier
* src/gtkutil.c (xg_update_scroll_bar_pos)
(xg_update_horizontal_scrollbar_pos): Avoid
gtk_widget_queue_allocate on older GTK versions.
2022-03-16 08:42:33 +08:00
Eli Zaretskii
5e8fbf7789 Clean up implementation of N0 per UAX#9
* src/bidi.c (bidi_resolve_brackets): Instead of requiring
prev_for_neutral's type to be known, fall back on SOS, per
the UBA.
2022-03-15 21:21:20 +02:00
Po Lu
e547ca1f89 Fix some minor glitches with Haiku scroll bars
* src/haiku_support.cc (MouseDown): Don't start overscroll if
dragging started inside a button.
2022-03-15 04:46:01 +00:00
Po Lu
90742d7b01 Fix crashes when trying to pop up a menu on GTK 2
* src/xterm.c (handle_one_xevent): Respect finish when
dispatching copy.
2022-03-15 12:14:56 +08:00
Po Lu
2bfa184e29 Fix some issues with input on GTK 2 builds
* src/xfns.c (setup_xi_event_mask): Don't ask for XI key press
on GTK 2.
2022-03-15 12:10:31 +08:00
Po Lu
8cc8dfd67e Fix extraneous ifdef in xwidgets code
* xterm.c (handle_one_xevent): Pass GesturePinchEnd events to
xwidgets regardless of no-longer-present define.
2022-03-15 10:28:54 +08:00
Po Lu
299e475361 * src/xterm.c (handle_one_xevent): Fix use of wrong motion structure. 2022-03-15 10:24:13 +08:00
Po Lu
3bf5c2a838 Stop relying on dynlib for PGTK interrupt input
* src/pgtkterm.c (pgtk_term_init): Use dlopen and dlsym directly
instead of dynlib functions.  (bug#54378)
2022-03-15 08:54:30 +08:00
Paul Eggert
0d0703e9c4 Prefer CALLN
* src/bytecode.c (Fbyte_code):
* src/composite.c (Fclear_composition_cache):
Prefer CALLN to doing it by hand.
* src/fns.c (ccall2): Remove.  All uses replaced by CALLN.
2022-03-14 09:06:20 -07:00
Po Lu
b72dd3d0c5 Handle position specification hints on X toolkit builds
* src/xterm.c (x_wm_set_size_hint): Set PPosition and USPosition
independently of Xt.
2022-03-14 21:40:38 +08:00
Lars Ingebrigtsen
f8cc706fb3 Improve the execute-kbd-macro doc string
* src/macros.c (Fexecute_kbd_macro): Improve the doc string
(bug#14206).
2022-03-14 12:17:24 +01:00
Lars Ingebrigtsen
637dde4aba Don't always escape "." and "?" in `prin1'
* src/print.c (print_object): Only escape "." and "?" when
appearing as the first character in a symbol (bug#23130).
2022-03-14 10:29:54 +01:00
Po Lu
a1fa3d24d7 Clean up some Haiku toolkit code
* src/haiku_io.c (haiku_read_with_timeout): Accept `bigtime_t'
instead of `time_t' for values which are cast to bigtime_t
anyway.
* src/haiku_support.cc (BMenu_run): Read all help events instead
of just one.
* src/haiku_support.h: Update prototypes.
2022-03-14 06:48:53 +00:00
Po Lu
faab1b2002 Fix extraneous overscroll activation on Haiku
* src/haiku_support.cc (class EmacsScrollBar): New field
`maybe_overscroll'.
(MouseDown): Set that field.
(MouseUp): Clear that field.
(MouseMoved): Also test `maybe_overscroll' to ensure that a grab
started inside the scroll bar.
2022-03-14 02:46:11 +00:00
Po Lu
a63bac7ade Fix tool-bar highlight persisting after mouse moves onto WM frame
* src/xterm.c (handle_one_xevent): Always report MotionNotify
coordinates in terms of the edit widget.
2022-03-14 09:07:13 +08:00
Glenn Morris
485a8fcbf4 * src/bytecode.c: Include sysstdio.h, for fprint, stderr.
; Ref https://hydra.nixos.org/build/169207408
2022-03-13 18:03:11 -07:00
Po Lu
17fd48efab Enable overscroll on Haiku horizontal scroll bars
* src/haiku_support.cc (MouseMoved): Handle horizontal
directions correctly.
* src/haikuterm.c (haiku_set_horizontal_scroll_bar_thumb):
Enable overscrolling on scroll bar widget.
2022-03-14 00:54:10 +00:00
Po Lu
57172d0a35 Fix scroll bar movement right before overscroll begins on Haiku
* src/haikuterm.c (haiku_set_scroll_bar_thumb): Make sure value
and size are within bounds even if portion adjustment is off.
2022-03-14 00:45:00 +00:00
Mattias Engdegård
edb8481ce1 * src/bytecode.c (sf_set_ptr): Cast pointer to type of right size. 2022-03-13 19:35:50 +01:00
Mattias Engdegård
3ed79cdbf2 Separate bytecode stack
Use a dedicated stack for bytecode, instead of using the C stack.
Stack frames are managed explicitly and we stay in the same
exec_byte_code activation throughout bytecode function calls and
returns.  In other words, exec_byte_code no longer uses recursion
for calling bytecode functions.

This results in better performance, and bytecode recursion is no
longer limited by the size of the C stack.  The bytecode stack is
currently of fixed size but overflow is handled gracefully by
signalling a Lisp error instead of the hard crash that we get now.

In addition, GC marking of the stack is now faster and more precise.
Full precision could be attained if desired.

* src/alloc.c (ATTRIBUTE_NO_SANITIZE_ADDRESS): Make non-static.
* src/bytecode.c (enum stack_frame_index, BC_STACK_SIZE)
(sf_get_ptr, sf_set_ptr, sf_get_lisp_ptr, sf_set_lisp_ptr)
(sf_get_saved_pc, sf_set_saved_pc, init_bc_thread, free_bc_thread)
(mark_bytecode, Finternal_stack_stats, valid_sp): New.
(exec_byte_code): Adapt to use the new bytecode stack.
(syms_of_bytecode): Add defsubr.
* src/eval.c (unwind_to_catch): Restore saved stack frame.
(push_handler_nosignal): Save stack frame.
* src/lisp.h (struct handler): Add act_rec member.
(get_act_rec, set_act_rec): New.
* src/thread.c (mark_one_thread): Call mark_bytecode.
(finalize_one_thread): Free bytecode thread state.
(Fmake_thread, init_threads): Set up bytecode thread state.
* src/thread.h (struct bc_thread_state): New.
(struct thread_state): Add bytecode thread state.
2022-03-13 17:51:49 +01:00
Mattias Engdegård
267f41c7ce Simplify exec_byte_code arguments
Pass the function object and encoded arity, not the other components.
This speeds up several call paths and is necessary for improvements to
come.

* src/bytecode.c (Fbyte_code): Make a new byte code object for
execution.  This is slower but performance isn't critical here.
(exec_byte_code): Retrieve components from the passed function.
* src/eval.c (fetch_and_exec_byte_code):
* src/lisp.h (exec_byte_code): Update signature.
2022-03-13 17:51:49 +01:00
Po Lu
49f70b603f Allow overscrolling on Haiku scroll bars that are full
* src/haiku_support.cc (MouseMoved): Allow overscrolling even if
portion is less than 1.0.
2022-03-13 12:58:06 +00:00
Po Lu
6ab04b59b1 Fix pointer event tracking on top of Haiku scroll bars
* src/haiku_support.cc (MouseDown): Set correct mouse event mask
in case the scroll bar widget decides to not do that.
2022-03-13 12:57:56 +00:00
Po Lu
1b8711f426 Fix splurious button events being generated on Haiku
* src/haiku_support.cc (MouseDown, MouseUp): Don't process if
the grab is not appropriate for the buttons that were pressed.
2022-03-13 12:33:09 +00:00
Po Lu
676dffff4b Fix setting IM spot after key press events
* src/xterm.c (handle_one_xevent): Check f is not NULL before
trying to set its status area and set preedit spot location
after KeyPress events.
2022-03-13 19:05:04 +08:00
Po Lu
6ea5b5e1b4 Fix small regression for horizontal scroll bars
* src/haikuterm.c (haiku_read_socket): Restore previous
horizontal scrollbar code, since the change it was intended for
was never made.
2022-03-13 07:27:24 +00:00
Po Lu
12f666c1d5 Improve overscrolling support on Haiku
* src/haiku_support.cc (class EmacsScrollBar): New field
`real_max_value'.
(MessageReceived): Set real max value.
(MouseMoved): Get rid of magic numbers by using real max value
instead.
2022-03-13 07:22:59 +00:00
Po Lu
ae8c146332 ; * haiku_support.cc (MessageReceived): Fix 32-bit build. 2022-03-13 06:50:12 +00:00
Po Lu
8c1a068159 Allow dragging scroll bar for overscroll on Haiku
* src/haiku_support.cc (class EmacsScrollBar): New fields
`in_overscroll', `can_overscroll', `last_overscroll',
`last_reported_overscroll_value' and `max_value'.
(ValueChanged): Make very sure extraneous value are not
generated.
(MouseUp): Clear overscroll if enabled.
(MouseMoved): If overscroll is enabled and dragging downwards
fails to dislodge the maximum value, enable overscrolling.
(BView_scroll_bar_update): New parameter `can_overscroll'
* src/haiku_support.h: Update prototypes.
* src/haikuterm.c (haiku_set_scroll_bar_thumb)
(haiku_set_horizontal_scroll_bar_thumb): Adjust parameters to
scroll bar update functions.
(haiku_read_socket): Take ceiling of bar position if
horizontal.
2022-03-13 06:45:46 +00:00
Stefan Monnier
20d9c4b59f Flocate_file_internal: Protect from .eln remapping
Don't use `openp`s functionality to remap `.elc` files to `.eln` files
since `locate-file` is not specific to ELisp files.
This should be not just simpler but more robust than the current
hack which tries to undo the damage after the fact.

* src/lread.c (Flocate_file_internal): Don't map `.elc` to `.eln`.
* lisp/files.el (locate-file): Simplify accordingly.
2022-03-12 23:51:22 -05:00
Po Lu
e7ab69e762 Improve reliaibility of scroll bar dimensions adjustment on GTK 3
* src/gtkutil.c (xg_scroll_bar_size_allocate_cb): New function.
(xg_finish_scroll_bar_creation): Attach new signal.
(xg_update_scrollbar_pos)
(xg_update_horizontal_scrollbar_pos): Also set window dimensions
for the event box.
* src/xterm.c (x_scroll_bar_configure): New function.
* src/xterm.h: Update prototypes.
2022-03-13 09:28:58 +08:00
Mattias Engdegård
bea1a96335 ; * src/eval.c: (grow_specpdl): Remove another redundant declaration 2022-03-12 17:54:25 +01:00
Mattias Engdegård
b176b9d4d1 ; * src/lisp.h: Remove redundant declaration 2022-03-12 17:46:38 +01:00
Mattias Engdegård
2c54e9a1dd Remove never-used relative jump opcodes
* src/bytecode.c (BYTE_CODES, exec_byte_code):
Remove relative jump opcodes that seem to have been a short-lived
experiment, never used in a release.
2022-03-12 17:32:31 +01:00
Mattias Engdegård
88889212c7 Remove debug code for opcodes long gone
* src/bytecode.c (BYTE_CODES, enum byte_code_op, exec_byte_code):
Don't display custom messages in debug mode for Bscan_buffer and
Bset_mark which were removed long ago.
2022-03-12 17:32:31 +01:00
Mattias Engdegård
2fb98486e1 Faster bytecode immediate argument fetching
* src/bytecode.c (FETCH2):
Use `|` instead of `+` to combine the bytes forming a 16-bit immediate
argument so that GCC (prior to version 12) recognises the idiom and
generates a 16-bit load.  This applies for little-endian machines with
cheap unaligned accesses such as x86[-64], arm64 and power64le.

This 1-character change results in a measurable speed gain on many
kinds of Lisp code, as 16-bit immediates are used by all jump
instructions.

Clang performs this optimisation for both `+` and `|` from version 10.
2022-03-12 17:32:31 +01:00
Mattias Engdegård
fe65db05f4 Maintain end of specpdl instead of size
Keep track of the end of specpdl explicitly since that is what we are
comparing against on critical code paths.

* src/eval.c (init_eval_once_for_pdumper, signal_or_quit)
(grow_specpdl_allocation):
* src/fileio.c (Fdo_auto_save):
* src/lisp.h (grow_specpdl):
* src/thread.c (run_thread, Fmake_thread):
* src/thread.h (struct thread_state):
Replace specpdl_size with specpdl_end, according to the equation
specpdl_end = specpdl + specpdl_size.
2022-03-12 17:32:31 +01:00
Mattias Engdegård
213483124b Inline record_in_backtrace
It's critical in several function call paths.

* src/eval.c (grow_specpdl_allocation): Make non-static.
(grow_specpdl, record_in_backtrace): Move from here...
* src/lisp.h (grow_specpdl, record_in_backtrace): ... to here,
and declare inline.
2022-03-12 17:32:31 +01:00
Po Lu
6ef9dc7797 Fix the PGTK build
* src/gtkutil.c (xg_finish_scroll_bar_creation): Fix ifdefs
preventing x_window from being correctly set.
(xg_get_scroll_id_for_window): Ifdef out unused function.
2022-03-12 20:58:18 +08:00
Po Lu
82a454915c Try really hard to make GTK 3 scroll bars fit
* src/gtkutil.c (xg_get_widget_from_map): New argument DISPLAY.
All callers changed.
(find_scrollbar_cb): New function.
(xg_finish_scroll_bar_creation, xg_remove_scroll_bar)
(xg_update_scrollbar_pos, xg_update_horizontal_scrollbar_pos)
(xg_set_toolkit_scroll_bar_thumb)
(xg_set_toolkit_horizontal_scroll_bar_thumb, xg_initialize):
Stop using id_to_widget_map on X builds with GTK 3 and set the
event box as the x_window instead.
* src/xterm.c (x_window_to_scroll_bar): Don't look for ID on GTK
3.
(handle_one_xevent): If a ConfigureNotify event is found for a
scroll bar and the dimensions are wrong, resize the X window to
the right ones.
2022-03-12 20:44:35 +08:00
Stefan Kangas
3af12cb8f2 Merge from origin/emacs-28
dbe6a3ecf7 Fix regression in 'custom-prompt-customize-unsaved-options'
a9920473f6 Improve documentation of 'map-charset-chars'
2022-03-12 06:34:05 +01:00
Po Lu
b5ac604b15 Fix some issues with input methods that depend on button state
* src/xterm.c (handle_one_xevent): Translate button state before
filtering events.
2022-03-12 13:03:00 +08:00
Po Lu
d0ff20f2e6 Fix horizontal scroll bar updating on Haiku
* src/haikuterm.c (haiku_set_horizontal_scroll_bar_thumb): Just
take portion and position without adjustments.
2022-03-12 03:16:00 +00:00
Po Lu
37cda51353 Use more reasonable default timeouts in Haiku menu loop
* src/haiku_support.cc (BMenu_run): Set default timeout to 10
seconds.
2022-03-12 03:02:03 +00:00
Po Lu
3ba3fdf7aa Make C-mouse-3 on scroll bars work on Haiku
* src/haiku_support.cc (class EmacsScrollBar): New field
`handle_button'.
(MouseDown, MouseUp): Pass button events with ControlMask to
parent view.
2022-03-12 02:47:03 +00:00
Po Lu
b279e1a5ec Slightly improve scrollbar position accounting on Haiku
* src/haiku_support.cc (MessageReceived): Use floats for
calculating portion and subtract proportion directly.
* src/haikuterm.c (haiku_set_scroll_bar_thumb): Take ceiling of
value instead of rounding it.
2022-03-12 00:46:39 +00:00