I wrote a program that sets up an icon in the systray (
GtkStatusIcon).
The important thing is a tooltip with a text that should be updated every second using
gtk_status_icon_set_tooltip() and
gtk_tooltip_trigger_tooltip_query() and
Here's a stripped down version of the code:
Code:
#include <gtk/gtk.h>
#include <glib.h>
static GtkStatusIcon* icon;
static GTimer* timer;
static int count;
static GdkDisplay* display;
/* this function is called periodically */
static gboolean do_timer(gpointer data)
{
char buffer[64];
snprintf(buffer, sizeof(buffer), "tooltip: %d", count++);
gtk_status_icon_set_tooltip(icon, buffer);
gtk_tooltip_trigger_tooltip_query(display);
return TRUE;
}
int main(int argc, char **argv)
{
timer = g_timer_new();
gtk_init(&argc, &argv);
icon = gtk_status_icon_new_from_file("/path/to/icon.png");
gtk_status_icon_set_visible(icon, TRUE);
gtk_status_icon_set_tooltip(icon, "galarm");
display = gdk_display_get_default();
// start the timer loop
g_timeout_add(1000, do_timer, NULL);
gtk_main();
return 0;
}
In some cases (depending on how the cursor was moved onto the icon) the tooltip appears in the
upper left corner of the screen (see the screenshot). Instead, the tooltip should of course appear next to the mouse cursor.
I can reproduce this problem with gtk+2.12 - 2.14 on Xfce4.4.
Any idea what might be the problem or how to debug gtk internals?