Problem with gdk_pointer_is_grabbed() + test program




gdk_pointer_is_grabbed() often returns 0 even if there is a grab.

I was trying to make sure any pointer grab was released before
calling abort() so I could debug my app. I knew there was a pointer
grab, but gdk_pointer_is_grabbed() always returned 0.

(If I call gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_flush ();
the grab is actually released and I can use gdb OK.)


Damon (GTK+ 1.2.1, Debian 2, i386)


========================================================================

Test Program - run in gdb and click a clist row.
See what gdk_is_pointer_grabbed () returns and if there really is a grab.

WARNING - you will have to switch out of X to kill it!!!


#include <gtk/gtk.h>


static void on_clist_select_row (GtkCList *clist, gint row, gint column,
				 GdkEventButton *bevent, gpointer data);

int
main (int argc, char *argv[])
{
  GtkWidget *window, *clist;
  gchar *row_data[] = { "Another row" };
  gint i;

  gtk_init (&argc, &argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  clist = gtk_clist_new (1);
  gtk_clist_set_column_width (GTK_CLIST (clist), 0, 200);
  for (i = 0; i < 10; i++)
    gtk_clist_append (GTK_CLIST (clist), row_data);
  gtk_signal_connect (GTK_OBJECT (clist), "select-row",
		      GTK_SIGNAL_FUNC (on_clist_select_row), NULL);
  gtk_container_add (GTK_CONTAINER (window), clist);
  gtk_widget_show (clist);
  gtk_widget_show (window);
  gtk_main ();
  return 0;
}

static void
on_clist_select_row (GtkCList *clist, gint row, gint column,
		     GdkEventButton *bevent, gpointer data)
{
  gint is_grabbed = gdk_pointer_is_grabbed ();
  g_print ("gdk_pointer_is_grabbed returned: %i\n", is_grabbed);

  g_print ("Aborting...");
  abort ();
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]