expose events in gtk2



After finishing the porting of my image viewer widget I am trying to
understand why the gtk2 version is much slower than the gtk version.
One reason that I found is that every time the window with the 
gtk2 widget is focused by the window manager, an exposure event is
generated for the whole window. An additional exposure events are also
generated on button release. In the gtk1.2 version I only get exposure
events when I expect them. I.e. when the window is first mapped, and
when an area of the widget was obscured, and subsequently exposed.

The both the gtk-1.2 version and the gtk-2.0 version the "realize"
function is identical and contains the following setup code:

  attributes.x = widget->allocation.x;
  attributes.y = widget->allocation.y;
  attributes.width = widget->allocation.width;
  attributes.height = widget->allocation.height;
  attributes.wclass = GDK_INPUT_OUTPUT;
  attributes.window_type = GDK_WINDOW_CHILD;
  attributes.event_mask = gtk_widget_get_events (widget) | 
			  GDK_EXPOSURE_MASK |
			  GDK_BUTTON_PRESS_MASK | 
			  GDK_BUTTON_RELEASE_MASK |
			  GDK_POINTER_MOTION_MASK |
                          GDK_POINTER_MOTION_HINT_MASK | 
			  GDK_KEY_PRESS_MASK |
			  GDK_LEAVE_NOTIFY_MASK |
			  GDK_ENTER_NOTIFY_MASK;
  attributes.visual = gtk_widget_get_visual (widget);
  attributes.colormap = gtk_widget_get_colormap (widget);

  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
  widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);

I'm using gtk-2.0.2 on a RedHat 7.3 system.

Regards,
Dov




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