Bug 3501 - (int-87442) hildon_window_update_topmost() should handle/ignore windows that haven't been realized
(int-87442)
: hildon_window_update_topmost() should handle/ignore windows that haven't been...
Status: RESOLVED FIXED
Product: Desktop platform
hildon-widgets
: 4.1 (4.2008.23-14)
: All Linux
: Low normal (vote)
: 4.1+
Assigned To: unassigned
: hildon-libs-bugs
:
: easyfix
:
:
  Show dependency tree
 
Reported: 2008-07-26 14:16 UTC by Andrew Zabolotny
Modified: 2008-12-01 12:42 UTC (History)
2 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Andrew Zabolotny (reporter) 2008-07-26 14:16:54 UTC
I've hit a small problem with the hildon library.

The application I'm debugging creates two top-level windows. However, only one
of them is initially visible, the second is created invisible and made visible
later when needed.

I've replaced gtk_window_new() calls with hildon_window_new() calls, and added
hildon_program_add_window() calls right after creating the window. However,
when I run the application, I always get the following warning during startup:

GLIB WARNING ** Gdk - gdkdrawable-x11.c:878 drawable is not a pixmap or window

I've debugged the problem down to hildon-window.c, function
hildon_window_update_topmost. It contains a line:

my_window = GDK_WINDOW_XID (GTK_WIDGET(self)->window);

Problem is, when it's called for the window that wasn't yet mapped
(hildon_window_realize() was not called), the 'window' field in GtkWidget is
zero, this GDK_WINDOW_XID call will emit a warning.

To work around this problem I have either to delay the
hildon_program_add_window() call until the window is actually made visible, or
after adding the window to HildonProgram call immediately gtk_widget_show()
followed by a gtk_widget_hide().

I think hildon_window_update_topmost() should ignore invisible widgets at all.
Comment 1 Andrew Zabolotny (reporter) 2008-07-26 14:28:09 UTC
Was little wrong, deferring the call to hildon_add_window() does not change
anything. It's just enough to create a invisible HildonWindow object and the
warning will appear.

I tried to call gtk_widget_realize(): this indeed removes the above warning,
but a different one appears telling me that I'm trying to allocate a widget
with a height of -24 and a width of 0 :)

So, the show/hide() sequence is the only reliable solution so far.
Comment 2 Andre Klapper maemo.org 2008-07-28 12:09:32 UTC
... interested in providing a patch, or do you think that this needs to be
clarified in the developer documentation (if so, please provide a link)?
Comment 3 Eero Tamminen nokia 2008-08-05 17:17:07 UTC
(In reply to comment #0)
> I've replaced gtk_window_new() calls with hildon_window_new() calls, and added
> hildon_program_add_window() calls right after creating the window. However,
> when I run the application, I always get the following warning during startup:
> 
> GLIB WARNING ** Gdk - gdkdrawable-x11.c:878 drawable is not a pixmap or window
> 
> I've debugged the problem down to hildon-window.c, function
> hildon_window_update_topmost. It contains a line:
> 
> my_window = GDK_WINDOW_XID (GTK_WIDGET(self)->window);

I looked into code and this seems a clear bug.  I've seen this warning
also in logs from our apps, maybe the cause is the same.


> Problem is, when it's called for the window that wasn't yet mapped
> (hildon_window_realize() was not called), the 'window' field in
> GtkWidget is zero, this GDK_WINDOW_XID call will emit a warning.
>
> I think hildon_window_update_topmost() should ignore invisible widgets at all.

A check for "GTK_WIDGET_REALIZED(self)" or "self->window" in line 1466
libhildon::hildon-window.c should be enough:
--------------------------------------------
1456 void
1457 hildon_window_update_topmost                    (HildonWindow *self, 
1458                                                  Window window_id)
1459 {
1460     HildonWindowPrivate *priv = HILDON_WINDOW_GET_PRIVATE (self);
1461 
1462     Window my_window;
1463 
1464     g_return_if_fail (HILDON_IS_WINDOW (self));
1465     g_assert (priv);
1466 
1467     my_window = GDK_WINDOW_XID (GTK_WIDGET (self)->window);
--------------------------------------------

Thanks!
Comment 4 Eero Tamminen nokia 2008-08-07 12:38:29 UTC
was already internally reported with a patch...
Comment 5 Jianjun Yu 2008-08-13 07:45:37 UTC
Can you share your test code ?
Thanks!
Comment 6 Andre Klapper maemo.org 2008-11-03 23:41:59 UTC
This bug has been fixed. Now trying to find out if/when it was publically
released...
Comment 7 Andre Klapper maemo.org 2008-12-01 12:42:59 UTC
Fixed in package
libhildon 2.0.7-1
which is part of the internal build version
diablo build x.2008.47 

(Note that 2008 is the year and the number after is the week.)

Any public update released with or after this build version will include the
fix.
Please verify that the new version fixes the bug by marking this bug report as
VERIFIED after the public update has been released and if you have some time.