Button clicks trigger leave-notify events! Why?



I got interested in tracking the mouse as it moves over a drawing
area.  Imagine my surprise when I found that clicking the mouse button
generates a leave-notify event!  Nothing in the manual prepared me for
this: the GDK reference just says "GDK_LEAVE_NOTIFY the pointer has
left the window".  What is the rationale for this behaviour (if it is
not a bug)?  Should I think of the pointer as leaving the desktop for
the duration of a drag?  What should I do if I need to track the
pointer while the button is pressed?

Details: Linux 2.2.20, Red Hat 6.2, gtk+-1.2.10 .  Demo progam
attached.

Cheers, 

Jeremy Henty 
/*
**  Duh!?!?  I get leave-notify events from button presses!
*/

#include <stdio.h>
#include <gtk/gtk.h>

static void make_interface(void);
int main (int argc, char **argv)
{
  gtk_init(&argc,&argv);
  make_interface();
  gtk_main();
  return 0;
}

static GtkWidget *main_window_make(void);
static GtkWidget *drawing_area_make(void);
static void make_interface (void)
{
  GtkWidget *main_window, *drawing_area;
  main_window = main_window_make();
  drawing_area = drawing_area_make();
  gtk_container_add(GTK_CONTAINER(main_window),drawing_area);
  gtk_widget_show_all(main_window);
}

static void destroy_handler(void);
static GtkWidget *main_window_make(void)
{
  GtkWidget *main_window;
  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title
    (GTK_WINDOW(main_window), "Enter/Leave bug");
  gtk_signal_connect
    (GTK_OBJECT(main_window), "destroy", destroy_handler, NULL);
  return main_window;
}

static void destroy_handler(void)
{
  gtk_main_quit();
}

static void leave_notify_handler(void);
static GtkWidget *drawing_area_make (void)
{
  GtkWidget *drawing_area;
  drawing_area = gtk_drawing_area_new();
  gtk_widget_set_events
    (drawing_area,GDK_LEAVE_NOTIFY_MASK);
  gtk_signal_connect
    (GTK_OBJECT(drawing_area),
     "leave-notify-event",
     leave_notify_handler,
     NULL
     );
  return drawing_area;
}

static void leave_notify_handler(void)
{
  printf("%s","Leave/Notify event\n");
}


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