1 xtk_tooltip
liquibyte edited this page 2026-11-19 16:23:20 -06:00

xtk_tooltip.h

A small window of help text that shows beside a widget, plain or rich.

A tooltip is a borderless window that shows a short text next to the thing the pointer is over, usually after a short delay. One XtkTooltip is usually enough for a whole program: it is moved to each new place and shows one text at a time.

It shows either plain text (up to 1023 bytes, one line per \n, with an optional icon before it) or rich content: an XtkTooltipContent that the program builds from sections of colored runs of text, laid out the way an editor shows documentation for a symbol (a declaration in a code font, a rule, wrapped prose, labeled rows, a dimmed footer). In popup mode (xtk_tooltip_set_popup()) rich content becomes a popup the pointer can go into: it scrolls, its links can be clicked, and its corner can be dragged to another size.

Placing. Every show call takes the rectangle of the thing the tooltip is about, in screen (root window) coordinates. The tooltip goes below it, centered, if it fits on the screen there; otherwise above, then to the right, then to the left; if none fits, below, moved to stay on the screen. It keeps 6 pixels from the rectangle, or none when the theme gives it an arrow.

Making one. xtk_tooltip_create() makes the window on the root window (override-redirect, so the window manager does not decorate it) and gives it the "dark" preset. Give it the program's theme with xtk_tooltip_set_theme(&config.tooltip) or a preset with xtk_tooltip_set_preset(). Free it with xtk_tooltip_destroy().

Timing and events. The tooltip has no timer of its own:

