Strange transparency behaviour

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

 



Hi!

I was making some trials with transparency stuff with the code attached, and I've found that if I put an eventbox in a window and set its background transparent, the background of the window becomes transparent too.

Is this the normal behaviour? I was expecting to see the window background through the eventbox. Is there any way to handle the opacity of the window background and of the eventbox separately? Or maybe there is only one alpha channel per toplevel window and it's impossible to set different opacities to different gdkwindows that are in the same window hierarchy?

Thanks for your help!

Greetings!

--
Miguel Gomez <magomez@xxxxxxxxxx>
Igalia - http://www.igalia.com
#include <gtk/gtk.h>


static gboolean
transparent_expose (GtkWidget      *widget,
                    GdkEventExpose *event)
{
  cairo_t *cr;

  cr = gdk_cairo_create (widget->window);
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  gdk_cairo_region (cr, event->region);
  cairo_fill (cr);
  cairo_destroy (cr);

  return FALSE;
}


int
main (int argc, char **argv)
{
    GtkWidget *window, *event, *label, *aspect;
  GdkScreen *screen;
  GdkColormap *rgba;

  gtk_init (&argc, &argv);


  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  screen = gtk_widget_get_screen (window);
  rgba = gdk_screen_get_rgba_colormap (screen);
  gtk_widget_set_colormap (window, rgba);
  gtk_widget_set_size_request (window, 300, 300);

  aspect = gtk_aspect_frame_new (NULL, 0.5, 0.5, 4.0 / 3, FALSE);
  gtk_container_add (GTK_CONTAINER (window), aspect);
  
  event = gtk_event_box_new ();
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (event), TRUE);
  gtk_widget_set_app_paintable (GTK_WIDGET (event), TRUE);
  gtk_container_add (GTK_CONTAINER (aspect), event);
  g_signal_connect (event, "expose-event",
                    G_CALLBACK (transparent_expose), NULL);

  label = gtk_label_new ("this a visible label");
  gtk_container_add (GTK_CONTAINER (event), label);
  
  gtk_widget_show_all (window);
  
  gtk_main ();

  return 0;
}
_______________________________________________
gtk-list mailing list
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