From 95084cec09190d7263ce61d30387c08e7d365ad3 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 19 Jan 2022 13:12:18 +0800 Subject: [PATCH] Rename system tooltip variables to `use-system-tooltips' * doc/emacs/frames.texi (Tooltips): * doc/emacs/haiku.texi (Haiku Basics): * doc/lispref/display.texi (Tooltips): Document `use-system-tooltips' instead. * etc/NEWS: Announce new option. * lisp/cus-start.el (standard): Add new option. * lisp/term/haiku-win.el (haiku-use-system-tooltips): * lisp/term/pgtk-win.el (x-gtk-use-system-tooltips): * lisp/term/x-win.el (x-gtk-use-system-tooltips): Add aliases for old options. * src/frame.c (syms_of_frame): New variable `use-system-tooltips'. * src/haikufns.c (Fx_show_tip): (syms_of_haikufns): * src/pgtkfns.c (x_hide_tip): (Fx_show_tip): (syms_of_pgtkfns): * src/xfns.c (x_hide_tip): (Fx_show_tip): (syms_of_xfns): Use `use-system-tooltips' instead of the old platform dependent options. --- doc/emacs/frames.texi | 15 ++++++++------- doc/emacs/haiku.texi | 10 +++++----- doc/lispref/display.texi | 15 ++++++++------- etc/NEWS | 5 +++++ lisp/cus-start.el | 1 + lisp/term/haiku-win.el | 2 ++ lisp/term/pgtk-win.el | 2 ++ lisp/term/x-win.el | 2 ++ src/frame.c | 8 ++++++++ src/haikufns.c | 10 +--------- src/pgtkfns.c | 14 ++++---------- src/xfns.c | 24 +++++++++--------------- 12 files changed, 55 insertions(+), 53 deletions(-) diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index c641b8ccb14..29edbe98633 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi @@ -1633,13 +1633,14 @@ Parameters,,, elisp, The Emacs Lisp Reference Manual}, and also For additional customization options for displaying tooltips, use @kbd{M-x customize-group @key{RET} tooltip @key{RET}}. -@vindex x-gtk-use-system-tooltips - If Emacs is built with GTK+ support, it displays tooltips via GTK+, -using the default appearance of GTK+ tooltips. To disable this, -change the variable @code{x-gtk-use-system-tooltips} to @code{nil}. -If you do this, or if Emacs is built without GTK+ support, most -attributes of the tooltip text are specified by the @code{tooltip} -face, and by X resources (@pxref{X Resources}). +@vindex use-system-tooltips + If Emacs is built with the GTK+ toolkit or Haiku windowing support, +it displays tooltips via the toolkit, using the default appearance of +the toolkit's tooltips. To disable this, change the variable +@code{use-system-tooltips} to @code{nil}. If you do this, or if Emacs +is built without GTK+ or Haiku windowing support, most attributes of +the tooltip text are specified by the @code{tooltip} face, and by X +resources (@pxref{X Resources}). @dfn{GUD tooltips} are special tooltips that show the values of variables when debugging a program with GUD@. @xref{Debugger diff --git a/doc/emacs/haiku.texi b/doc/emacs/haiku.texi index 6e38660fdb3..0d3ed8339e7 100644 --- a/doc/emacs/haiku.texi +++ b/doc/emacs/haiku.texi @@ -85,15 +85,15 @@ instead. @cindex tooltips (haiku) @cindex haiku tooltips -@vindex haiku-use-system-tooltips On Haiku, Emacs defaults to using the system tooltip mechanism. This usually leads to more responsive tooltips, but the tooltips will not be able to display text properties or faces. If you need those -features, customize the variable @code{haiku-use-system-tooltips} to -the nil value, and Emacs will use its own implementation of tooltips. +features, customize the variable @code{use-system-tooltips} to the +@code{nil} value, and Emacs will use its own implementation of +tooltips. - System tooltips cannot display above the menu bar, so help text -in the menu bar will display in the echo area instead when they are + System tooltips cannot display above the menu bar, so help text in +the menu bar will display in the echo area instead when they are enabled. @cindex X resources on Haiku diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 12e19efab0e..9020b98a1eb 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -8438,13 +8438,14 @@ displayed in the echo area. @end defun @cindex system tooltips -@vindex x-gtk-use-system-tooltips -When Emacs is built with GTK+ support, it by default displays tooltips -using GTK+ functions, and the appearance of the tooltips is then -controlled by GTK+ settings. GTK+ tooltips can be disabled by -changing the value of the variable @code{x-gtk-use-system-tooltips} to -@code{nil}. The rest of this subsection describes how to control -non-GTK+ tooltips, which are presented by Emacs itself. +@vindex use-system-tooltips +When Emacs is built with the GTK+ toolkit or Haiku windowing support, +it by default displays tooltips using toolkit functions, and the +appearance of the tooltips is then controlled by by the toolkit's +settings. Toolkit-provided tooltips can be disabled by changing the +value of the variable @code{use-system-tooltips} to @code{nil}. The +rest of this subsection describes how to control non-toolkit tooltips, +which are presented by Emacs itself. @cindex tooltip frames Tooltips are displayed in special frames called tooltip frames, which diff --git a/etc/NEWS b/etc/NEWS index afb7c1fbd3c..41de3b4b687 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -154,6 +154,11 @@ methods. This controls whether or not GTK input methods are used by Emacs, instead of XIM input methods. ++++ +** New user option 'use-system-tooltips'. +This controls whether or not to use the toolkit Emacs was built with +to display tooltips, if supported. + --- ** New minor mode 'pixel-scroll-precision-mode'. When enabled, and if your mouse supports it, you can scroll the diff --git a/lisp/cus-start.el b/lisp/cus-start.el index cdadf08a894..7f639240f51 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -356,6 +356,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (const :tag "Iconify" t)) "26.1") (tooltip-reuse-hidden-frame tooltip boolean "26.1") + (use-system-tooltips tooltip boolean "29.1") ;; fringe.c (overflow-newline-into-fringe fringe boolean) ;; image.c diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el index ff9402c4acb..739ea9fdfce 100644 --- a/lisp/term/haiku-win.el +++ b/lisp/term/haiku-win.el @@ -136,6 +136,8 @@ If TYPE is nil, return \"text/plain\"." (define-key special-event-map [drag-n-drop] 'haiku-dnd-handle-drag-n-drop-event) +(defvaralias 'haiku-use-system-tooltips 'use-system-tooltips) + (provide 'haiku-win) (provide 'term/haiku-win) diff --git a/lisp/term/pgtk-win.el b/lisp/term/pgtk-win.el index 9bcf3eac646..25f3a851dcc 100644 --- a/lisp/term/pgtk-win.el +++ b/lisp/term/pgtk-win.el @@ -510,6 +510,8 @@ This uses `icon-map-list' to map icon file names to stock icon names." (t (popup-menu (mouse-menu-bar-map) last-nonmenu-event)))) +(defvaralias 'x-gtk-use-system-tooltips 'use-system-tooltips) + (provide 'pgtk-win) (provide 'term/pgtk-win) diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index cd63c9208ba..019a01e22ca 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el @@ -1561,6 +1561,8 @@ EVENT is a preedit-text event." (define-key special-event-map [preedit-text] 'x-preedit-text) +(defvaralias 'x-gtk-use-system-tooltips 'use-system-tooltips) + (provide 'x-win) (provide 'term/x-win) diff --git a/src/frame.c b/src/frame.c index e5d74edc168..8aaff949ba2 100644 --- a/src/frame.c +++ b/src/frame.c @@ -6472,6 +6472,14 @@ This variable is effective only with the X toolkit (and there only when Gtk+ tooltips are not used) and on Windows. */); tooltip_reuse_hidden_frame = false; + DEFVAR_BOOL ("use-system-tooltips", use_system_tooltips, + doc: /* Use the toolkit to display tooltips. +This option is only meaningful when Emacs is built with GTK+ or Haiku +windowing support, and results in tooltips that look like those +displayed by other GTK+ or Haiku programs, but will not be able to +display text properties inside tooltip text. */); + use_system_tooltips = true; + DEFVAR_LISP ("iconify-child-frame", iconify_child_frame, doc: /* How to handle iconification of child frames. This variable tells Emacs how to proceed when it is asked to iconify a diff --git a/src/haikufns.c b/src/haikufns.c index 5b55efea32e..d0436bbb96d 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -1946,7 +1946,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, else CHECK_FIXNUM (dy); - if (haiku_use_system_tooltips) + if (use_system_tooltips) { int root_x, root_y; CHECK_STRING (string); @@ -2672,14 +2672,6 @@ syms_of_haikufns (void) doc: /* SKIP: real doc in xfns.c. */); Vx_max_tooltip_size = Fcons (make_fixnum (80), make_fixnum (40)); - DEFVAR_BOOL ("haiku-use-system-tooltips", haiku_use_system_tooltips, - doc: /* When non-nil, Emacs will display tooltips using the App Kit. -This can avoid a great deal of consing that does not play -well with the Haiku memory allocator, but comes with the -disadvantage of not being able to use special display properties -within tooltips. */); - haiku_use_system_tooltips = 1; - #ifdef USE_BE_CAIRO DEFVAR_LISP ("cairo-version-string", Vcairo_version_string, doc: /* Version info for cairo. */); diff --git a/src/pgtkfns.c b/src/pgtkfns.c index c604e2f1002..9c37c04810c 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -3128,7 +3128,7 @@ x_hide_tip (bool delete) value of x_gtk_use_system_tooltips might not be the same as used for the tooltip we have to hide, see Bug#30399. */ if ((NILP (tip_last_frame) && NILP (tip_frame)) - || (!x_gtk_use_system_tooltips + || (!use_system_tooltips && !delete && FRAMEP (tip_frame) && FRAME_LIVE_P (XFRAME (tip_frame)) @@ -3161,7 +3161,7 @@ x_hide_tip (bool delete) /* When using GTK+ system tooltips (compare Bug#41200) reset tip_last_frame. It will be reassigned when showing the next GTK+ system tooltip. */ - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) tip_last_frame = Qnil; /* Now look whether there's an Emacs tip around. */ @@ -3171,7 +3171,7 @@ x_hide_tip (bool delete) if (FRAME_LIVE_P (f)) { - if (delete || x_gtk_use_system_tooltips) + if (delete || use_system_tooltips) { /* Delete the Emacs tooltip frame when DELETE is true or we change the tooltip type from an Emacs one to @@ -3267,7 +3267,7 @@ Text larger than the specified size is clipped. */) else CHECK_FIXNUM (dy); - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) { bool ok; @@ -4068,12 +4068,6 @@ If more space for files in the file chooser dialog is wanted, set this to nil to turn the additional text off. */); x_gtk_file_dialog_help_text = true; - DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips, - doc: /* If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used. -Otherwise use Emacs own tooltip implementation. -When using Gtk+ tooltips, the tooltip face is not used. */); - x_gtk_use_system_tooltips = true; - DEFVAR_LISP ("x-max-tooltip-size", Vx_max_tooltip_size, doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */); diff --git a/src/xfns.c b/src/xfns.c index d73e951754b..5f0e91332b6 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -7357,13 +7357,13 @@ x_hide_tip (bool delete) } #ifdef USE_GTK - /* Any GTK+ system tooltip can be found via the x_output structure of - tip_last_frame, provided that frame is still live. Any Emacs - tooltip is found via the tip_frame variable. Note that the current - value of x_gtk_use_system_tooltips might not be the same as used - for the tooltip we have to hide, see Bug#30399. */ + /* Any GTK+ system tooltip can be found via the x_output structure + of tip_last_frame, provided that frame is still live. Any Emacs + tooltip is found via the tip_frame variable. Note that the + current value of use_system_tooltips might not be the same as + used for the tooltip we have to hide, see Bug#30399. */ if ((NILP (tip_last_frame) && NILP (tip_frame)) - || (!x_gtk_use_system_tooltips + || (!use_system_tooltips && !delete && !NILP (tip_frame) && FRAME_LIVE_P (XFRAME (tip_frame)) @@ -7396,7 +7396,7 @@ x_hide_tip (bool delete) /* When using GTK+ system tooltips (compare Bug#41200) reset tip_last_frame. It will be reassigned when showing the next GTK+ system tooltip. */ - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) tip_last_frame = Qnil; /* Now look whether there's an Emacs tip around. */ @@ -7406,7 +7406,7 @@ x_hide_tip (bool delete) if (FRAME_LIVE_P (f)) { - if (delete || x_gtk_use_system_tooltips) + if (delete || use_system_tooltips) { /* Delete the Emacs tooltip frame when DELETE is true or we change the tooltip type from an Emacs one to @@ -7565,7 +7565,7 @@ Text larger than the specified size is clipped. */) CHECK_FIXNUM (dy); #ifdef USE_GTK - if (x_gtk_use_system_tooltips) + if (use_system_tooltips) { bool ok; @@ -8647,12 +8647,6 @@ If more space for files in the file chooser dialog is wanted, set this to nil to turn the additional text off. */); x_gtk_file_dialog_help_text = true; - DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips, - doc: /* If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used. -Otherwise use Emacs own tooltip implementation. -When using Gtk+ tooltips, the tooltip face is not used. */); - x_gtk_use_system_tooltips = true; - DEFVAR_LISP ("x-gtk-resize-child-frames", x_gtk_resize_child_frames, doc: /* If non-nil, resize child frames specially with GTK builds. If this is nil, resize child frames like any other frames. This is the -- 2.39.2