Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Maemo: Developers

How to get a transparent GtkWindow (fremantle)

 

 

Maemo developers RSS feed   Index | Next | Previous | View Threaded


donaggio at gmail

Oct 29, 2009, 9:29 AM

Post #1 of 21 (2096 views)
Permalink
How to get a transparent GtkWindow (fremantle)

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.
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


hald at icandy

Oct 29, 2009, 10:12 AM

Post #2 of 21 (2042 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

Hi Luca,

create a window like this and then use cairo to draw on it:

GtkWidget *overlay = gtk_window_new(GTK_WINDOW_POPUP);
gtk_window_set_decorated(GTK_WINDOW(overlay), FALSE);
gtk_widget_set_size_request(overlay, 100 100);
gtk_window_set_resizable(GTK_WINDOW(overlay), FALSE);

GdkScreen *screen = gtk_widget_get_screen (widget);
gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));

gtk_widget_realize(overlay);


Cheers!
Conny



On Thu, 2009-10-29 at 17:29 +0100, 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.
> 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
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


kimmo.hamalainen at nokia

Oct 30, 2009, 12:28 AM

Post #3 of 21 (2029 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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

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

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Oct 30, 2009, 6:36 AM

Post #4 of 21 (2027 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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>

> 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
>
>


hald at icandy

Oct 30, 2009, 6:51 AM

Post #5 of 21 (2031 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

Hi Luca,

have a look at this file:
https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/conboy/src/fullscreenmanager.c?revision=517&root=conboy&view=markup

The creation of the overlay window is done in fullscreen_ui_create() and
the cairo drawing on the window is in on_expose_event().

This code works. It creates a small semi-transparent window which is
shown over the main window. I first clear the surface, then I draw a
semi-transparent rectangle with a rounded upper-left corner and then I
add a pixmap with an alpha channel.

I think the most important parts are:

- Setting the color map of the window.
gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap
(screen));

- Clearing the cairo surface.
cairo_set_operator (ctx, CAIRO_OPERATOR_CLEAR);
cairo_paint (ctx);


Hope that helps!
Conny


On Fri, 2009-10-30 at 14:36 +0100, Luca Donaggio wrote:
> 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>
> 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
>
> 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
>
>
>
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


kimmo.hamalainen at nokia

Oct 30, 2009, 7:05 AM

Post #6 of 21 (2033 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Fri, 2009-10-30 at 14:36 +0100, ext Luca Donaggio wrote:
> 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!

gdk_window_set_override_redirect () sets it. You need to set it after
realizing (gtk_widget_realize ()) your window but before showing it.
gtk_widget_get_window () returns GdkWindow of your widget.

-Kimmo

>
> Luca Donaggio
>
> 2009/10/30 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> 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
>
> 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
>
>
>

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Oct 30, 2009, 8:00 AM

Post #7 of 21 (2021 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

Thanks Kimmo, somehow I haven't seen it in the manual page!
But... I found it's not necessary: the thing which was preventing the
transparency effect to work as expected was this instruction:

gdk_window_reparent(myapp->imgparamwin->window,gtk_widget_get_window(GTK_WIDGET
(myapp->mainwin)),offset,offset);

Without it I can get the transparent background just as Conny suggested, BUT
... without it the HildonAppMenu stops working: it shows up and immediately
disappear!

Luca Donaggio

2009/10/30 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>

> On Fri, 2009-10-30 at 14:36 +0100, ext Luca Donaggio wrote:
> > 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!
>
> gdk_window_set_override_redirect () sets it. You need to set it after
> realizing (gtk_widget_realize ()) your window but before showing it.
> gtk_widget_get_window () returns GdkWindow of your widget.
>
> -Kimmo
>
> >
> > Luca Donaggio
> >
> > 2009/10/30 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > 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
> >
> > 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
> >
> >
> >
>
>


donaggio at gmail

Nov 3, 2009, 6:06 AM

Post #8 of 21 (1950 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

I'm still banging my head against a wall with this:

why without reparenting the popup undecorated window to the main app window
it becomes transparent but the app menu doesn't work (it starts to be drawn
but immediately disappears) and viceversa?

The final version of my function is this:

