summaryrefslogtreecommitdiff
path: root/src/xterm.h
AgeCommit message (Collapse)Author
2026-05-23Fix misleading x_dnd_begin_drag_and_drop APIPaul Eggert
* src/xterm.c (x_dnd_begin_drag_and_drop): The n_ask_actions arg is an int, not a size_t, as XChangeProperty supports only int and our caller passes an int.
2026-05-19Make X_ERROR_MESSAGE_SIZE dependency more explicitPaul Eggert
This avoids an alloca in x_set_mouse_color. * src/xfns.c (x_set_mouse_color): Use local array rather than alloca, since the string is small. * src/xterm.c (X_ERROR_MESSAGE_SIZE): Move defn from here ... * src/xterm.h: ... to here, and make it an enum not a macro.
2026-01-01; Add 2026 to copyright years.Sean Whitton
2025-12-22Add functions to set frame size and position in one compound stepMartin Rudalics
* lisp/frame.el (set-frame-size-and-position): New function. * src/frame.c (adjust_frame_size): Handle requests to set size and position. (Fset_frame_size_and_position_pixelwise): New function. * src/gtkutil.c (xg_frame_set_size_and_position): New function. (xg_wm_set_size_hint): Handle any non-NorthWestGravity values for child frames only. Some GTK implementations don't like them. * src/gtkutil.h (xg_frame_set_size_and_position.): Add external declaration. * src/termhooks.h (set_window_size_and_position_hook): New hook. * src/w32term.c (w32_set_window_size_and_position): New function. (w32_create_terminal): Make it the Microsoft Windows API set_window_size_and_position_hook. * src/xterm.c (x_set_window_size_and_position_1) (x_set_window_size_and_position): New functions. (x_create_terminal): Make x_set_window_size_and_position the set_window_size_and_position_hook for the X protocol. * src/xterm.h (x_set_window_size_and_position): Add external declaration. * etc/NEWS: Announce new functions.
2025-12-09Port back to GTK2Paul Eggert
Problem reported by Sven Joachim in: https://lists.gnu.org/r/emacs-devel/2025-12/msg00225.html * src/xterm.c (xi_frame_selected_for): Also define if !(defined USE_GTK && defined HAVE_GTK3).
2025-12-09; Fix a typo in xterm.[ch].Eli Zaretskii
2025-12-08Fix some C symbol extern visibilityPaul Eggert
Make some C symbols static if they don’t need to be extern. Also, remove a couple of functions that were discovered to be unused as a result of this process, and mark two extern functions intended to be usable from GDB. * src/buffer.c (previous_overlay_change): * src/composite.c (composition_lisp_table): * src/fileio.c (file_name_directory): * src/frame.c (check_tty): * src/insdel.c (adjust_markers_for_insert): * src/keyboard.c (unread_switch_frame, read_char) (requeued_events_pending_p): * src/sysdep.c (renameat_noreplace) [!HAVE_ANDROID]: * src/textconv.c (get_conversion_field) [!HAVE_ANDROID]: * src/treesit.c (TREESIT_BOB_LINECOL, TREESIT_TS_POINT_1_0) (treesit_buf_tracks_linecol_p, make_treesit_parser) (make_treesit_node): * src/xdisp.c (x_y_to_hpos_vpos): * src/xfaces.c (load_color) [!MSDOS]: * src/xfns.c (x_real_pos_and_offsets): * src/xterm.c (x_dnd_do_unsupported_drop): Now static. Move up if necessary. * src/coding.c (utf8_string_p): * src/keyboard.c (detect_input_pending_ignore_squeezables): Remove; unused. * src/frame.c (gui_set_alpha): * src/textconv.c (start_batch_edit, end_batch_edit, commit_text) (finish_composing_text, set_composing_text) (set_composing_region, textconv_set_point_and_mark) (delete_surrounding_text, request_point_update) (textconv_barrier, replace_text, get_extracted_text) (get_surrounding_text): * src/xdisp.c (gui_union_rectangles): * src/xterm.c (xi_frame_selected_for): Define only if needed. * src/treesit.c (treesit_debug_print_parser_list) (treesit_debug_print_linecol): Declare EXTERNALLY_VISIBLE. * src/xdisp.c (x_y_to_column_row): New function, defined only if needed. All external callers to x_y_to_hpos_vpos changed.
2025-02-10Fix handling of visibility on tty frames (Bug#76031)Martin Rudalics
* src/frame.h (FRAME_REDISPLAY_P): Remove. Use the new function frame_redisplay_p instead. Extern frame_redisplay_p. * src/frame.c (frame_redisplay_p): New function to replace FRAME_REDISPLAY_P macro. (make_terminal_frame): Don't tinker with frame visibility and don't make the new frame the terminal's top frame. (do_switch_frame): Make sure frame switched to and any of its ancestors are visible. Don't reset the visibility of other frames. (other_frames): Do not assume tty frames are by default visible. (Fmake_frame_invisible): When making the selected tty frame invisible, explicitly select the next visible frame. * src/dispnew.c (Fredraw_display): Use frame_redisplay_p instead of FRAME_REDISPLAY_P. * src/xdisp.c (clear_garbaged_frames, echo_area_display) (prepare_menu_bars, redisplay_internal, display_and_set_cursor) (gui_clear_cursor): Use frame_redisplay_p instead of FRAME_REDISPLAY_P. * src/keyboard.c (tty_read_avail_input): When storing an event and the selected frame is a child frame whose root is its terminal's top frame, set the frame_or_window slot to the child frame since otherwise the next switch frame event will select the top frame instead.
2025-01-01Update copyright year to 2025Paul Eggert
Run "TZ=UTC0 admin/update-copyright".
2024-06-01On X, avoid reporting unrepresentable touch IDs to LispPo Lu
* src/xterm.c (xi_link_touch_point): Assign a Lisp-representable identifier to the new touch point and return the same. (xi_unlink_touch_point): New arg LOCAL_DETAIL. Return such an identifier if there is a matching touch point record. (handle_one_xevent): Adjust as is proper. * src/xterm.h (struct xi_touch_point_t) <local_detail>: New field. Reorder fields for alignment.
2024-05-11Pacify gcc -Wmissing-variable-declarationsPaul Eggert
This is a new warning diagnostic in GCC 14. * lib-src/etags.c (mercury_heuristics_ratio): * src/pgtkselect.c, src/xselect.c (selection_request_stack): * src/xselect.c (outstanding_transfers): * src/xterm.c (pending_selection_requests) (x_dnd_waiting_for_motif_finish_display): Now static. * lib-src/make-docfile.c (close_emacs_globals): Arrange for lispsym to be declared with extern first, when compiling lread.c. * src/alloc.c (gdb_make_enums_visible) [__GNUC__]: * src/emacs.c (RCS_Id): * src/keyboard.c (stop_character): * src/print.c (print_output_debug_flag): Now declared with extern first. * src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN) [MAIN_PROGRAM]: Arrange for ID to be declared extern first. * src/lisp.h (garbage_collection_inhibited): * src/xterm.h (x_frame_parm_handlers): Declare here, so that its interface is properly checked. Other decls removed.
2024-04-30Pacify GCC 14 -Wnull-dereferencePaul Eggert
* src/xterm.c (x_dpyinfo): New function, which acts like x_display_info_for_display except it always returns nonnull. This simplifies callers and pacifies GCC 14. All callers changed.
2024-01-20Be more systematic about parens in C source codePaul Eggert
Be more systematic about putting space before paren in calls, and in avoiding unnecessary parentheses in macros. This was partly inspired by my wading through gcc -E output while debugging something else, and seeing too many parens. This patch does not change the generated .o files on my platform.
2024-01-02Merge from savannah/emacs-29Po Lu
dc4e6b13296 ; Update copyright years in more files 64b37776318 ; Run set-copyright from admin.el 8e1c56ae467 ; Add 2024 to copyright years # Conflicts: # doc/misc/modus-themes.org # doc/misc/texinfo.tex # etc/NEWS # etc/refcards/ru-refcard.tex # etc/themes/modus-operandi-theme.el # etc/themes/modus-themes.el # etc/themes/modus-vivendi-theme.el # lib/alloca.in.h # lib/binary-io.h # lib/c-ctype.h # lib/c-strcasecmp.c # lib/c-strncasecmp.c # lib/careadlinkat.c # lib/cloexec.c # lib/close-stream.c # lib/diffseq.h # lib/dup2.c # lib/filemode.h # lib/fpending.c # lib/fpending.h # lib/fsusage.c # lib/getgroups.c # lib/getloadavg.c # lib/gettext.h # lib/gettime.c # lib/gettimeofday.c # lib/group-member.c # lib/malloc.c # lib/md5-stream.c # lib/md5.c # lib/md5.h # lib/memmem.c # lib/memrchr.c # lib/nanosleep.c # lib/save-cwd.h # lib/sha1.c # lib/sig2str.c # lib/stdlib.in.h # lib/strtoimax.c # lib/strtol.c # lib/strtoll.c # lib/time_r.c # lib/xalloc-oversized.h # lisp/auth-source-pass.el # lisp/emacs-lisp/lisp-mnt.el # lisp/emacs-lisp/timer.el # lisp/info-look.el # lisp/jit-lock.el # lisp/loadhist.el # lisp/mail/rmail.el # lisp/net/ntlm.el # lisp/net/webjump.el # lisp/progmodes/asm-mode.el # lisp/progmodes/project.el # lisp/progmodes/sh-script.el # lisp/textmodes/flyspell.el # lisp/textmodes/reftex-toc.el # lisp/textmodes/reftex.el # lisp/textmodes/tex-mode.el # lisp/url/url-gw.el # m4/alloca.m4 # m4/clock_time.m4 # m4/d-type.m4 # m4/dirent_h.m4 # m4/dup2.m4 # m4/euidaccess.m4 # m4/fchmodat.m4 # m4/filemode.m4 # m4/fsusage.m4 # m4/getgroups.m4 # m4/getloadavg.m4 # m4/getrandom.m4 # m4/gettime.m4 # m4/gettimeofday.m4 # m4/gnulib-common.m4 # m4/group-member.m4 # m4/inttypes.m4 # m4/malloc.m4 # m4/manywarnings.m4 # m4/mempcpy.m4 # m4/memrchr.m4 # m4/mkostemp.m4 # m4/mktime.m4 # m4/nproc.m4 # m4/nstrftime.m4 # m4/pathmax.m4 # m4/pipe2.m4 # m4/pselect.m4 # m4/pthread_sigmask.m4 # m4/readlink.m4 # m4/realloc.m4 # m4/sig2str.m4 # m4/ssize_t.m4 # m4/stat-time.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/stdio_h.m4 # m4/stdlib_h.m4 # m4/stpcpy.m4 # m4/strnlen.m4 # m4/strtoimax.m4 # m4/strtoll.m4 # m4/time_h.m4 # m4/timegm.m4 # m4/timer_time.m4 # m4/timespec.m4 # m4/unistd_h.m4 # m4/warnings.m4 # nt/configure.bat # nt/preprep.c # test/lisp/register-tests.el
2024-01-02; Add 2024 to copyright yearsPo Lu
2023-07-18Merge remote-tracking branch 'origin/master' into feature/androidPo Lu
2023-07-18Expose the ``cancellation'' of touch events to LispPo Lu
* doc/lispref/commands.texi (Touchscreen Events): * etc/NEWS: Describe new event parameter `canceled'. * src/keyboard.c (make_lispy_event) <TOUCHSCREEN_END_EVENT>: If event->modifiers, set canceled to t. * src/termhooks.h (enum event_kind): Describe meaning of modifiers in TOUCHSCREEN_END_EVENTs. * src/xfns.c (setup_xi_event_mask): Select for XI_TouchOwnership. * src/xterm.c (xi_link_touch_point): Round X and Y and clear ownership. (xi_unlink_touch_point): Return 1 if the touch point is not owned by Emacs, 2 otherwise. (handle_one_xevent): Handle XI_TouchOwnership events and report ownership correctly. * src/xterm.h (enum xi_touch_ownership): New enum. Write commentary on XI touch sequence ownership. (struct xi_touch_point_t): Use integer X and Y. New field `ownership'. Adjust for alignment.
2023-05-22Merge remote-tracking branch 'origin/master' into feature/androidPo Lu
2023-05-22Plug various leaks and fix input method initializationPo Lu
* src/image.c (free_bitmap_record): Free bm->name correctly even if the display connection has been closed. * src/xfns.c (x_window): Use dpyinfo-specific `use_xim' flag. * src/xterm.c (use_xim): Remove global variable. (xim_destroy_callback): Free `xim_styles' if present, and set it to NULL to be on the safe side. (xim_open_dpy): Consult dpyinfo->use_xim instead. Don't leak `xim_styles' if an IM was previously opened. (xim_initialize): Use dpyinfo-specific `use_xim' flag. (xim_close_dpy): Check if `dpyinfo->xim_callback_data' is set before unregistering the instantiation callback. (x_term_init): Determine whether or not to use XIM for each display opened, instead of using the resources of the last display opened to toggle a global flag. (x_delete_terminal): Always call `image_destroy_all_bitmaps' and `xim_close_dpy'. Free storage used to hold bitmap records. * src/xterm.h (struct x_display_info): New field `use_xim'.
2023-01-26Update Android portPo Lu
* INSTALL.android: Describe that apksigner is also required. * configure.ac: Correctly add cross/Makefile to SUBDIR_MAKEFILES. * cross/Makefile.in: (config.status): Depend on $(top_srcdir)/config.status. * doc/emacs/input.texi (On-Screen Keyboards): Document how to quit without a physical keyboard. * java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function `quit'. * java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New field `lastVolumeButtonPress'. (onKeyDown): Quit if necessary. * m4/ndk-build.m4 (ndk_where_cc): Fix search if CC is not a single word. * src/android.c (android_open): Remove unused variable. (quit): New function. * src/androidmenu.c (android_process_events_for_menu): Allow quitting the menu. * src/xterm.c (handle_one_xevent, x_term_init, syms_of_xterm): Implement features described above, so they work on free operating systems. * src/xterm.h (struct x_display_info): New fields `quit_keysym', `quit_keysym_time'.
2023-01-17Correctly handle touches on the tool barPo Lu
* src/xterm.c (xi_link_touch_point): New argument `frame'. Set new field `touchpoint->frame' to it. (xi_unlink_touch_points): New function. (xi_disable_devices): Clear the tool bar device on frames whose tool bar device matches this field. (handle_one_xevent): If an XI_TouchBegin event lands on the tool bar, then simulate a pointer click. Ignore future events from that touchpoint from there onwards. (x_make_frame_invisible, x_free_frame_resources): Unlink touch points associated with the frame. * src/xterm.h (struct xi_touch_point_t): New field `frame'. (struct x_output): New fields for keeping track of tool bar touches.
2023-01-01Merge from origin/emacs-29Eli Zaretskii
cae528457c ; Add 2023 to copyright years. b394359261 Improve documentation of 'isearch-open-overlay-temporary' ab3210e709 Document 'use-package' in the 2 main manuals # Conflicts: # etc/refcards/ru-refcard.tex # lib/explicit_bzero.c # m4/explicit_bzero.m4
2023-01-01; Add 2023 to copyright years.Eli Zaretskii
2022-12-26Redisplay "invisible" frames that are actually visible on modern XPo Lu
* etc/NEWS: Document that "invisible" frames are now redisplayed if the compositing manager is still displaying it as part of a thumbnail out of Emacs's control. * src/dispnew.c (Fredraw_display): Use FRAME_REDISPLAY_P. * src/frame.h (FRAME_REDISPLAY_P): New macro. * src/xdisp.c (clear_garbaged_frames, echo_area_display) (prepare_menu_bars, redisplay_internal, display_and_set_cursor) (gui_clear_cursor): Use FRAME_REDISPLAY_P to determine whether or not a frame should be redisplayed. * src/xfns.c (Fx_create_frame): Set visibility state initially. * src/xterm.c (handle_one_xevent): Likewise. * src/xterm.h (struct x_output): New field `visibility_state'.
2022-12-15Handle selection transfer errors earlierPo Lu
* src/xselect.c (x_decline_selection_request, struct transfer) (struct x_selection_request, x_cancel_selection_transfer) (x_start_selection_transfer, x_continue_selection_transfer): Give the right serial to x_ignore_errors_for_next_request. (x_handle_selection_error): New function. (x_reply_selection_request): Give the right serial to x_ignore_errors_for_next_request. * src/xterm.c (x_ignore_errors_for_next_request): New arg `selection_serial'. All callers changed. (x_error_handler): Call selection error handler. * src/xterm.h (struct x_failable_request): New field `selection_serial'.
2022-12-09; * src/xterm.h: Fix minor copyeditsPo Lu
2022-12-07; Minor copyedits of the latest xterm changeEli Zaretskii
* src/xterm.h (struct x_display_info): Fix a comment. * src/xterm.c (syms_of_xterm) <x-detect-server-trust>: Doc fix.
2022-12-07Fix some more problems with running Emacs as untrustedPo Lu
* etc/PROBLEMS (X security problems): Describe new variable. * src/xfns.c (append_wm_protocols): Don't support ping when it does not work. * src/xterm.c (x_wm_supports_1): Don't support anything when untrusted. (x_term_init): Implement Vx_detect_server_trust. (syms_of_xterm): New variable `x-detect-server-trust'. * src/xterm.h (struct x_display_info): New field `untrusted'.
2022-12-04Make Emacs build with Xfixes support on old versions of the libraryPo Lu
* src/xterm.c (xfixes_toggle_visible_pointer): (x_toggle_visible_pointer): (XTtoggle_invisible_pointer, x_term_init): Disable code requiring fixes 4.0 or later when the fixes library is older. * src/xterm.h: Define missing types needed by other extensions when the fixes library is too old. * configure.ac: Allow building with any version of the Xfixes extension library.
2022-12-02More behind the scenes transparent speedups around xselect.cPo Lu
* src/xdisp.c (display_menu_bar): Fix compiler warning about NULL pointer dereference. * src/xfns.c (Fx_begin_drag): Use x_intern_atoms. (Fx_change_window_property): Pass dpyinfo to x_fill_property_data. * src/xselect.c (lisp_data_to_selection_data): Use x_intern_atoms instead of syncing for each atom. (x_fill_property_data, x_send_client_event): Use x_intern_cached_atom. * src/xterm.c (x_intern_atoms): New function. * src/xterm.h: Update prototypes.
2022-12-01Finish up last change with more speedupsPo Lu
* src/xterm.c (x_atom_refs): * src/xterm.h (struct x_display_info): Add some new atoms to be interned at connection setup.
2022-12-01Speed up handling X selection requestsPo Lu
* etc/NEWS: Announce speedup. * src/alloc.c (garbage_collect): Call mark_xselect. * src/xftfont.c (xftfont_end_for_frame): Fix crash on display IO error. * src/xselect.c (struct selection_data, struct transfer): New structures. (outstading_transfers): New variable. (SELECTED_EVENTS, x_selection_request_lisp_error): Stop checking cs->nofree. (x_catch_errors_unwind): Delete function. (c_size_for_format, x_size_for_format, selection_data_for_offset) (selection_data_size, transfer_selecting_event) (x_continue_selection_transfer, x_remove_selection_transfers) (x_selection_transfer_timeout): New functions. (x_reply_selection_request): When handling selection requests, never wait for property notifications synchronously. Instead, write out the selection data as the client reads it from the event loop. (x_handle_selection_request, x_convert_selection) (x_handle_property_notify, x_get_window_property) (lisp_data_to_selection_data): Don't ever use pointers to Lisp string data! Instead, just store the string object itself. (syms_of_xselect): Initialize outstanding transfer list. (syms_of_xselect_for_pdumper): * src/xterm.c (x_delete_display): Remove outstanding selection transfers. * src/xterm.h: Update prototypes.
2022-11-27Make frame synchronization more robustPo Lu
* src/xterm.c (x_sync_wait_for_frame_drawn_event) (x_sync_handle_frame_drawn): Only cancel frame synchronization if hanging twice or more in a row. * src/xterm.h (struct x_output, FRAME_X_DRAW_JUST_HUNG): New flag.
2022-11-18Add knob to make `mouse-position' faster on XPo Lu
* etc/PROBLEMS (Improving performance with slow X connections): Add new advice. * src/xterm.c (XTmouse_position): Add alternative implementations for slow connections. (syms_of_xterm): Add new variable to enable them. * src/xterm.h (struct x_display_info): Update commentary.
2022-11-15More fixes to last changePo Lu
* lisp/dynamic-setting.el (font-setting-change-default-font): Call `reconsider-frame-fonts'. * src/frame.c (Freconsider_frame_fonts): New function. (syms_of_frame): Add new function.
2022-10-28Simplify scroll valuator reset handlingPo Lu
* src/xterm.c (xi_populate_device_from_info) (xi_reset_scroll_valuators_for_device_id, xi_handle_device_changed) (handle_one_xevent): * src/xterm.h (struct xi_scroll_valuator_t): Get rid of `pending_enter_reset', which was extremely convoluted and kept hitting server bugs. Now, valuators are reset upon all crossing events.
2022-10-25Fix drag-and-drop bugs on Lucid buildPo Lu
Also, optimize Fx_translate_coordinates to avoid excessive calls to _XReply. * lisp/x-dnd.el (x-dnd-get-drop-rectangle): Return empty drop rectangle if posn-area. * src/xfns.c (Fx_translate_coordinates): Accept arg `require_child'. If not set, allow optimizations based on cached position data. * src/xselect.c (x_handle_dnd_message): Use x_translate_coordinates. * src/xterm.c (x_translate_coordinates): Export function. (x_handle_translate_coordinates): New function. (handle_one_xevent): Fix coding style. * src/xterm.h: Update prototypes.
2022-10-23Reduce duplicate code for creating "special windows"Po Lu
* src/xterm.c (x_create_special_window): Define on all non-GTK builds and all builds with XFixes. (x_update_frame_user_time_window): Use x_create_special_window. Also write a comment explaining what user time windows are. * src/xterm.h: Fix style of `x_parse_color' prototype.
2022-10-17Fix pieces of code being too expensive over slow network connectionsPo Lu
* lisp/menu-bar.el (menu-bar-edit-menu): Test buffer-read-only before gui-backend-selection-exists-p. This places the less expensive condition before the more expensive one. * src/xfns.c (compute_tip_xy): Use cached monitor attributes whenever available. (Fx_show_tip): Remove code that really did nothing. (Fx_backspace_delete_keys_p): Do not download the entire keymap from the server upon creating a frame. * src/xmenu.c (create_and_show_popup_menu): Use x_translate_coordinates_to_root. (x_menu_show): Use x_translate_coordinates_to_root. * src/xselect.c (Fx_selection_exists_p): If a temporary selection owner can be found, use it. * src/xterm.c (x_translate_coordinates_to_root) (x_handle_selection_monitor_event, x_find_selection_owner): New functions. These functions try to avoid downloading data from the X server in places that are called very often (i.e. during tool bar updates.) (handle_one_xevent): Handle selection notify events. Also catch some mistakes found. Fetch all kinds of key names as well. (x_create_special_window): New function. (x_term_init, x_delete_display): Ask for all key names. Also, passively monitor selections that are given to `x-selection-exists-p' during redisplay, so we do not have to ask the server about them upon each redisplay. (syms_of_xterm): New variable `x-fast-selection-list'. * src/xterm.h (struct x_monitored_selection): New structure. (X_INVALID_WINDOW): New define. (struct x_display_info): New fields for selection monitoring. Also, record the fixes extension base.
2022-10-16Fix multiple sources of flicker under XPo Lu
Fix three kinds of flicker. The first is if you do: (while t (sit-for 1) (redraw-display)) and press a key, the frame will turn blank until you C-g. The second is where handling async input happens in the middle of drawing and causes a buffer flip to happen. The third is where unmapping the hourglass window causes exposures. * src/dispnew.c (redraw_frame): Garbage the frame if it is a window system frame. * src/xterm.c (x_update_begin): Clear complete flag. (x_flip_and_flush, XTframe_up_to_date): Set complete flag. (x_show_hourglass): Fix hourglass window class. (flush_dirty_back_buffer_on): Rename to x_flush_dirty_back_buffer_on. (x_flush_dirty_back_buffer_on): Check if the frame is complete before trying to flip. (handle_one_xevent): Flush frames in a more detailed fashion. * src/xterm.h (struct x_output): New flag `complete'. (FRAME_X_COMPLETE_P): New macro.
2022-10-03Fix coding systems used for X input methodsPo Lu
* doc/emacs/mule.texi (International): Refer to X Coding as well. (Communication Coding): Document that locale-coding-system is not always used on X to decode keyboard input. (X Coding): New node. * etc/NEWS: Announce change to input method coding resolution. * lisp/term/x-win.el (x-get-input-coding-system): New function. * src/coding.c (syms_of_coding): Update doc string of locale-coding-system. * src/xfns.c (struct x_xim_text_conversion_data) (x_xim_text_to_utf8_unix_1, x_xim_text_to_utf8_unix_2) (x_xim_text_to_utf8_unix): Accept dpyinfo. Use the coding system specified inside if possible. (xic_preedit_draw_callback): Pass dpyinfo. * src/xterm.c (handle_one_xevent): Use XIM coding system for IM input. (xim_open_dpy): Try to determine the input method coding system. (mark_xterm): Mark `xim_coding'. (syms_of_xterm): New variable `x-input-coding-system'. * src/xterm.h (struct x_display_info): New field `xim_coding'. (FRAME_X_XIM_CODING): New macro.
2022-09-27Optimize coordinate translation during event handlingPo Lu
These changes noticeably improve turning the mouse wheel on top of scroll bars etc over slow network connections. * src/xterm.c (x_dnd_note_self_position, x_dnd_note_self_wheel) (x_dnd_note_self_drop): Use x_translate_coordinates. (x_compute_root_window_offset): New function for calculating and caching root window offsets of edit window. (x_translate_coordinates): New function. Use cached values whenever possible. (xi_compute_root_window_offset) (xi_compute_root_window_offset_pinch): New wrappers for XI2 events. (x_construct_mouse_click, handle_one_xevent): Use x_translate_coordinates wherever appropriate. * src/xterm.h (struct x_output): New fields for keeping track of the root window offset of the edit window.
2022-09-24Reduce complexity of scroll bar window protection codePo Lu
It turns out my previous theories of why ClientMessages were generated were wrong, and they are just generated so we can set finish to X_EVENT_GOTO_OUT to have them delivered immediately. This allows for the code to be simplified greatly, by not unpacking pointers to the raw window into the client messages. * src/xterm.c (x_unprotect_window_for_callback): Return the window removed from the queue, or nil if none. (x_scroll_bar_to_input_event) (x_horizontal_scroll_bar_to_input_event): Use window provided by x_unprotect_window_for_callback. (handle_one_xevent): Pass dpyinfo to functions that need it. (x_free_frame_resources): Remove "first scroll bar request" code. * src/xterm.h (struct x_display_info): Likewise.
2022-09-23Fix more toolkit scroll bar window protection issuesPo Lu
* src/xterm.c (handle_one_xevent): Ignore outdated scroll bar events. (x_free_frame_resources): Clear protected windows and invalidate previous scroll bar events. * src/xterm.h (struct x_display_info): New field `first_valid_scroll_bar_req'.
2022-09-06Correctly handle frame synchronization on fullscreen KWinPo Lu
* src/xfns.c (x_set_use_frame_synchronization): Announce that we do not want the compositor to unredirect the frame while fullscreen. * src/xterm.c (x_atom_refs): New atom `_NET_WM_BYPASS_COMPOSITOR'. * src/xterm.h (struct x_display_info): Likewise.
2022-09-02Prevent crashes when embedding Emacs in a nonexistent parentPo Lu
* src/xfns.c (x_window, Fx_create_frame): Handle X errors while trying to reparent the frame onto an explicitly specified parent. * src/xterm.c (handle_one_xevent): Handle unparenting embedded windows correctly. This only works if the embedder is aware of the fixes extension and has put the window into the right save set. (x_embed_frame): New function. * src/xterm.h (FRAME_X_EMBEDDED_P): Fix coding style.
2022-08-26; * src/xterm.h (struct x_display_info): Update comment.Po Lu
2022-08-25Fix overflows in HAVE_XSYNC timestamp handlingPaul Eggert
Also, port to platforms lacking CLOCK_MONOTONIC and int64_t, and use 0 more consistently to represent missing timestamps. * src/xterm.h (struct x_display_info): Omit server_time_monotonic_p and server_time_offset if !HAVE_CLOCK_GETTIME since they are unused in that case. * src/xterm.h (struct x_display_info, struct x_output): * src/xterm.c (x_sync_get_monotonic_time) (x_sync_current_monotonic_time, x_sync_note_frame_times): Use int_fast64_t instead of int64_t as POSIX doesn't guarantee the latter. Similarly for uint_fast64_t. (x_sync_get_monotonic_time, x_sync_current_monotonic_time) (x_sync_note_frame_times, x_display_set_last_user_time): Check for integer overflow in time arithmetic. (CLOCK_MONOTONIC): Define to CLOCK_REALTIME if absent. (x_sync_current_monotonic_time): Check for clock_gettime failure and fall back on CLOCK_REALTIME if CLOCK_MONOTONIC does not work, which POSIX allows. (x_sync_current_monotonic_time, x_sync_note_frame_times) (x_display_set_last_user_time): Use 0 more consistently to represent missing timestamps.
2022-08-25Fix various problems with mouse highlight on XI2 buildsPo Lu
* src/dispextern.h (reset_mouse_highlight): Fix coding style. * src/xterm.c (xi_position_changed): New functions. (xi_report_motion_window_clear, handle_one_xevent): Don't report motion events if the pixel position did not actually change. * src/xterm.h (struct xi_device_t): New fields `last_motion_window', `last_motion_x' and `last_motion_y'.
2022-08-23Make frame synchronization conditional on clock_gettimePo Lu
* src/xfns.c (x_set_parent_frame) (x_set_use_frame_synchronization): * src/xterm.c (x_update_begin, show_back_buffer, x_update_end) (x_display_set_last_user_time, handle_one_xevent): * src/xterm.h (struct x_output): Define out vsync code when !HAVE_CLOCK_GETTIME. (bug#57346)