Theme keys. [tooltip] (TooltipBlock, config.tooltip; the defaults are those of the "dark" preset):

  • background: the fill (default #252526). It can be a gradient.
  • color: the text (default DCDCDC).
  • border: the border (default #505050).
  • border-width: the border width in pixels (default 1).
  • border-radius: the corner radius in pixels (default 5).
  • padding: the space inside the border in pixels (default 6).
  • font-family (or font): the font (default "Sans").
  • font-size: the font size in pixels (default 12), as in the other widgets.
  • delay-ms: how long xtk_tooltip_schedule() waits, in milliseconds (default 400).

TooltipBlock also has arrow_size, the size of a pointer that makes the tooltip a speech bubble pointing at its target. It has no key in the config file; it is 0 (no pointer) unless a program sets it.

Example.

XtkConfig config;
xtk_config_init_defaults(&config);
XtkTheme *theme = xtk_theme_new();
if (theme && xtk_theme_builtin("Dark", theme)) xtk_theme_apply(&config, theme);
xtk_theme_free(theme);

XtkTooltip *tooltip = xtk_tooltip_create(display, screen);
xtk_tooltip_set_theme(tooltip, &config.tooltip);

XEvent event;
for (;;) {
    while (XPending(display)) {
        XNextEvent(display, &event);
        xtk_tooltip_handle_event(tooltip, &event);
        if (event.type == EnterNotify && event.xcrossing.window == button_window) {
            int x, y; Window child;
            XTranslateCoordinates(display, button_window, DefaultRootWindow(display), 0, 0, &x, &y, &child);
            xtk_tooltip_schedule(tooltip, "Save the file", x, y, 80, 24);
        } else if (event.type == LeaveNotify && event.xcrossing.window == button_window) {
            xtk_tooltip_hide(tooltip);
        }
    }
    xtk_tooltip_update(tooltip);
    usleep(20000);
}
 * 

Limitations.

  • Plain text is cut at 1023 bytes and 32 lines. It wraps only where a line is wider than the screen: at its last space that fits, or between two characters.
  • Rich content holds at most 32 KB of text, 2048 runs and 96 sections; what is added past that is left out. Outside popup mode, content taller than two thirds of the screen is cut, and "…" shows where.
  • The icon of xtk_tooltip_set_icon() is drawn with plain text only.
#include "xtk_tooltip.h"

Types: XtkTooltipPreset, XtkTooltipTheme, XtkTooltip, XtkTooltipSection, XTK_TOOLTIP_STYLE_BOLD and the other values, XtkTooltipContent, XtkTooltipLinkCallback

Functions: xtk_tooltip_config_init_defaults, xtk_tooltip_config_parse_styling, xtk_tooltip_config_write_styling, xtk_tooltip_create, xtk_tooltip_destroy, xtk_tooltip_set_preset, xtk_tooltip_set_theme, xtk_tooltip_get_theme, xtk_tooltip_preset_name, xtk_tooltip_preset_from_name, xtk_tooltip_get_preset_theme, xtk_tooltip_show, xtk_tooltip_schedule, xtk_tooltip_set_icon, xtk_tooltip_hide, xtk_tooltip_is_visible, xtk_tooltip_get_window, xtk_tooltip_update, xtk_tooltip_cancel, xtk_tooltip_content_new, xtk_tooltip_content_free, xtk_tooltip_content_clear, xtk_tooltip_content_section, xtk_tooltip_content_add_space, xtk_tooltip_get_space, xtk_tooltip_content_add, xtk_tooltip_content_add_link, xtk_tooltip_show_content, xtk_tooltip_replace_content, xtk_tooltip_schedule_content, xtk_tooltip_content_set_tag, xtk_tooltip_shown_tag, xtk_tooltip_is_scheduled, xtk_tooltip_set_popup, xtk_tooltip_set_link_callback, xtk_tooltip_pointer_inside, xtk_tooltip_hide_soon, xtk_tooltip_get_popup_size, xtk_tooltip_set_popup_size, xtk_tooltip_get_popup_font_delta, xtk_tooltip_set_popup_font_delta, xtk_tooltip_set_code_font, xtk_tooltip_set_max_width, xtk_tooltip_handle_event

Types

XtkTooltipPreset

The built-in tooltip color sets.

Each preset is a whole XtkTooltipTheme (see xtk_tooltip_get_preset_theme()). Their names, for a config file, are given by xtk_tooltip_preset_name().

Name Value Description
TOOLTIP_PRESET_DARK 0 "dark": dark grey with light text; the default.
TOOLTIP_PRESET_LIGHT "light": near white with dark text.
TOOLTIP_PRESET_SYSTEM "system": the same colors as dark, with less padding and a smaller font.
TOOLTIP_PRESET_MIDNIGHT "midnight": deep blue-black.
TOOLTIP_PRESET_OCEAN "ocean": navy blue.
TOOLTIP_PRESET_TEAL "teal": dark teal.
TOOLTIP_PRESET_SLATE "slate": blue-grey.
TOOLTIP_PRESET_CHOCOLATE "chocolate": dark brown with caramel text.
TOOLTIP_PRESET_EMBER "ember": dark red.
TOOLTIP_PRESET_RUST "rust": brown-orange.
TOOLTIP_PRESET_GOLD "gold": amber.
TOOLTIP_PRESET_VIOLET "violet": purple.
TOOLTIP_PRESET_ROSE "rose": dark pink.
TOOLTIP_PRESET_FOREST "forest": green.
TOOLTIP_PRESET_GRAPHITE "graphite": plain grey.
TOOLTIP_PRESET_COUNT The number of presets (not a preset).

XtkTooltipTheme

typedef struct TooltipBlock XtkTooltipTheme;

The tooltip's colors, font, geometry and delay.

This is the TooltipBlock of xtk_config.h (config.tooltip) under the tooltip's own name.

XtkTooltip

typedef struct XtkTooltip XtkTooltip;

A tooltip (opaque). Made by xtk_tooltip_create().

XtkTooltipSection

The kind of a section of rich content, which decides its layout.

Rich content reads from top to bottom: code (a declaration), a rule under it, prose, labeled rows, and a dimmed band along the bottom. A small gap separates sections.

Name Value Description
XTK_TOOLTIP_SECTION_CODE 0 In the code font; wraps at spaces, with the wrapped lines indented by four spaces. A rule is drawn under the last of a run of CODE sections.
XTK_TOOLTIP_SECTION_TEXT Prose in the tooltip's font, wrapped at spaces; \n starts a new line.
XTK_TOOLTIP_SECTION_FIELD A labeled row, such as "Params:" and its text. The labels form a column of their own; a label is shown once for a run of rows with the same label.
XTK_TOOLTIP_SECTION_FOOTER A band along the bottom, in dimmed text (for example, where a symbol is declared).
XTK_TOOLTIP_SECTION_SPACE An empty box for a window of the program's own, such as a color swatch: xtk_tooltip_content_add_space(), xtk_tooltip_get_space().

XTK_TOOLTIP_STYLE_BOLD and the other values

The style bits of a run of rich content, combined with |.

Name Value Description
XTK_TOOLTIP_STYLE_BOLD 1 The tooltip's font, bold.
XTK_TOOLTIP_STYLE_CODE 2 The code font (always used in a CODE section).

XtkTooltipContent

typedef struct XtkTooltipContent XtkTooltipContent;

Rich content for a tooltip: sections of colored runs of text (opaque).

The program builds it with xtk_tooltip_content_section() and xtk_tooltip_content_add(). The show and schedule calls copy it, so the same content can be cleared and built again for the next tooltip at once. It holds at most 32 KB of text, 2048 runs and 96 sections; what is added past that is left out.

XtkTooltipLinkCallback

typedef void (*XtkTooltipLinkCallback)(XtkTooltip *tooltip, int link, void *user_data);

Called when a link of a popup is clicked.

The callback may hide the tooltip or show other content in it.

Functions

xtk_tooltip_config_init_defaults

void xtk_tooltip_config_init_defaults(TooltipBlock *tooltip_config);

Fills a TooltipBlock with the defaults, which are the "dark" preset.

xtk_config_init_defaults() already does this for config.tooltip.

Parameter Description
tooltip_config The block to fill.

xtk_tooltip_config_parse_styling

int xtk_tooltip_config_parse_styling(
    TooltipBlock *tooltip_config,
    const char *key,
    const char *value);

Reads one [tooltip] key into a TooltipBlock.

Parameter Description
tooltip_config The block to change.
key The key: one of those listed at the top of this page.
value The value, as written in the file.

Returns: 1 if the key is known, 0 if not or an argument is NULL.

xtk_tooltip_config_write_styling

int xtk_tooltip_config_write_styling(FILE *file, const TooltipBlock *tooltip_config);

Writes the [tooltip] section to a file.

Parameter Description
file The open file.
tooltip_config The block to write.

Returns: 1 on success, 0 if an argument is NULL.

xtk_tooltip_create

XtkTooltip *xtk_tooltip_create(Display *display, int screen);

Creates a tooltip, hidden, with the "dark" preset.

Parameter Description
display The X display.
screen The screen number; the window is made on its root window.

Returns: The new tooltip, or NULL when display is NULL or memory runs out.

xtk_tooltip_destroy

void xtk_tooltip_destroy(XtkTooltip *tooltip);

Destroys a tooltip and its window.

Parameter Description
tooltip The tooltip. NULL is allowed and does nothing.

xtk_tooltip_set_preset

void xtk_tooltip_set_preset(XtkTooltip *tooltip, XtkTooltipPreset preset);

Gives the tooltip the colors, font and geometry of a preset.

A tooltip on the screen is drawn again in the new colors.

Parameter Description
tooltip The tooltip.
preset The preset. A value of TOOLTIP_PRESET_COUNT or more does nothing.

xtk_tooltip_set_theme

void xtk_tooltip_set_theme(XtkTooltip *tooltip, const XtkTooltipTheme *theme);

Gives the tooltip a theme, usually &config.tooltip.

The theme is copied. A tooltip on the screen is drawn again in the new colors.

Parameter Description
tooltip The tooltip.
theme The theme. NULL does nothing.

xtk_tooltip_get_theme

const XtkTooltipTheme *xtk_tooltip_get_theme(const XtkTooltip *tooltip);

Gives the tooltip's current theme.

Parameter Description
tooltip The tooltip, or NULL.

Returns: The theme, owned by the tooltip (do not free it), or NULL when tooltip is NULL.

xtk_tooltip_preset_name

const char *xtk_tooltip_preset_name(XtkTooltipPreset preset);

Gives the name of a preset.

Parameter Description
preset The preset.

Returns: The name in lower case, such as "dark" or "ocean"; "dark" for a value that is not a preset.

xtk_tooltip_preset_from_name

XtkTooltipPreset xtk_tooltip_preset_from_name(const char *name);

Finds a preset by its name.

Parameter Description
name The name, in lower case as xtk_tooltip_preset_name() gives it, or NULL.

Returns: The preset, or TOOLTIP_PRESET_DARK when name is NULL or no preset has that name.

xtk_tooltip_get_preset_theme

void xtk_tooltip_get_preset_theme(XtkTooltipPreset preset, XtkTooltipTheme *out_theme);

Copies a preset's theme.

Parameter Description
preset The preset; a value that is not a preset gives "dark".
out_theme Receives the theme. NULL does nothing.

xtk_tooltip_show

void xtk_tooltip_show(
    XtkTooltip *tooltip,
    const char *text,
    int target_x,
    int target_y,
    int target_w,
    int target_h);

Shows plain text at once, beside a target rectangle.

The tooltip is sized to the text, placed as described at the top of this page, mapped and drawn. A tooltip that was scheduled is no longer scheduled.

Parameter Description
tooltip The tooltip.
text The text; \n starts a new line. It is copied (at most 1023 bytes; a line wider than the screen wraps). NULL does nothing.
target_x The left edge of the target, in screen coordinates.
target_y The top edge of the target, in screen coordinates.
target_w The width of the target in pixels.
target_h The height of the target in pixels.

xtk_tooltip_schedule

void xtk_tooltip_schedule(
    XtkTooltip *tooltip,
    const char *text,
    int target_x,
    int target_y,
    int target_w,
    int target_h);

Shows plain text after the theme's delay.

It starts the delay (delay-ms) again from now. The text shows on the first xtk_tooltip_update() after the delay, as xtk_tooltip_show() would show it. xtk_tooltip_cancel() or xtk_tooltip_hide() stops it.

Parameter Description
tooltip The tooltip.
text The text; it is copied now. NULL does nothing.
target_x The left edge of the target, in screen coordinates.
target_y The top edge of the target, in screen coordinates.
target_w The width of the target in pixels.
target_h The height of the target in pixels.

xtk_tooltip_set_icon

void xtk_tooltip_set_icon(XtkTooltip *tooltip, const char *icon_key);

Sets or clears an icon drawn before the text of plain tooltips.

The icon stays for every later plain tooltip until it is changed. It is as tall as a line of text, in the text color. It takes effect from the next show.

Parameter Description
tooltip The tooltip.
icon_key An icon key from xtk_icon.h, or NULL or "" for none. An unknown key draws nothing.

xtk_tooltip_hide

void xtk_tooltip_hide(XtkTooltip *tooltip);

Hides the tooltip at once and cancels a scheduled one.

Parameter Description
tooltip The tooltip.

xtk_tooltip_is_visible

int xtk_tooltip_is_visible(const XtkTooltip *tooltip);

Tells whether the tooltip is on the screen.

Parameter Description
tooltip The tooltip, or NULL.

Returns: 1 if it is shown, 0 if not or tooltip is NULL.

xtk_tooltip_get_window

Window xtk_tooltip_get_window(const XtkTooltip *tooltip);

Gives the tooltip's window.

Parameter Description
tooltip The tooltip, or NULL.

Returns: The window, or None when tooltip is NULL.

xtk_tooltip_update

void xtk_tooltip_update(XtkTooltip *tooltip);

Shows a scheduled tooltip when its time has come.

Call it on every pass of the program's event loop. It shows what xtk_tooltip_schedule() or xtk_tooltip_schedule_content() scheduled once the delay has passed, and hides a popup whose xtk_tooltip_hide_soon() wait is over while the pointer is not in it.

Parameter Description
tooltip The tooltip. NULL does nothing.

xtk_tooltip_cancel

void xtk_tooltip_cancel(XtkTooltip *tooltip);

Cancels a scheduled tooltip; one on the screen stays.

Parameter Description
tooltip The tooltip.

xtk_tooltip_content_new

XtkTooltipContent *xtk_tooltip_content_new(void);

Makes a new, empty content.

Returns: The content, which the caller frees with xtk_tooltip_content_free(), or NULL when memory runs out.

xtk_tooltip_content_free

void xtk_tooltip_content_free(XtkTooltipContent *content);

Frees a content made by xtk_tooltip_content_new().

Parameter Description
content The content. NULL is allowed and does nothing.

xtk_tooltip_content_clear

void xtk_tooltip_content_clear(XtkTooltipContent *content);

Empties a content so that it can be built again.

Its tag (xtk_tooltip_content_set_tag()) goes back to 0.

Parameter Description
content The content. NULL does nothing.

xtk_tooltip_content_section

void xtk_tooltip_content_section(
    XtkTooltipContent *content,
    XtkTooltipSection kind,
    const char *label);

Starts a new section; the runs added after it belong to it.

Parameter Description
content The content being built.
kind The kind of section.
label For a FIELD section, its label (such as "Params:"; at most 31 bytes are kept); otherwise NULL.

xtk_tooltip_content_add_space

void xtk_tooltip_content_add_space(XtkTooltipContent *content, int width, int height);

Adds an empty box of the program's own, as a section of its own, at the left edge.

The tooltip leaves the box empty. Once the content shows, xtk_tooltip_get_space() says where the box is in the tooltip's window, and the program can put a child window of its own there (a color swatch, a picture); it moves it as the popup scrolls. A content has at most one box: the last one added counts.

Parameter Description
content The content being built.
width The box's width in pixels.
height Its height in pixels.

xtk_tooltip_get_space

int xtk_tooltip_get_space(
    const XtkTooltip *tooltip,
    int *x,
    int *y,
    int *width,
    int *height);

Where the box of the content shown is (xtk_tooltip_content_add_space()), in the tooltip's window.

Parameter Description
tooltip The tooltip.
x, y Set to the box's top left in the window (y moves as a popup scrolls; it can be outside the window).
width, height Set to its size.

Returns: 1 when the tooltip shows a content with a box, 0 otherwise (nothing set).

xtk_tooltip_content_add

void xtk_tooltip_content_add(
    XtkTooltipContent *content,
    const char *text,
    size_t length,
    const ConfigColor *color,
    unsigned style);

Adds a run of text to the current section.

When no section has been started, a TEXT section is started first.

Parameter Description
content The content being built.
text UTF-8 text; it need not end with a NUL. \n starts a new line. NULL does nothing.
length The length of the text in bytes. 0 does nothing.
color The color of the text, or NULL for the section's color (the theme's text color, dimmed in a footer).
style XTK_TOOLTIP_STYLE_ bits, or 0.
void xtk_tooltip_content_add_link(
    XtkTooltipContent *content,
    const char *text,
    size_t length,
    const ConfigColor *color,
    unsigned style,
    int link);

Adds a run of text that is a link.

Like xtk_tooltip_content_add(), but the run is underlined. In popup mode (xtk_tooltip_set_popup()), a press and release on it calls the link callback (xtk_tooltip_set_link_callback()) with link, and the pointer shows a hand over it.

Parameter Description
content The content being built.
text UTF-8 text; it need not end with a NUL.
length The length of the text in bytes.
color The color of the text, or NULL for the section's color.
style XTK_TOOLTIP_STYLE_ bits, or 0.
link The number the click reports, from 1 to 65535. Any other value makes a run that is not a link.

xtk_tooltip_show_content

void xtk_tooltip_show_content(
    XtkTooltip *tooltip,
    const XtkTooltipContent *content,
    int target_x,
    int target_y,
    int target_w,
    int target_h);

Shows rich content at once, beside a target rectangle.

The content is copied and laid out, at most as wide as xtk_tooltip_set_max_width() allows. The tooltip is placed as plain text is. In popup mode it is at most two fifths of the screen high (or the size set with xtk_tooltip_set_popup_size()), and the rest scrolls; it starts scrolled to the top.

Parameter Description
tooltip The tooltip.
content What to show. NULL does nothing.
target_x The left edge of the target, in screen coordinates.
target_y The top edge of the target, in screen coordinates.
target_w The width of the target in pixels.
target_h The height of the target in pixels.

xtk_tooltip_replace_content

void xtk_tooltip_replace_content(XtkTooltip *tooltip, const XtkTooltipContent *content);

Replaces the rich content on the screen, where it is.

Use it for content that changes while it is read (an answer that came later, a row that came or went). A popup keeps its place, the size the user gave it and its scroll position (as far as the new content allows); a tooltip that is not a popup is shown again at the same target. It does nothing when no rich content is on the screen; use xtk_tooltip_show_content() then.

Parameter Description
tooltip The tooltip.
content The new content. It is copied.

xtk_tooltip_schedule_content

void xtk_tooltip_schedule_content(
    XtkTooltip *tooltip,
    const XtkTooltipContent *content,
    int target_x,
    int target_y,
    int target_w,
    int target_h);

Shows rich content after the theme's delay.

Like xtk_tooltip_schedule(), but for rich content. The content is copied now.

Parameter Description
tooltip The tooltip.
content What to show. NULL does nothing.
target_x The left edge of the target, in screen coordinates.
target_y The top edge of the target, in screen coordinates.
target_w The width of the target in pixels.
target_h The height of the target in pixels.

xtk_tooltip_content_set_tag

void xtk_tooltip_content_set_tag(XtkTooltipContent *content, int tag);

Gives a content the program's own number for what it is about.

A program often builds content for a thing while the tooltip still shows the content of an earlier one (the new one is only scheduled). xtk_tooltip_shown_tag() then tells which content is on the screen. A new or cleared content has the tag 0.

Parameter Description
content The content. NULL does nothing.
tag The number.

xtk_tooltip_shown_tag

int xtk_tooltip_shown_tag(const XtkTooltip *tooltip);

Gives the tag of the rich content on the screen.

Parameter Description
tooltip The tooltip, or NULL.

Returns: The tag of the content shown, or 0 when no rich content is shown or tooltip is NULL.

xtk_tooltip_is_scheduled

int xtk_tooltip_is_scheduled(const XtkTooltip *tooltip);

Tells whether a tooltip waits for its delay to pass.

Parameter Description
tooltip The tooltip, or NULL.

Returns: 1 when a tooltip is scheduled and not yet shown, 0 if not or tooltip is NULL.

xtk_tooltip_set_popup

void xtk_tooltip_set_popup(XtkTooltip *tooltip, int enabled);

Turns popup mode on or off.

A plain tooltip is only looked at: it takes no input, and the program hides it when the pointer leaves the target. In popup mode, rich content becomes a popup that can be used, like an editor's documentation popup:

  • The pointer can move into it, and it stays while the pointer is there. When the pointer leaves it, it hides 350 ms later unless the pointer comes back.
  • The wheel scrolls content that is taller than the popup (40 pixels a step), and a thin scrollbar on its right can be dragged.
  • A link (xtk_tooltip_content_add_link()) can be clicked.
  • The bottom right corner can be dragged to another size (the pointer shows a corner arrow there); the text wraps to the new width.
  • Ctrl with the wheel makes the text larger or smaller; Ctrl with the middle button puts it back to the theme's size.
  • A FOOTER section stays at the bottom: it does not scroll.

The program's part: where it would hide the tooltip because the pointer left the target, it calls xtk_tooltip_hide_soon() instead, so that the pointer has time to reach the popup; it passes the popup window's events to xtk_tooltip_handle_event() and calls xtk_tooltip_update() as for any tooltip. Plain text tooltips are not changed by this mode.

Parameter Description
tooltip The tooltip.
enabled 1 for popup mode, 0 for plain tooltips.
void xtk_tooltip_set_link_callback(
    XtkTooltip *tooltip,
    XtkTooltipLinkCallback callback,
    void *user_data);

Sets the function called when a link of a popup is clicked.

Parameter Description
tooltip The tooltip.
callback The function, or NULL for none.
user_data Passed to the function.

xtk_tooltip_pointer_inside

int xtk_tooltip_pointer_inside(const XtkTooltip *tooltip);

Tells whether the pointer is in the popup.

A program does not hide the popup while this is 1.

Parameter Description
tooltip The tooltip, or NULL.

Returns: 1 when the popup is shown and the pointer is in it or is dragging its scrollbar or its corner; 0 otherwise.

xtk_tooltip_hide_soon

void xtk_tooltip_hide_soon(XtkTooltip *tooltip, int wait_ms);

Hides a popup after a wait, unless the pointer comes into it first.

It also cancels a scheduled tooltip. The wait is counted by xtk_tooltip_update(). A wait that is already running is not started again.

Parameter Description
tooltip The tooltip.
wait_ms The wait in milliseconds. With 0 or less, or for a tooltip that is not in popup mode, the tooltip hides at once.

xtk_tooltip_get_popup_size

void xtk_tooltip_get_popup_size(const XtkTooltip *tooltip, int *width, int *height);

Gives the size of the popup set by the user or the program.

This is the size the user last dragged the popup's corner to, or the size set with xtk_tooltip_set_popup_size(). A program can save it and restore it the next time it runs.

Parameter Description
tooltip The tooltip, or NULL (which gives 0 and 0).
width Receives the width in pixels, 0 if none is set. May be NULL.
height Receives the height in pixels, 0 if none is set. May be NULL.

xtk_tooltip_set_popup_size

void xtk_tooltip_set_popup_size(XtkTooltip *tooltip, int width, int height);

Sets the largest size of popups from the next one on.

A popup is as large as its content asks, up to this size; its text wraps at the width.

Parameter Description
tooltip The tooltip.
width The width in pixels; less than 160 means none is set.
height The height in pixels; less than 60 means none is set.

xtk_tooltip_get_popup_font_delta

int xtk_tooltip_get_popup_font_delta(const XtkTooltip *tooltip);

Gives how much the user enlarged the popup's text.

Ctrl and the wheel change it. A program can save it and restore it with xtk_tooltip_set_popup_font_delta().

Parameter Description
tooltip The tooltip, or NULL.

Returns: The number of pixels added to the font sizes (negative for smaller), or 0 when tooltip is NULL.

xtk_tooltip_set_popup_font_delta

void xtk_tooltip_set_popup_font_delta(XtkTooltip *tooltip, int delta);

Sets how much larger the tooltip's text is than the theme's size.

Shown rich content is laid out again.

Parameter Description
tooltip The tooltip.
delta The number added to the font sizes, from -6 to 16; other values are clamped to that range.

xtk_tooltip_set_code_font

void xtk_tooltip_set_code_font(XtkTooltip *tooltip, const char *family, int pixel_size);

Sets the font for code in rich content.

Shown content is drawn again in the new font.

Parameter Description
tooltip The tooltip.
family The font family, or NULL or "" for "monospace" at the theme's font size.
pixel_size The font size in pixels; 0 or less also means "monospace" at the theme's size.

xtk_tooltip_set_max_width

void xtk_tooltip_set_max_width(XtkTooltip *tooltip, int pixels);

Sets how wide rich content may grow before it wraps.

It takes effect from the next show. The width is also kept within the screen.

Parameter Description
tooltip The tooltip.
pixels The largest width in pixels, or 0 for the default (600).

xtk_tooltip_handle_event

int xtk_tooltip_handle_event(XtkTooltip *tooltip, const XEvent *event);

Handles one X event.

It draws the tooltip on an Expose of its window. In popup mode it also handles the pointer events of the popup (see xtk_tooltip_set_popup()).

Parameter Description
tooltip The tooltip.
event The event.

Returns: 1 if the event was for the tooltip's window and was used, 0 if not.