void create_image_details(GtkWidget *callerobj,app_data_t *myapp) {
GdkScreen *screen;
PangoLayout *textbuff;
cairo_t *cr;
gint offset, padding, txtwidth, txtheight;

offset = 20;
padding = 10;
/* For the widget itself let's use a GtkWindow */
if ((myapp->imgparamwin != NULL) & GTK_IS_WINDOW(myapp->imgparamwin))
draw_image_details(myapp->imgparamwin,NULL,myapp);
else {
myapp->imgparamwin = gtk_window_new(GTK_WINDOW_POPUP);
gtk_window_set_decorated(GTK_WINDOW (myapp->imgparamwin),FALSE);
gtk_widget_set_app_paintable(myapp->imgparamwin,TRUE);
screen = gtk_widget_get_screen(myapp->imgparamwin);

gtk_widget_set_colormap(myapp->imgparamwin,gdk_screen_get_rgba_colormap(screen));
gtk_window_set_transient_for(GTK_WINDOW
(myapp->imgparamwin),GTK_WINDOW (myapp->mainwin));
gtk_window_set_destroy_with_parent(GTK_WINDOW
(myapp->imgparamwin),TRUE);
gtk_widget_realize(myapp->imgparamwin);
/* Get the Cairo context and the overall dimensions of the text to
be displayed */
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);
cairo_destroy(cr);
g_object_unref(textbuff);
/* Show the widget */
gtk_widget_set_size_request(myapp->imgparamwin,txtwidth +
padding,txtheight + padding);
gtk_window_set_resizable(GTK_WINDOW (myapp->imgparamwin),FALSE);
gtk_window_set_accept_focus(GTK_WINDOW (myapp->imgparamwin),FALSE);
/*
gdk_window_set_override_redirect(myapp->imgparamwin->window,TRUE);

gdk_window_reparent(myapp->imgparamwin->window,gtk_widget_get_window(GTK_WIDGET
(myapp->mainwin)),offset,offset); */
gtk_window_move(GTK_WINDOW (myapp->imgparamwin),offset,offset);
gtk_widget_show(myapp->imgparamwin);
/* Actual drawing needs to take place when the widget is exposed */
g_signal_connect_after(myapp->imgparamwin,"expose-event",
G_CALLBACK (draw_image_details),myapp);
}
}

--
Luca Donaggio


kimmo.hamalainen at nokia

Nov 3, 2009, 6:30 AM

Post #9 of 21 (1943 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Tue, 2009-11-03 at 15:06 +0100, ext Luca Donaggio wrote:
> I'm still banging my head against a wall with this:
>
> why without reparenting the popup undecorated window to the main app
> window it becomes transparent but the app menu doesn't work (it starts
> to be drawn but immediately disappears) and viceversa?

I think this is not the way to go. This is way too hacky and ugly.
Also, the window manager has not been tested for this kind of
reparenting cases (which cause unmaps and remapping of windows), and
it's likely that it's buggy in handling those.

Home applet windows are transparent, so clearly there is some way to do
it depending on the window type.

Do you have a stand-alone program showing transparent dialog (without
reparenting hacks), so I could spend some time to see if it can be made
to work?

-Kimmo


_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Nov 3, 2009, 7:53 AM

Post #10 of 21 (1954 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

2009/11/3 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>

> On Tue, 2009-11-03 at 15:06 +0100, ext Luca Donaggio wrote:
> > I'm still banging my head against a wall with this:
> >
> > why without reparenting the popup undecorated window to the main app
> > window it becomes transparent but the app menu doesn't work (it starts
> > to be drawn but immediately disappears) and viceversa?
>
> I think this is not the way to go. This is way too hacky and ugly.
> Also, the window manager has not been tested for this kind of
> reparenting cases (which cause unmaps and remapping of windows), and
> it's likely that it's buggy in handling those.
>
> Home applet windows are transparent, so clearly there is some way to do
> it depending on the window type.
>
> Do you have a stand-alone program showing transparent dialog (without
> reparenting hacks), so I could spend some time to see if it can be made
> to work?
>
> -Kimmo
>
>
>
Hi Kimmo,

my project is pretty simple, you can have a look at its sources here: [1].
The relevant code is in interface.c (create_image_details) and callbacks.c
(draw_image_details).

I don't think either that reparenting should be the way to go (I think I've
seen it done for the first time in some example, don't remember where now),
I just found that with it the app menu did work and window's transparency
didn't!

[1]
https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/?root=mrawviewer

--
Luca Donaggio


donaggio at gmail

Nov 4, 2009, 8:12 AM

Post #11 of 21 (1909 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

2009/11/3 Luca Donaggio <donaggio [at] gmail>

> 2009/11/3 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
>
> On Tue, 2009-11-03 at 15:06 +0100, ext Luca Donaggio wrote:
>> > I'm still banging my head against a wall with this:
>> >
>> > why without reparenting the popup undecorated window to the main app
>> > window it becomes transparent but the app menu doesn't work (it starts
>> > to be drawn but immediately disappears) and viceversa?
>>
>> I think this is not the way to go. This is way too hacky and ugly.
>> Also, the window manager has not been tested for this kind of
>> reparenting cases (which cause unmaps and remapping of windows), and
>> it's likely that it's buggy in handling those.
>>
>> Home applet windows are transparent, so clearly there is some way to do
>> it depending on the window type.
>>
>> Do you have a stand-alone program showing transparent dialog (without
>> reparenting hacks), so I could spend some time to see if it can be made
>> to work?
>>
>> -Kimmo
>>
>>
>>
> Hi Kimmo,
>
> my project is pretty simple, you can have a look at its sources here: [1].
> The relevant code is in interface.c (create_image_details) and callbacks.c
> (draw_image_details).
>
> I don't think either that reparenting should be the way to go (I think I've
> seen it done for the first time in some example, don't remember where now),
> I just found that with it the app menu did work and window's transparency
> didn't!
>
> [1]
> https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/?root=mrawviewer
>
> --
> Luca Donaggio
>

Sorry Kimmo,

I forgot to update the svn repo, I'm doing it right now!

--
Luca Donaggio


kimmo.hamalainen at nokia

Nov 10, 2009, 3:33 AM

Post #12 of 21 (1813 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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
Attachments: rgba-window-example.c (1.21 KB)


donaggio at gmail

Nov 10, 2009, 5:12 AM

Post #13 of 21 (1812 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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.


Thanks for your time,

Luca Donaggio

2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>

> 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
>
>
Attachments: rgba-window-example-1.c (2.20 KB)


kimmo.hamalainen at nokia

Nov 10, 2009, 6:22 AM

Post #14 of 21 (1810 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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.hamalainen [at] nokia>
> 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
>
>

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Nov 10, 2009, 7:15 AM

Post #15 of 21 (1804 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

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.hamalainen [at] nokia>

> 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.hamalainen [at] nokia>
> > 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
> >
> >
>
>
Attachments: rgba-window-example-2.c (2.29 KB)


kimmo.hamalainen at nokia

Nov 10, 2009, 11:28 PM

Post #16 of 21 (1789 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> 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).

Reparenting 'win->window' makes it a child of 'mainwin'. That is
completely different ballgame than the original code, which keeps 'win-
>window' a top-level window (child of the root). When the window is not
top-level, it's not managed by the window manager anymore, but it could
also cause something in Gtk/Hildon (at least I have checked all places
deleting windows in hildon-desktop to no avail).

-Kimmo

> --
> Luca Donaggio
>
> 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> 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.hamalainen [at] nokia>
> > 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
> >
> >
>
>
>

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


kimmo.hamalainen at nokia

Nov 11, 2009, 1:11 AM

Post #17 of 21 (1779 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Wed, 2009-11-11 at 08:28 +0100, Hamalainen Kimmo (Nokia-D/Helsinki)
wrote:
> On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> > 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).
>
> Reparenting 'win->window' makes it a child of 'mainwin'. That is
> completely different ballgame than the original code, which keeps 'win-
> >window' a top-level window (child of the root). When the window is not
> top-level, it's not managed by the window manager anymore, but it could
> also cause something in Gtk/Hildon (at least I have checked all places
> deleting windows in hildon-desktop to no avail).

Finally I found the reason for hiding the menu! It's in libhildon
function hildon_app_menu_find_intruder. It thinks that the window with
the "This is an RGBA window" label is an "intruder" (such as dialog
etc.) and closes the menu as soon as it is mapped. This seems like a
bug since the menu should not be mapped in the first place if this
"intruder" is already there at mapping time.

To summarize: this is libhildon bug and hildon-desktop is completely
innocent (at last...)! ;)

-Kimmo

>
> -Kimmo
>
> > --
> > Luca Donaggio
> >
> > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > 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.hamalainen [at] nokia>
> > > 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
> > >
> > >
> >
> >
> >
>
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Nov 12, 2009, 8:21 AM

Post #18 of 21 (1750 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

Thanks a lot Kimmo!

At least, now I know what's happening!
Now, what to do to solve the problem? If HildonAppMenu behaves like this by
design (and if the bug regards only the fact that it is first mapped and
then unmapped while it shouldn't be mapped at all), is there a way to create
a floating top level widget on top of a HildonWindow or it is somewhat
forbidden by the actual implementation?
I don't want to continue the development in the wrong direction, maybe it's
better if I stop here and redisign my app to not include the "offending"
widget and find another way to present the same informations to the user -
but let me say that I grew somewhat fond of my
transparent-overlayed-unobtrusive-image-details-window!

What do you think?

--
Luca Donaggio

2009/11/11 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>

> On Wed, 2009-11-11 at 08:28 +0100, Hamalainen Kimmo (Nokia-D/Helsinki)
> wrote:
> > On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> > > 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).
> >
> > Reparenting 'win->window' makes it a child of 'mainwin'. That is
> > completely different ballgame than the original code, which keeps 'win-
> > >window' a top-level window (child of the root). When the window is not
> > top-level, it's not managed by the window manager anymore, but it could
> > also cause something in Gtk/Hildon (at least I have checked all places
> > deleting windows in hildon-desktop to no avail).
>
> Finally I found the reason for hiding the menu! It's in libhildon
> function hildon_app_menu_find_intruder. It thinks that the window with
> the "This is an RGBA window" label is an "intruder" (such as dialog
> etc.) and closes the menu as soon as it is mapped. This seems like a
> bug since the menu should not be mapped in the first place if this
> "intruder" is already there at mapping time.
>
> To summarize: this is libhildon bug and hildon-desktop is completely
> innocent (at last...)! ;)
>
> -Kimmo
>
> >
> > -Kimmo
> >
> > > --
> > > Luca Donaggio
> > >
> > > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > > 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.hamalainen [at] nokia>
> > > > 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
> > > >
> > > >
> > >
> > >
> > >
> >
> > _______________________________________________
> > maemo-developers mailing list
> > maemo-developers [at] maemo
> > https://lists.maemo.org/mailman/listinfo/maemo-developers
>
>


kimmo.hamalainen at nokia

Nov 13, 2009, 1:44 AM

Post #19 of 21 (1726 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Thu, 2009-11-12 at 17:21 +0100, ext Luca Donaggio wrote:
> Thanks a lot Kimmo!
>
> At least, now I know what's happening!
> Now, what to do to solve the problem? If HildonAppMenu behaves like
> this by design (and if the bug regards only the fact that it is first
> mapped and then unmapped while it shouldn't be mapped at all), is
> there a way to create a floating top level widget on top of a
> HildonWindow or it is somewhat forbidden by the actual implementation?
> I don't want to continue the development in the wrong direction, maybe
> it's better if I stop here and redisign my app to not include the
> "offending" widget and find another way to present the same
> informations to the user - but let me say that I grew somewhat fond of
> my transparent-overlayed-unobtrusive-image-details-window!

I think the cleanest (and most risk-free) solution is that you create
the transparent window as a child window of the main window right from
the beginning. But I'm not sure how Gtk allows that. Better solution
would be fixing the WM so that it allows rgba in dialogs, but that can
be more work...

-Kimmo

>
> What do you think?
>
> --
> Luca Donaggio
>
> 2009/11/11 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> On Wed, 2009-11-11 at 08:28 +0100, Hamalainen Kimmo (Nokia-
> D/Helsinki)
> wrote:
> > On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> > > 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).
> >
> > Reparenting 'win->window' makes it a child of 'mainwin'.
> That is
> > completely different ballgame than the original code, which
> keeps 'win-
> > >window' a top-level window (child of the root). When the
> window is not
> > top-level, it's not managed by the window manager anymore,
> but it could
> > also cause something in Gtk/Hildon (at least I have checked
> all places
> > deleting windows in hildon-desktop to no avail).
>
>
> Finally I found the reason for hiding the menu! It's in
> libhildon
> function hildon_app_menu_find_intruder. It thinks that the
> window with
> the "This is an RGBA window" label is an "intruder" (such as
> dialog
> etc.) and closes the menu as soon as it is mapped. This seems
> like a
> bug since the menu should not be mapped in the first place if
> this
> "intruder" is already there at mapping time.
>
> To summarize: this is libhildon bug and hildon-desktop is
> completely
> innocent (at last...)! ;)
>
> -Kimmo
>
>
> >
> > -Kimmo
> >
> > > --
> > > Luca Donaggio
> > >
> > > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > > 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.hamalainen [at] nokia>
> > > > 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
> > > >
> > > >
> > >
> > >
> > >
> >
>
> > _______________________________________________
> > maemo-developers mailing list
> > maemo-developers [at] maemo
> > https://lists.maemo.org/mailman/listinfo/maemo-developers
>
>
>

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


