forcing window repaints

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

 



I'm trying to benchmark GdkImage, and I'm having trouble getting the
window to update.  It seems like it will update as the result of an
expose event, but that's it.  Obviously I'm missing something; can
anyone be so kind as to tell me what?

TIA, Neale



Here's the program I'm using:


#include <unistd.h>
#include <assert.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

#define W 1280
#define H 1024

struct crap {
  GtkWidget *window;
  GtkWidget *image;
  GdkImage  *d_image;
};

gboolean
noise(gpointer data)
{
  static int   offset = 0;
  struct crap *c      = (struct crap *)data;

  ((char *)c->d_image->mem)[offset++] = 0xff;

  gtk_widget_show(c->image);

  return TRUE;
}

int
main(int argc, char *argv[])
{
  struct crap *c;

  gtk_init(&argc, &argv);

  c = (struct crap *)alloca(sizeof(*c));

  c->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT(c->window), "destroy",
                   G_CALLBACK(gtk_main_quit), NULL);

  {
    GdkVisual *v;

    v = gdk_visual_get_system();

    c->d_image = gdk_image_new(GDK_IMAGE_SHARED,
                            v,
                            W,
                            H);
    assert(c->d_image);
  }

  c->image = gtk_image_new_from_image(c->d_image, NULL);
  assert(c->image);

  gtk_container_add(GTK_CONTAINER(c->window), c->image);

  gtk_widget_show_all(c->window);

  g_idle_add_full(G_PRIORITY_LOW, noise, c, NULL);

  gtk_main();

  return 0;
}


_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux