Re: How to get a transparent GtkWindow (fremantle)

2009-11-13 Thread Kimmo Hämäläinen
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.hamalai...@nokia.com
 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.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 

Re: How to get a transparent GtkWindow (fremantle)

2009-11-13 Thread Kimmo Hämäläinen
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.hamalai...@nokia.com
  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.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
  

Re: How to get a transparent GtkWindow (fremantle)

2009-11-12 Thread Luca Donaggio
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.hamalai...@nokia.com

 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.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
   
   
  
  
  
 
  ___
  maemo-developers mailing list
  maemo-developers@maemo.org
  https://lists.maemo.org/mailman/listinfo/maemo-developers


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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-11 Thread Kimmo Hämäläinen
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.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
  
  
  
  
  
 
 ___
 maemo-developers mailing list
 maemo-developers@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers

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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-10 Thread Kimmo Hämäläinen
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 --cflags --libs` rgba-window-example.c -o rgba-window-example
 */

#include gtk/gtk.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 ()
{
  GtkWidget *win, *label;
  GdkScreen *screen;

  gtk_init (NULL, NULL);

  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_move (GTK_WINDOW (win), 300, 200);

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

  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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-10 Thread Luca Donaggio
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.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);
  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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-10 Thread Kimmo Hämäläinen
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
 
 

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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-10 Thread Luca Donaggio
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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-10 Thread Kimmo Hämäläinen
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.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
 
 
 
 
 

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


Re: How to get a transparent GtkWindow (fremantle)

2009-11-04 Thread Luca Donaggio
2009/11/3 Luca Donaggio donag...@gmail.com

 2009/11/3 Kimmo Hämäläinen kimmo.hamalai...@nokia.com

 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
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-11-03 Thread Luca Donaggio
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
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-11-03 Thread Kimmo Hämäläinen
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@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-11-03 Thread Luca Donaggio
2009/11/3 Kimmo Hämäläinen kimmo.hamalai...@nokia.com

 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
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-10-30 Thread Kimmo Hämäläinen
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@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-10-30 Thread Luca Donaggio
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.hamalai...@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#line173http://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


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


Re: How to get a transparent GtkWindow (fremantle)

2009-10-30 Thread Cornelius Hald
Hi Luca,

have a look at this file:
https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/conboy/src/fullscreenmanager.c?revision=517root=conboyview=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.hamalai...@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
 
 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 

Re: How to get a transparent GtkWindow (fremantle)

2009-10-30 Thread Kimmo Hämäläinen
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.hamalai...@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
 
 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@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-10-30 Thread Luca Donaggio
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.hamalai...@nokia.com

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

How to get a transparent GtkWindow (fremantle)

2009-10-29 Thread Luca Donaggio
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@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: How to get a transparent GtkWindow (fremantle)

2009-10-29 Thread Cornelius Hald
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@maemo.org
 https://lists.maemo.org/mailman/listinfo/maemo-developers

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