After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 700089 - Allocation inconsistency after calling gtk_widget_hide()
Allocation inconsistency after calling gtk_widget_hide()
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-05-10 15:55 UTC by Lionel Landwerlin
Modified: 2013-07-02 13:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkWidget: unrealize widget when hiding (1.25 KB, patch)
2013-05-11 13:16 UTC, Lionel Landwerlin
rejected Details | Review
GtkWidget: ensure a widget has a valid allocated size after realize call (3.01 KB, patch)
2013-05-11 16:48 UTC, Lionel Landwerlin
none Details | Review
GtkWidget: ensure a widget has a valid allocated size after realize call (2.79 KB, patch)
2013-05-11 19:31 UTC, Lionel Landwerlin
none Details | Review

Description Lionel Landwerlin 2013-05-10 15:55:08 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();
Comment 1 Lionel Landwerlin 2013-05-11 13:16:18 UTC
Created attachment 243850 [details] [review]
GtkWidget: unrealize widget when hiding
Comment 2 Matthias Clasen 2013-05-11 13:29:08 UTC
Review of attachment 243850 [details] [review]:

no, that is wrong. hiding a widget should not cause us to drop all system resources for it
Comment 3 Lionel Landwerlin 2013-05-11 16:48:15 UTC
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.
Comment 4 Lionel Landwerlin 2013-05-11 19:31:22 UTC
Created attachment 243864 [details] [review]
GtkWidget: ensure a widget has a valid allocated size after realize call
Comment 5 Matthias Clasen 2013-05-12 15:40:30 UTC
I'd be interested to learn if this also fixes the 'jumping dialogs' we have been seeing lately.
Comment 6 Lionel Landwerlin 2013-05-13 07:41:07 UTC
I've noticed that too. If you have a test case, I would be happy to try it (can't find one right now...).
Comment 7 Lionel Landwerlin 2013-05-15 10:22:02 UTC
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.
Comment 8 Lionel Landwerlin 2013-05-15 11:21:22 UTC
The button to create/add a new account.
Comment 9 Lionel Landwerlin 2013-05-15 15:05:21 UTC

*** This bug has been marked as a duplicate of bug 696882 ***
Comment 10 Lionel Landwerlin 2013-05-15 15:12:02 UTC
Sorry I screwed up my rebase...
Checked again after 696882, it's not actually fixing this bug.
Comment 11 Lionel Landwerlin 2013-05-15 16:08:49 UTC
Regarding empathy-accounts, it's just empathy filling in the protocol list while the dialog is doing its opening animation.
Unrelated... too bad.
Comment 12 Lionel Landwerlin 2013-05-15 16:13:19 UTC
Filed as https://bugzilla.gnome.org/show_bug.cgi?id=700397
Comment 13 Lionel Landwerlin 2013-06-14 09:57:33 UTC
Matthias, apparently it fixes the jumping dialogs in nautilus.
Comment 14 Lionel Landwerlin 2013-07-02 13:57:50 UTC
I giving up on this approach. It showed up deadlocks in ClutterGtk...

I opened https://bugzilla.gnome.org/show_bug.cgi?id=703460 instead.