comparison src/xfns.c @ 109604:43eca6c9f493

Use Gtk+ tooltips by default for Gtk+ Emacs. * lisp/cus-start.el (x-gtk-use-system-tooltips): New variable. * src/gtkutil.c (hierarchy_ch_cb, qttip_cb, xg_prepare_tooltip) (xg_show_tooltip, xg_hide_tooltip, xg_free_frame_widgets): New functions. (xg_create_frame_widgets): Set ttip_* to 0. Set a dummy tooltip text so qttip_cb is called. Connect query-tooltip to qttip_cb. Remove code that is commented out. * src/gtkutil.h (xg_free_frame_widgets, xg_prepare_tooltip) (xg_show_tooltip, xg_hide_tooltip): Declare. * src/xfns.c (x_gtk_use_system_tooltips): New variable. (Fx_show_tip): If USE_GTK and x_gtk_use_system_tooltips, call new gtkutil tooltip functions to show the tooltip. (Fx_hide_tip): Call xg_hide_tooltip. (syms_of_xfns): Defvar x-gtk-use-system-tooltips. * src/xterm.c (x_clear_frame): Check FRAME_GTK_WIDGET (f) before calling gtk_widget_queue_draw. (x_free_frame_resources): Call xg_free_frame_widgets. * src/xterm.h (struct x_output): Add ttip_widget, ttip_window and ttip_lbl.
author Jan D <jan.h.d@swipnet.se>
date Sun, 01 Aug 2010 15:57:07 +0200
parents 09fcb3817c1e
children c4c8e4a16194
comparison
equal deleted inserted replaced
109603:d660473e004d 109604:43eca6c9f493
158 int x_gtk_file_dialog_help_text; 158 int x_gtk_file_dialog_help_text;
159 159
160 /* If non-zero, don't collapse to tool bar when it is detached. */ 160 /* If non-zero, don't collapse to tool bar when it is detached. */
161 161
162 int x_gtk_whole_detached_tool_bar; 162 int x_gtk_whole_detached_tool_bar;
163
164 /* If non-zero, use Gtk+ tooltips. */
165
166 static int x_gtk_use_system_tooltips;
163 167
164 /* The background and shape of the mouse pointer, and shape when not 168 /* The background and shape of the mouse pointer, and shape when not
165 over text or in the modeline. */ 169 over text or in the modeline. */
166 170
167 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; 171 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
4608 signal errors, for instance when a specified color name is 4612 signal errors, for instance when a specified color name is
4609 undefined. We have to make sure that we're in a consistent state 4613 undefined. We have to make sure that we're in a consistent state
4610 when this happens. */ 4614 when this happens. */
4611 4615
4612 static Lisp_Object 4616 static Lisp_Object
4613 x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms, Lisp_Object text) 4617 x_create_tip_frame (struct x_display_info *dpyinfo,
4618 Lisp_Object parms,
4619 Lisp_Object text)
4614 { 4620 {
4615 struct frame *f; 4621 struct frame *f;
4616 Lisp_Object frame, tem; 4622 Lisp_Object frame, tem;
4617 Lisp_Object name; 4623 Lisp_Object name;
4618 long window_prompting = 0; 4624 long window_prompting = 0;
5035 if (NILP (dy)) 5041 if (NILP (dy))
5036 dy = make_number (-10); 5042 dy = make_number (-10);
5037 else 5043 else
5038 CHECK_NUMBER (dy); 5044 CHECK_NUMBER (dy);
5039 5045
5046 #ifdef USE_GTK
5047 if (x_gtk_use_system_tooltips)
5048 {
5049 int ok;
5050
5051 /* Hide a previous tip, if any. */
5052 Fx_hide_tip ();
5053
5054 BLOCK_INPUT;
5055 if ((ok = xg_prepare_tooltip (f, string, &width, &height)) != 0)
5056 {
5057 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
5058 xg_show_tooltip (f, root_x, root_y);
5059 /* This is used in Fx_hide_tip. */
5060 XSETFRAME (tip_frame, f);
5061 }
5062 UNBLOCK_INPUT;
5063 if (ok) goto start_timer;
5064 }
5065 #endif /* USE_GTK */
5066
5040 if (NILP (last_show_tip_args)) 5067 if (NILP (last_show_tip_args))
5041 last_show_tip_args = Fmake_vector (make_number (3), Qnil); 5068 last_show_tip_args = Fmake_vector (make_number (3), Qnil);
5042 5069
5043 if (!NILP (tip_frame)) 5070 if (!NILP (tip_frame))
5044 { 5071 {
5195 (void) 5222 (void)
5196 { 5223 {
5197 int count; 5224 int count;
5198 Lisp_Object deleted, frame, timer; 5225 Lisp_Object deleted, frame, timer;
5199 struct gcpro gcpro1, gcpro2; 5226 struct gcpro gcpro1, gcpro2;
5227 struct frame *f;
5200 5228
5201 /* Return quickly if nothing to do. */ 5229 /* Return quickly if nothing to do. */
5202 if (NILP (tip_timer) && NILP (tip_frame)) 5230 if (NILP (tip_timer) && NILP (tip_frame))
5203 return Qnil; 5231 return Qnil;
5204 5232
5211 specbind (Qinhibit_redisplay, Qt); 5239 specbind (Qinhibit_redisplay, Qt);
5212 specbind (Qinhibit_quit, Qt); 5240 specbind (Qinhibit_quit, Qt);
5213 5241
5214 if (!NILP (timer)) 5242 if (!NILP (timer))
5215 call1 (Qcancel_timer, timer); 5243 call1 (Qcancel_timer, timer);
5244
5245 #ifdef USE_GTK
5246 /* When using system tooltip, tip_frame is the Emacs frame on which
5247 the tip is shown. */
5248 f = XFRAME (frame);
5249 if (xg_hide_tooltip (f))
5250 frame = Qnil;
5251 #endif
5216 5252
5217 if (FRAMEP (frame)) 5253 if (FRAMEP (frame))
5218 { 5254 {
5219 delete_frame (frame, Qnil); 5255 delete_frame (frame, Qnil);
5220 deleted = Qt; 5256 deleted = Qt;
5222 #ifdef USE_LUCID 5258 #ifdef USE_LUCID
5223 /* Bloodcurdling hack alert: The Lucid menu bar widget's 5259 /* Bloodcurdling hack alert: The Lucid menu bar widget's
5224 redisplay procedure is not called when a tip frame over menu 5260 redisplay procedure is not called when a tip frame over menu
5225 items is unmapped. Redisplay the menu manually... */ 5261 items is unmapped. Redisplay the menu manually... */
5226 { 5262 {
5227 struct frame *f = SELECTED_FRAME (); 5263 Widget w;
5228 Widget w = f->output_data.x->menubar_widget; 5264 f = SELECTED_FRAME ();
5265 w = f->output_data.x->menubar_widget;
5229 5266
5230 if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen) 5267 if (!DoesSaveUnders (FRAME_X_DISPLAY_INFO (f)->screen)
5231 && w != NULL) 5268 && w != NULL)
5232 { 5269 {
5233 BLOCK_INPUT; 5270 BLOCK_INPUT;
5892 doc: /* *If non-nil, a detached tool bar is shown in full. 5929 doc: /* *If non-nil, a detached tool bar is shown in full.
5893 The default is to just show an arrow and pressing on that arrow shows 5930 The default is to just show an arrow and pressing on that arrow shows
5894 the tool bar buttons. */); 5931 the tool bar buttons. */);
5895 x_gtk_whole_detached_tool_bar = 0; 5932 x_gtk_whole_detached_tool_bar = 0;
5896 5933
5934 DEFVAR_BOOL ("x-gtk-use-system-tooltips", &x_gtk_use_system_tooltips,
5935 doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used.
5936 Otherwise use Emacs own tooltip implementation.
5937 When using Gtk+ tooltips, the tooltip face is not used. */);
5938 x_gtk_use_system_tooltips = 1;
5939
5897 Fprovide (intern_c_string ("x"), Qnil); 5940 Fprovide (intern_c_string ("x"), Qnil);
5898 5941
5899 #ifdef USE_X_TOOLKIT 5942 #ifdef USE_X_TOOLKIT
5900 Fprovide (intern_c_string ("x-toolkit"), Qnil); 5943 Fprovide (intern_c_string ("x-toolkit"), Qnil);
5901 #ifdef USE_MOTIF 5944 #ifdef USE_MOTIF