[maemo-developers] How to get a transparent GtkWindow (fremantle)
From: Luca Donaggio donaggio at gmail.comDate: Fri Oct 30 15:36:55 EET 2009
- Previous message: How to get a transparent GtkWindow (fremantle)
- Next message: How to get a transparent GtkWindow (fremantle)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks Conny and Kimmo, here are my progresses: I'm able to draw to the GtkWindow using Cairo only if I do it in a callback attached to the expose event of the window itself, but I'm still getting no transparency! I'm sure this is the problem with the window manager that Kimmo pointed out, but I don't know how to set the override-redirect flag apart from passing the correct value inside a GdkWindowAttr struct when manually creating a GdkWindow with gdk_window_new(), but I'm not doing this manually, so I'm lost here! Luca Donaggio 2009/10/30 Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> > On Thu, 2009-10-29 at 17:29 +0100, ext Luca Donaggio wrote: > > I'm trying to create a transparent, non-decorated popup GtkWindow on > > top af my app HildonWindow and draw something on its underlying > > GdkWindow object using cairo. > > All I was able to obtain so far is a black (or whatever is the > > background colour of the selected theme) rectangle -ie it's not > > transparent and everything I paint in its GdkWindow with Cairo is not > > showed at all. > > You may hit (at least) this hard-coded limitation: > http://maemo.gitorious.org/fremantle-hildon- > desktop/libmatchbox2/blobs/master/matchbox/core/mb-wm-client.c#line173<http://maemo.gitorious.org/fremantle-hildon-%0Adesktop/libmatchbox2/blobs/master/matchbox/core/mb-wm-client.c#line173> > > Currently alpha in dialogs and application windows is ignored because it > allows for optimisations in the compositor. But if you set the override- > redirect flag for the window, that should go around that (because the > type of your window would be MBWMClientTypeOverride). > > -Kimmo > > > Here is the code I'm using: > > > > void create_image_details(GtkWidget *callerobj,app_data_t *myapp) { > > PangoLayout *textbuff; > > cairo_t *cr; > > gint x0, y0, r, txtwidth, txtheight; > > > > /* For the widget itself let's use a GtkWindow */ > > if ((myapp->imgparamwin != NULL) & GTK_IS_WINDOW(myapp- > > >imgparamwin)) gtk_widget_destroy(myapp->imgparamwin); > > myapp->imgparamwin = gtk_window_new(GTK_WINDOW_POPUP); > > gtk_window_set_decorated(GTK_WINDOW (myapp->imgparamwin),FALSE); > > gtk_window_set_opacity(GTK_WINDOW (myapp->imgparamwin),0); > > gtk_widget_set_app_paintable(myapp->imgparamwin,TRUE); > > gtk_widget_realize(myapp->imgparamwin); > > /* gdk_window_set_back_pixmap(myapp->imgparamwin- > > >window,NULL,FALSE); */ > > /* Get the Cairo context */ > > cr = gdk_cairo_create(GDK_DRAWABLE (myapp->imgparamwin->window)); > > textbuff = pango_cairo_create_layout(cr); > > pango_layout_set_markup(textbuff,myapp->imgparam,-1); > > pango_layout_get_pixel_size(textbuff,&txtwidth,&txtheight); > > /* Draw a rounded rectangle */ > > > > [cairo stuff is here] > > > > cairo_destroy(cr); > > g_object_unref(textbuff); > > /* Show the widget */ > > gtk_window_resize(GTK_WINDOW (myapp->imgparamwin),txtwidth + (r * > > 2),txtheight + (r * 2)); > > gtk_window_move(GTK_WINDOW (myapp->imgparamwin),30,30); > > gdk_window_reparent(myapp->imgparamwin->window,myapp->image- > > >window,30,30); > > gtk_widget_show_all(myapp->imgparamwin); > > } > > > > The window dimension after the gtk_window_resize() are correct -ie the > > dimension of the PangoLayout containing the text to be rendered, so > > something is definitely going on under the hood... but nothing is > > displayed! > > If I add some widget to the popoup window (for example a GtkLabel with > > some text in it), it's rendered correctly, but, of course it's not > > transparent! > > > > Any help, as always, is much appreciated! > > > > Luca Donaggio > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20091030/0cf84a66/attachment.htm
- Previous message: How to get a transparent GtkWindow (fremantle)
- Next message: How to get a transparent GtkWindow (fremantle)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]