Re: How do expose_events work?



It does get configure_event's though.
I tried to connect to a expose_event of a gtk_button in my
container and that works fine.

Does a gtk_drawing_area have an X-window?

Definitely Yes.

Suggestions:

1) play with the scribble-simple example that comes 
with Gtk. This shows how to use a gtk_drawing_area.

2) add this to your mask, you might really want this,
____________________
 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
___________________

3) You should have most, if not all, of this signals connected 
(the example is with a gl_area but it works the same way):

----------------
/* Redraw image when window exposed. */
gtk_signal_connect (GTK_OBJECT (gl_area), "expose_event",
                    GTK_SIGNAL_FUNC (app_mesa_expose_gl_area), window);
/* Handle mouse motion in the gl_area */
gtk_signal_connect (GTK_OBJECT (gl_area), "motion_notify_event",
                    GTK_SIGNAL_FUNC (app_mesa_notify_gl_area_motion), window);
/* Handle mouse press in the gl_area */
gtk_signal_connect (GTK_OBJECT (gl_area), "button_press_event",
                    GTK_SIGNAL_FUNC (app_mesa_press_gl_area_button), window);
/* When window is resized viewport needs to be resized also. */
gtk_signal_connect (GTK_OBJECT (gl_area), "configure_event",
                    GTK_SIGNAL_FUNC (app_mesa_configure_gl_area), window);
__________________

4) You might really need these lines in the beginning of
the motion_notify_event callback, the reason is explained
in Havoc's book, pg 206, basically to avoid a flood of events,
the events receiving stream is blocked until gdk_window_get_pointer 
is called again, so you only have one event at a time. If you don't 
call, motion events are not handled. This is related with
GDK_POINTER_MOTION_HINT_MASK, discussed above.

------------------
gint notify_gl_area_motion (GtkWidget *widget, 
GdkEventMotion *event, gpointer data)
{
GdkModifierType state;
int x, y;

if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state);
else
  {
  x = event->x;
  y = event->y;
  state = event->state;
  }
etc.
_____________

Carlos




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