GNOME Bugzilla – Bug 700089
Allocation inconsistency after calling gtk_widget_hide()
Last modified: 2013-07-02 13:57:50 UTC
When hiding a widget, its allocation is reset to 1x1. But it's realized state remains. Some widgets like the tooltips rely on the fact that calling gtk_widget_realize() would provide an a correct allocation to a widget, but if you've called gtk_widget_hide() on a realized widget, you will never get a correct allocation until the widget is actually shown. It might be a wrong assumption to call realize() to get a correct allocation. I'm not sure. Following a quick gjs script showing the inconsistency : -------------------------------------------------------- const Mainloop = imports.mainloop; const Lang = imports.lang; const Gdk = imports.gi.Gdk; const Gtk = imports.gi.Gtk; Gtk.init(null, null); let w = new Gtk.Window(); w.resize(800, 600); let box = new Gtk.Box(); w.add(box); let eb = new Gtk.Button({ label: 'Layout me!' }); box.pack_start(eb, true, true, 0); let dumpWindowState = function(win) { log('window visible : ' + win.visible); log('window realized : ' + win.get_realized()); let alloc = win.get_allocation(); log('window allocation : ' + alloc.width + 'x' + alloc.height); log('-----------'); }; Mainloop.timeout_add_seconds(1, Lang.bind(this, function() { dumpWindowState(w); w.hide(); dumpWindowState(w); w.realize(); dumpWindowState(w); w.show(); return false; })); Mainloop.timeout_add_seconds(2, Lang.bind(this, function() { dumpWindowState(w); return false; })); dumpWindowState(w); w.show_all(); dumpWindowState(w); Gtk.main();
Created attachment 243850 [details] [review] GtkWidget: unrealize widget when hiding
Review of attachment 243850 [details] [review]: no, that is wrong. hiding a widget should not cause us to drop all system resources for it
Created attachment 243857 [details] [review] GtkWidget: ensure a widget has a valid allocated size after realize call Fair enough, coming up with another approach. I'm not sure this is actually correctly implemented.
Created attachment 243864 [details] [review] GtkWidget: ensure a widget has a valid allocated size after realize call
I'd be interested to learn if this also fixes the 'jumping dialogs' we have been seeing lately.
I've noticed that too. If you have a test case, I would be happy to try it (can't find one right now...).
Ok, I found a test case for the jumping dialog. In empathy-accounts, click the button to open a new account. This patch doesn't fix that problem.
The button to create/add a new account.
*** This bug has been marked as a duplicate of bug 696882 ***
Sorry I screwed up my rebase... Checked again after 696882, it's not actually fixing this bug.
Regarding empathy-accounts, it's just empathy filling in the protocol list while the dialog is doing its opening animation. Unrelated... too bad.
Filed as https://bugzilla.gnome.org/show_bug.cgi?id=700397
Matthias, apparently it fixes the jumping dialogs in nautilus.
I giving up on this approach. It showed up deadlocks in ClutterGtk... I opened https://bugzilla.gnome.org/show_bug.cgi?id=703460 instead.