Commit 20038f8a authored by Dmitry Antipov's avatar Dmitry Antipov

Cleanup tooltips

* src/dispextern.h (toplevel): Remove 'tip_frame' and 'tip_window' decls.
* src/frame.h (struct frame): New bitfield to indicate tooltip frame.
(FRAME_TOOLTIP_P): New macro.
* src/frame.c (make_frame): Mark new frame as regular frame by default.
(Fframe_list, delete_frame): Redesign to use FRAME_TOOLTIP_P.
(syms_of_frame): Don't DEFSYM 'Qtooltip' but use 'Qtooltip_timer'
and 'Qtooltip_parameters' instead.
* src/gtkutil.h (toplevel): Add 'xg_hide_tip' decl.
* src/gtkutil.c (xg_hide_tip): New function.
(xg_hide_tooltip): Adjust to cancel GTK event loop timeout if needed.
* src/menu.c (Fx_popup_menu): Adjust call to Fx_hide_tip.
* src/nsfns.c (toplevel): Remove 'tip_frame' leftover.
* src/w32fns.c (unwind_create_tip_frame): Remove.
(w32_display_monitor_attributes_list)
(w32_display_monitor_attributes_list_fallback): Use FRAME_TOOLTIP_P.
(toplevel): Remove 'tip_frame', 'tip_window' and 'last_show_tip_args'.
(x_create_tip_frame): Use do_unwind_create_frame.  Mark new frame
as a tooltip frame and record it using appropriate display info.
(x_hide_tooltip): Add frame arg.
(Fx_show_tip): Adjust to avoid globals, store tooltip parameters among
base frame parameters, store tooltip hide timer among tooltip frame
parameters.
(Fx_hide_tip): Add frame arg, hide tooltips on all displays by default.
(syms_of_w32fns): Don't DEFSYM 'Qtip_frame', don't initialize
and GC-protect 'tip_timer', 'tip_frame' and 'last_show_tip_args'.
* src/w32term.c (w32_read_socket): Extract tooltip window id from
per-display data.  Use FRAME_TOOLTIP_P where appropriate.
(x_new_font): Use FRAME_TOOLTIP_P.
(x_free_frame_resources): Reset pointer to tooltip frame.
* src/w32term.h (struct w32_display_info): New member 'w32_tooltip_frame'.
* src/xdisp.c (init_iterator, x_consider_frame_title, prepare_menu_bars):
Use FRAME_TOOLTIP_P.
* src/xfns.c (x_make_monitor_attribute_list)
(Fx_display_monitor_attributes_list): Likewise.
(unwind_create_tip_frame): Remove.
(toplevel): Remove 'tip_frame', 'tip_window' and 'last_show_tip_args'.
(x_create_tip_frame): Use do_unwind_create_frame.  Mark new frame
as a tooltip frame and record it using appropriate display info.
(x_hide_tooltip): Add frame arg.
(Fx_show_tip): Adjust to avoid globals, store tooltip parameters among
base frame parameters, store tooltip hide timer among tooltip frame
parameters.  To hide GTK system tooltip, use timeout hooked into GTK
event loop.
(Fx_hide_tip): Add frame arg, hide tooltips on all displays by default.
(syms_of_xfns): Don't DEFSYM 'Qtip_frame', don't initialize
and GC-protect 'tip_timer', 'tip_frame' and 'last_show_tip_args'.
* src/xterm.c (handle_one_xevent): Extract tooltip window id from
per-display data.  Use FRAME_TOOLTIP_P where appropriate.
(x_new_font, x_set_window_size): Use FRAME_TOOLTIP_P.
(x_free_frame_resources): Reset pointer to tooltip frame.
* src/xterm.h (struct x_display_info): New member 'x_tooltip_frame'.
(struct x_output) [USE_GTK_TOOLTIP]: New member 'ttip_timeout'.
parent 8ea59925
......@@ -3461,8 +3461,6 @@ void gamma_correct (struct frame *, COLORREF *);
void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
void x_change_tool_bar_height (struct frame *f, int);
extern Lisp_Object tip_frame;
extern Window tip_window;
extern frame_parm_handler x_frame_parm_handlers[];
extern void start_hourglass (void);
......
......@@ -642,6 +642,7 @@ make_frame (bool mini_p)
f->vertical_scroll_bar_type = vertical_scroll_bar_none;
f->horizontal_scroll_bars = false;
f->want_fullscreen = FULLSCREEN_NONE;
f->tooltip = false;
#if ! defined (USE_GTK) && ! defined (HAVE_NS)
f->last_tool_bar_item = -1;
#endif
......@@ -1260,13 +1261,16 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
doc: /* Return a list of all live frames. */)
(void)
{
Lisp_Object frames;
frames = Fcopy_sequence (Vframe_list);
#ifdef HAVE_WINDOW_SYSTEM
if (FRAMEP (tip_frame))
frames = Fdelq (tip_frame, frames);
Lisp_Object list = Qnil, tail, frame;
FOR_EACH_FRAME (tail, frame)
if (!FRAME_TOOLTIP_P (XFRAME (frame)))
list = Fcons (frame, list);
return list;
#else /* !HAVE_WINDOW_SYSTEM */
return Fcopy_sequence (Vframe_list);
#endif
return frames;
}
/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
......@@ -1557,7 +1561,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
}
}
is_tooltip_frame = !NILP (Fframe_parameter (frame, Qtooltip));
is_tooltip_frame = FRAME_TOOLTIP_P (f);
/* Run `delete-frame-functions' unless FORCE is `noelisp' or
frame is a tooltip. FORCE is set to `noelisp' when handling
......@@ -4900,7 +4904,6 @@ syms_of_frame (void)
DEFSYM (Qgeometry, "geometry");
DEFSYM (Qicon_left, "icon-left");
DEFSYM (Qicon_top, "icon-top");
DEFSYM (Qtooltip, "tooltip");
DEFSYM (Quser_position, "user-position");
DEFSYM (Quser_size, "user-size");
DEFSYM (Qwindow_id, "window-id");
......@@ -5022,6 +5025,8 @@ syms_of_frame (void)
DEFSYM (Qvertical_scroll_bars, "vertical-scroll-bars");
DEFSYM (Qvisibility, "visibility");
DEFSYM (Qwait_for_wm, "wait-for-wm");
DEFSYM (Qtooltip_timer, "tooltip-timer");
DEFSYM (Qtooltip_parameters, "tooltip-parameters");
{
int i;
......
......@@ -309,6 +309,9 @@ struct frame
ENUM_BF (output_method) output_method : 3;
#ifdef HAVE_WINDOW_SYSTEM
/* True if this frame is a tooltip frame. */
bool_bf tooltip : 1;
/* See FULLSCREEN_ enum on top. */
ENUM_BF (fullscreen_type) want_fullscreen : 4;
......@@ -861,6 +864,9 @@ default_pixels_per_inch_y (void)
#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
/* Whether F is a tooltip frame. */
#define FRAME_TOOLTIP_P(f) ((f)->tooltip)
#else /* not HAVE_WINDOW_SYSTEM */
/* If there is no window system, there are no scroll bars. */
......@@ -869,6 +875,9 @@ default_pixels_per_inch_y (void)
#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
#define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
/* If there is no window system, there are no tooltips. */
#define FRAME_TOOLTIP_P(f) ((void) f, 0)
#endif /* HAVE_WINDOW_SYSTEM */
/* Whether horizontal scroll bars are currently enabled for frame F. */
......
......@@ -731,14 +731,23 @@ xg_show_tooltip (struct frame *f, int root_x, int root_y)
bool
xg_hide_tooltip (struct frame *f)
{
bool ret = 0;
#ifdef USE_GTK_TOOLTIP
if (f->output_data.x->ttip_window)
struct x_output *x = FRAME_X_OUTPUT (f);
if (x->ttip_window)
{
GtkWindow *win = f->output_data.x->ttip_window;
block_input ();
gtk_widget_hide (GTK_WIDGET (win));
/* Cancel call to xg_hide_tip. */
if (x->ttip_timeout != 0)
{
g_source_remove (x->ttip_timeout);
x->ttip_timeout = 0;
}
if (g_object_get_data (G_OBJECT (win), "restore-tt"))
{
GdkWindow *gwin = gtk_widget_get_window (GTK_WIDGET (win));
......@@ -747,11 +756,21 @@ xg_hide_tooltip (struct frame *f)
g_object_set (settings, "gtk-enable-tooltips", TRUE, NULL);
}
unblock_input ();
ret = 1;
return 1;
}
#endif
return ret;
return 0;
}
/* One-shot timeout handler attached to GTK event loop in Fx_show_tip. */
gboolean
xg_hide_tip (gpointer data)
{
#ifdef USE_GTK_TOOLTIP
xg_hide_tooltip ((struct frame *) data);
#endif
return FALSE;
}
......
......@@ -178,6 +178,7 @@ extern bool xg_prepare_tooltip (struct frame *f,
int *height);
extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
extern bool xg_hide_tooltip (struct frame *f);
extern gboolean xg_hide_tip (gpointer data);
#ifdef USE_CAIRO
extern void xg_page_setup_dialog (void);
......
......@@ -1400,7 +1400,12 @@ no quit occurs and `x-popup-menu' returns nil. */)
#ifdef HAVE_WINDOW_SYSTEM
/* Hide a previous tip, if any. */
if (!FRAME_TERMCAP_P (f))
Fx_hide_tip ();
{
Lisp_Object frame;
XSETFRAME (frame, f);
Fx_hide_tip (frame);
}
#endif
#ifdef HAVE_NTGUI /* FIXME: Is it really w32-specific? --Stef */
......
......@@ -2658,10 +2658,6 @@ and GNUstep implementations ("distributor-specific release
return make_number (1 << min (dpyinfo->n_planes, 24));
}
/* Unused dummy def needed for compatibility. */
Lisp_Object tip_frame;
/* TODO: move to xdisp or similar */
static void
compute_tip_xy (struct frame *f,
......
This diff is collapsed.
......@@ -5024,11 +5024,10 @@ w32_read_socket (struct terminal *terminal,
/* wParam non-zero means Window is about to be shown, 0 means
about to be hidden. */
/* Redo the mouse-highlight after the tooltip has gone. */
if (!msg.msg.wParam && msg.msg.hwnd == tip_window)
{
tip_window = NULL;
x_redo_mouse_highlight (dpyinfo);
}
if (!msg.msg.wParam
&& dpyinfo->w32_tooltip_frame
&& FRAME_W32_WINDOW (dpyinfo->w32_tooltip_frame) == msg.msg.hwnd)
x_redo_mouse_highlight (dpyinfo);
/* If window has been obscured or exposed by another window
being maximized or minimized/restored, then recheck
......@@ -5394,7 +5393,7 @@ w32_read_socket (struct terminal *terminal,
struct frame *f = XFRAME (frame);
/* The tooltip has been drawn already. Avoid the
SET_FRAME_GARBAGED below. */
if (EQ (frame, tip_frame))
if (FRAME_TOOLTIP_P (f))
continue;
/* Check "visible" frames and mark each as obscured or not.
......@@ -5871,7 +5870,7 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
/* Don't change the size of a tip frame; there's no point in
doing it because it's done in Fx_show_tip, and it leads to
problems because the tip frame has no widget. */
if (NILP (tip_frame) || XFRAME (tip_frame) != f)
if (!FRAME_TOOLTIP_P (f))
adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
false, Qfont);
......@@ -6569,6 +6568,8 @@ x_free_frame_resources (struct frame *f)
dpyinfo->w32_focus_event_frame = 0;
if (f == dpyinfo->x_highlight_frame)
dpyinfo->x_highlight_frame = 0;
if (f == dpyinfo->w32_tooltip_frame)
dpyinfo->w32_tooltip_frame = 0;
if (f == hlinfo->mouse_face_mouse_frame)
reset_mouse_highlight (hlinfo);
......
......@@ -186,6 +186,9 @@ struct w32_display_info
/* The frame waiting to be auto-raised in w32_read_socket. */
struct frame *w32_pending_autoraise_frame;
/* Tooltip frame on this display. */
struct frame *w32_tooltip_frame;
/* The frame where the mouse was last time we reported a mouse event. */
struct frame *last_mouse_frame;
......
......@@ -2841,11 +2841,7 @@ init_iterator (struct it *it, struct window *w,
frames when the fringes are turned off. But leave the dimensions
zero for tooltip frames, as these glyphs look ugly there and also
sabotage calculations of tooltip dimensions in x-show-tip. */
#ifdef HAVE_WINDOW_SYSTEM
if (!(FRAME_WINDOW_P (it->f)
&& FRAMEP (tip_frame)
&& it->f == XFRAME (tip_frame)))
#endif
if (!FRAME_TOOLTIP_P (it->f))
{
if (it->line_wrap == TRUNCATE)
{
......@@ -11713,7 +11709,7 @@ x_consider_frame_title (Lisp_Object frame)
if ((FRAME_WINDOW_P (f)
|| FRAME_MINIBUF_ONLY_P (f)
|| f->explicit_name)
&& NILP (Fframe_parameter (frame, Qtooltip)))
&& !FRAME_TOOLTIP_P (f))
{
/* Do we have more than one visible frame on this X display? */
Lisp_Object tail, other_frame, fmt;
......@@ -11730,7 +11726,7 @@ x_consider_frame_title (Lisp_Object frame)
if (tf != f
&& FRAME_KBOARD (tf) == FRAME_KBOARD (f)
&& !FRAME_MINIBUF_ONLY_P (tf)
&& !EQ (other_frame, tip_frame)
&& !FRAME_TOOLTIP_P (tf)
&& (FRAME_VISIBLE_P (tf) || FRAME_ICONIFIED_P (tf)))
break;
}
......@@ -11793,13 +11789,6 @@ prepare_menu_bars (void)
{
bool all_windows = windows_or_buffers_changed || update_mode_lines;
bool some_windows = REDISPLAY_SOME_P ();
Lisp_Object tooltip_frame;
#ifdef HAVE_WINDOW_SYSTEM
tooltip_frame = tip_frame;
#else
tooltip_frame = Qnil;
#endif
if (FUNCTIONP (Vpre_redisplay_function))
{
......@@ -11840,7 +11829,7 @@ prepare_menu_bars (void)
&& !XBUFFER (w->contents)->text->redisplay)
continue;
if (!EQ (frame, tooltip_frame)
if (!FRAME_TOOLTIP_P (f)
&& (FRAME_ICONIFIED_P (f)
|| FRAME_VISIBLE_P (f) == 1
/* Exclude TTY frames that are obscured because they
......@@ -11877,7 +11866,7 @@ prepare_menu_bars (void)
struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
/* Ignore tooltip frame. */
if (EQ (frame, tooltip_frame))
if (FRAME_TOOLTIP_P (f))
continue;
if (some_windows
......
This diff is collapsed.
......@@ -987,8 +987,7 @@ static void
x_update_begin (struct frame *f)
{
#ifdef USE_CAIRO
if (! NILP (tip_frame) && XFRAME (tip_frame) == f
&& ! FRAME_VISIBLE_P (f))
if (FRAME_TOOLTIP_P (f) && ! FRAME_VISIBLE_P (f))
return;
if (! FRAME_CR_SURFACE (f))
......@@ -7839,11 +7838,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
case UnmapNotify:
/* Redo the mouse-highlight after the tooltip has gone. */
if (event->xunmap.window == tip_window)
{
tip_window = 0;
x_redo_mouse_highlight (dpyinfo);
}
if (dpyinfo->x_tooltip_frame
&& FRAME_X_WINDOW (dpyinfo->x_tooltip_frame) == event->xunmap.window)
x_redo_mouse_highlight (dpyinfo);
f = x_top_window_to_frame (dpyinfo, event->xunmap.window);
if (f) /* F may no longer exist if
......@@ -8433,7 +8430,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
#ifdef USE_X_TOOLKIT
/* Tip frames are pure X window, set size for them. */
if (! NILP (tip_frame) && XFRAME (tip_frame) == f)
if (FRAME_TOOLTIP_P (f))
{
if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height
|| FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width)
......@@ -9614,7 +9611,7 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
/* Don't change the size of a tip frame; there's no point in
doing it because it's done in Fx_show_tip, and it leads to
problems because the tip frame has no widget. */
if (NILP (tip_frame) || XFRAME (tip_frame) != f)
if (!FRAME_TOOLTIP_P (f))
{
adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
......@@ -10689,7 +10686,7 @@ x_set_window_size (struct frame *f, bool change_gravity,
/* The following breaks our calculations. If it's really needed,
think of something else. */
#if false
if (NILP (tip_frame) || XFRAME (tip_frame) != f)
if (!FRAME_TOOLTIP_P (f))
{
int text_width, text_height;
......@@ -11340,6 +11337,8 @@ x_free_frame_resources (struct frame *f)
dpyinfo->x_focus_event_frame = 0;
if (f == dpyinfo->x_highlight_frame)
dpyinfo->x_highlight_frame = 0;
if (f == dpyinfo->x_tooltip_frame)
dpyinfo->x_tooltip_frame = 0;
if (f == hlinfo->mouse_face_mouse_frame)
reset_mouse_highlight (hlinfo);
......
......@@ -362,6 +362,9 @@ struct x_display_info
/* The frame waiting to be auto-raised in XTread_socket. */
struct frame *x_pending_autoraise_frame;
/* Tooltip frame on this display. */
struct frame *x_tooltip_frame;
/* The frame where the mouse was last time we reported a ButtonPress event. */
struct frame *last_mouse_frame;
......@@ -575,6 +578,7 @@ struct x_output
GtkTooltip *ttip_widget;
GtkWidget *ttip_lbl;
GtkWindow *ttip_window;
guint ttip_timeout;
#endif /* USE_GTK_TOOLTIP */
#endif /* USE_GTK */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment