GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 25, 2016 2:41 am

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: wrong tooltip position & gtk_tooltip_trigger_tooltip_que
PostPosted: Wed Mar 18, 2009 12:03 am 

Joined: Tue Mar 17, 2009 11:34 pm
Posts: 3
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:
#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);
    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);

    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?

 Post subject: Interesting but not too surprising
PostPosted: Sat Apr 11, 2009 2:40 am 
Familiar Face

Joined: Fri Jan 12, 2007 2:20 am
Posts: 15
Location: Indiana, USA

My understanding of how this works is;
1. Window Manager control where windows are placed on the Display.
2. GdkDisplay & toolips implementation are not offering any guidance on where to place the tooltip, so the WM places it where it wants (top-left is the default location)
3. We need to use GtkStatusIcon facilitiy to show, hide, and set the tooltip; like gtk_status_icon_set_tooltip() and let the mouse action alone cause the icon to present the tooltip.
4. If you want to force a tooltip like window to display? Use the libnotify apis, which offer the placement options your after.

Just my experience and observations.


Registered Linux User #270764
FC8 on Intel Quad
FC9 on AMD 4800+ X2
FC9 on Dual AMD-MP 2400+
Author: {gfhcm, gkrellfah2,gapcmon}

 Post subject:
PostPosted: Wed May 20, 2009 10:29 pm 

Joined: Tue Mar 17, 2009 11:34 pm
Posts: 3
seems to be fixed in gtk+ 2.16

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group