kimmo.hamalainen at nokia

Nov 13, 2009, 5:37 AM

Post #20 of 21 (1726 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

On Fri, 2009-11-13 at 10:44 +0100, Hamalainen Kimmo (Nokia-D/Helsinki)
wrote:
> On Thu, 2009-11-12 at 17:21 +0100, ext Luca Donaggio wrote:
> > Thanks a lot Kimmo!
> >
> > At least, now I know what's happening!
> > Now, what to do to solve the problem? If HildonAppMenu behaves like
> > this by design (and if the bug regards only the fact that it is first
> > mapped and then unmapped while it shouldn't be mapped at all), is
> > there a way to create a floating top level widget on top of a
> > HildonWindow or it is somewhat forbidden by the actual implementation?
> > I don't want to continue the development in the wrong direction, maybe
> > it's better if I stop here and redisign my app to not include the
> > "offending" widget and find another way to present the same
> > informations to the user - but let me say that I grew somewhat fond of
> > my transparent-overlayed-unobtrusive-image-details-window!
>
> I think the cleanest (and most risk-free) solution is that you create
> the transparent window as a child window of the main window right from
> the beginning. But I'm not sure how Gtk allows that. Better solution
> would be fixing the WM so that it allows rgba in dialogs, but that can
> be more work...

I checked the WM support: it seems to be just a matter of commenting out
the offending code in mb-wm-client.c. But if you use a dialog, your
dialog is closed before you can access the application menu, which is
probably what you are trying to do.

-Kimmo

>
> -Kimmo
>
> >
> > What do you think?
> >
> > --
> > Luca Donaggio
> >
> > 2009/11/11 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > On Wed, 2009-11-11 at 08:28 +0100, Hamalainen Kimmo (Nokia-
> > D/Helsinki)
> > wrote:
> > > On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> > > > 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).
> > >
> > > Reparenting 'win->window' makes it a child of 'mainwin'.
> > That is
> > > completely different ballgame than the original code, which
> > keeps 'win-
> > > >window' a top-level window (child of the root). When the
> > window is not
> > > top-level, it's not managed by the window manager anymore,
> > but it could
> > > also cause something in Gtk/Hildon (at least I have checked
> > all places
> > > deleting windows in hildon-desktop to no avail).
> >
> >
> > Finally I found the reason for hiding the menu! It's in
> > libhildon
> > function hildon_app_menu_find_intruder. It thinks that the
> > window with
> > the "This is an RGBA window" label is an "intruder" (such as
> > dialog
> > etc.) and closes the menu as soon as it is mapped. This seems
> > like a
> > bug since the menu should not be mapped in the first place if
> > this
> > "intruder" is already there at mapping time.
> >
> > To summarize: this is libhildon bug and hildon-desktop is
> > completely
> > innocent (at last...)! ;)
> >
> > -Kimmo
> >
> >
> > >
> > > -Kimmo
> > >
> > > > --
> > > > Luca Donaggio
> > > >
> > > > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > > > 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.hamalainen [at] nokia>
> > > > > 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
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> > > _______________________________________________
> > > maemo-developers mailing list
> > > maemo-developers [at] maemo
> > > https://lists.maemo.org/mailman/listinfo/maemo-developers
> >
> >
> >
>
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers

_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


donaggio at gmail

Nov 13, 2009, 7:41 AM

Post #21 of 21 (1721 views)
Permalink
Re: How to get a transparent GtkWindow (fremantle) [In reply to]

