I thought it was somewhat related to transparency because doing this:

gdk_window_reparent(win->window,gtk_widget_get_window(GTK_WIDGET
(mainwin)),300,200);

makes the HildonAppMenu work again at the price of loosing the transparency
effect (modified code attached).

--
Luca Donaggio

2009/11/10 Kimmo Hämäläinen <kimmo.hamalai...@nokia.com>

> On Tue, 2009-11-10 at 14:12 +0100, ext Luca Donaggio wrote:
> > Hi Kimmo,
> >
> > I'm sorry to bother you again, but the problem I'm facing is not how
> > to get a transparent window, but that if I create such a window the
> > HildonAppMenu of its parent HildonWindow doesn't show anymore.
> > I (slightly) modified your code to exemplify my situation.
>
> Ah, yes, I can see it.  Looks like the menu is unmapped immediately when
> it is shown. It's weird, I'm not yet sure what unmaps it...  Now it
> looks like hildon-desktop is not unmapping it, so it could be widget
> side problem also. I'll try to find out.
>
> BTW. this problem is not related to the transparency: opaque window does
> the same.
>
> -Kimmo
>
> >
> >
> > Thanks for your time,
> >
> > Luca Donaggio
> >
> > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalai...@nokia.com>
> >         Hi,
> >
> >         Sorry, took some time, I was busy with some bug fixing...  I
> >         started
> >         with the Home applet example and managed to whip up a small
> >         example
> >         (attached) that shows a transparent pop-up window.
> >
> >         -Kimmo
> >
> >
>
>
/*
 gcc -Wall `pkg-config gtk+-2.0 hildon-1 --cflags --libs` rgba-window-example-1.c -o rgba-window-example-1
 */

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

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

  /* Create cairo context */
  cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
  gdk_cairo_region (cr, event->region);
  cairo_clip (cr);

  /* Draw alpha background */
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
  cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
  cairo_paint (cr);

  /* Free context */
  cairo_destroy (cr);

  return FALSE;
}

int main ()
{
  HildonProgram *prog;
  HildonWindow *mainwin;
  GtkWidget *win, *label1, *label2;
  GdkScreen *screen;
  HildonAppMenu *menu;
  GtkWidget *button;

  hildon_gtk_init (NULL, NULL);

  prog = HILDON_PROGRAM (hildon_program_get_instance ());
  mainwin = HILDON_WINDOW (hildon_window_new ());
  hildon_program_add_window (prog, mainwin);

  menu = HILDON_APP_MENU (hildon_app_menu_new ());
  button = gtk_button_new_with_label ("Quit");
  g_signal_connect_after (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
  hildon_app_menu_append (menu, GTK_BUTTON (button));
  gtk_widget_show_all (GTK_WIDGET (menu));
  hildon_window_set_app_menu (mainwin, menu);

  label2 = gtk_label_new ("This is the main Hildon window\nThis is the main Hildon window\nThis is the main Hildon window\nThis is the main Hildon window");
  gtk_container_add (GTK_CONTAINER (mainwin), label2);
  gtk_widget_show_all (GTK_WIDGET (mainwin));

  win = gtk_window_new (GTK_WINDOW_POPUP);
  screen = gtk_widget_get_screen (win);
  gtk_widget_set_colormap (win, gdk_screen_get_rgba_colormap (screen));
  gtk_widget_set_app_paintable (win, TRUE);

  gtk_widget_realize (win);
  gdk_window_set_back_pixmap (win->window, NULL, FALSE);
  gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (mainwin));
  gtk_window_set_destroy_with_parent (GTK_WINDOW (win), TRUE);
  gdk_window_reparent(win->window,gtk_widget_get_window(GTK_WIDGET (mainwin)),300,200);
  gtk_window_move (GTK_WINDOW (win), 300, 200);

  label1 = gtk_label_new ("This is an RGBA window");
  gtk_container_add (GTK_CONTAINER (win), label1);

  gtk_widget_show_all (win);

  g_signal_connect (win, "expose-event", G_CALLBACK (handle_expose), win);
  gtk_main ();
  return 0;
}

_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to