Mmmm... what I need is a place to put some informations about the image
which is currently being displayed by a GtkImage in the main HildonWindow.
With the version of mrawviewer currently in extras-testing I did that by
painting directly over the image itself, as it is always resized to fit the
screen.
With the next version I've introduced the possibility to zoom in / out, and
I wanted the image informations to remain visible all the time while zooming
and scrolling around the image, that's why I thought about a
see-through-GtkWindow positioned over the underlying image.
Of course that window must stay around until the user explicitly closes it
by toggling a filter in the HildonAppMenu. It can't be moved nor resized nor
it gets any focus, it's only purpose is displaying some informations.

I'll investigate on how can I make the transparent window a child of the
main HildonAppWindow upon its creation as you suggested.

Thanks,

--
Luca Donaggio

2009/11/13 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>

> On Fri, 2009-11-13 at 10:44 +0100, Hamalainen Kimmo (Nokia-D/Helsinki)
> wrote:
> > On Thu, 2009-11-12 at 17:21 +0100, ext Luca Donaggio wrote:
> > > Thanks a lot Kimmo!
> > >
> > > At least, now I know what's happening!
> > > Now, what to do to solve the problem? If HildonAppMenu behaves like
> > > this by design (and if the bug regards only the fact that it is first
> > > mapped and then unmapped while it shouldn't be mapped at all), is
> > > there a way to create a floating top level widget on top of a
> > > HildonWindow or it is somewhat forbidden by the actual implementation?
> > > I don't want to continue the development in the wrong direction, maybe
> > > it's better if I stop here and redisign my app to not include the
> > > "offending" widget and find another way to present the same
> > > informations to the user - but let me say that I grew somewhat fond of
> > > my transparent-overlayed-unobtrusive-image-details-window!
> >
> > I think the cleanest (and most risk-free) solution is that you create
> > the transparent window as a child window of the main window right from
> > the beginning. But I'm not sure how Gtk allows that. Better solution
> > would be fixing the WM so that it allows rgba in dialogs, but that can
> > be more work...
>
> I checked the WM support: it seems to be just a matter of commenting out
> the offending code in mb-wm-client.c. But if you use a dialog, your
> dialog is closed before you can access the application menu, which is
> probably what you are trying to do.
>
> -Kimmo
>
> >
> > -Kimmo
> >
> > >
> > > What do you think?
> > >
> > > --
> > > Luca Donaggio
> > >
> > > 2009/11/11 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > > On Wed, 2009-11-11 at 08:28 +0100, Hamalainen Kimmo (Nokia-
> > > D/Helsinki)
> > > wrote:
> > > > On Tue, 2009-11-10 at 16:15 +0100, ext Luca Donaggio wrote:
> > > > > 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).
> > > >
> > > > Reparenting 'win->window' makes it a child of 'mainwin'.
> > > That is
> > > > completely different ballgame than the original code, which
> > > keeps 'win-
> > > > >window' a top-level window (child of the root). When the
> > > window is not
> > > > top-level, it's not managed by the window manager anymore,
> > > but it could
> > > > also cause something in Gtk/Hildon (at least I have checked
> > > all places
> > > > deleting windows in hildon-desktop to no avail).
> > >
> > >
> > > Finally I found the reason for hiding the menu! It's in
> > > libhildon
> > > function hildon_app_menu_find_intruder. It thinks that the
> > > window with
> > > the "This is an RGBA window" label is an "intruder" (such as
> > > dialog
> > > etc.) and closes the menu as soon as it is mapped. This seems
> > > like a
> > > bug since the menu should not be mapped in the first place if
> > > this
> > > "intruder" is already there at mapping time.
> > >
> > > To summarize: this is libhildon bug and hildon-desktop is
> > > completely
> > > innocent (at last...)! ;)
> > >
> > > -Kimmo
> > >
> > >
> > > >
> > > > -Kimmo
> > > >
> > > > > --
> > > > > Luca Donaggio
> > > > >
> > > > > 2009/11/10 Kimmo Hämäläinen <kimmo.hamalainen [at] nokia>
> > > > > 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.hamalainen [at] nokia>
> > > > > > 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
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > > > _______________________________________________
> > > > maemo-developers mailing list
> > > > maemo-developers [at] maemo
> > > > https://lists.maemo.org/mailman/listinfo/maemo-developers
> > >
> > >
> > >
> >
> > _______________________________________________
> > maemo-developers mailing list
> > maemo-developers [at] maemo
> > https://lists.maemo.org/mailman/listinfo/maemo-developers
>
>

Maemo developers RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.