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 549403 - File Chooser pops up in lower right corner
File Chooser pops up in lower right corner
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.13.x
Other Linux
: Normal normal
: ---
Assigned To: Federico Mena Quintero
Federico Mena Quintero
: 559034 559199 563549 564365 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-08-26 08:24 UTC by Paolo Borelli
Modified: 2009-02-19 14:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gif showing the issue (733.89 KB, image/gif)
2008-08-26 08:40 UTC, Paolo Borelli
  Details
Screenshot of the filechooser's default size with the location bar (94.39 KB, image/png)
2008-10-24 23:34 UTC, Giacomo Perale
  Details
Screenshot of the filechooser's default size without the location bar (118.87 KB, image/png)
2008-10-24 23:35 UTC, Giacomo Perale
  Details
dirty fix for the filechooser problems (940 bytes, patch)
2008-10-25 08:26 UTC, Giacomo Perale
none Details | Review
dirty fix for the filechooser problems (818 bytes, patch)
2008-10-25 09:37 UTC, Giacomo Perale
none Details | Review
Backport to 2.14.7 (13.47 KB, patch)
2009-02-19 14:46 UTC, Daniel Gryniewicz
none Details | Review

Description Paolo Borelli 2008-08-26 08:24:11 UTC
After last round of federico's fixes the file chooser is popped up not centered on my screen.

The attached gif shows it (beware, the gif is fairly large ~1MB because I had to take it fullscreen to show the issue)
Comment 1 Paolo Borelli 2008-08-26 08:40:11 UTC
Created attachment 117387 [details]
gif showing the issue

If it matters, my resolution is 1920x1200, dpi is set to 148
Comment 2 Mikael Magnusson 2008-08-26 21:01:51 UTC
I get the same result here, I think. It shows up where it would have been centered, had it not been expanded. Ie, the same result as if you unexpand it, close it, open it, and expand it :).
Comment 3 Giacomo Perale 2008-10-24 23:33:18 UTC
I've got the same problem (gtk+ 2.14.4) and it's very annoying because my screen is just 1024x768 and the filechooser is ALWAYS partially offscreen, especially when the location bar is enabled, in which case the filechooser's size is completely messed up. See attached screenshots.
Comment 4 Giacomo Perale 2008-10-24 23:34:09 UTC
Created attachment 121316 [details]
Screenshot of the filechooser's default size with the location bar
Comment 5 Giacomo Perale 2008-10-24 23:35:05 UTC
Created attachment 121317 [details]
Screenshot of the filechooser's default size without the location bar
Comment 6 Andrew Cowie 2008-10-25 04:52:48 UTC
A number of our users have been experiencing similar issues, and even worse. The FileChooser dialog always used to appear with more or less a consistent size. Now, in addition to being mis-positioned half off screen, it is quite frequently to wide, or too narrow, such that you can't make out any of the files supposedly being displayed. Frankly, it's horrible.

This is a regression since upgrading to 2.14 from 2.12.11; certainly, 2.14.4 didn't fix it.

AfC
Comment 7 Giacomo Perale 2008-10-25 08:26:30 UTC
Created attachment 121328 [details] [review]
dirty fix for the filechooser problems

I went through some distros' bug reporting tools and found these two reports: https://bugs.launchpad.net/ubuntu/+source/gtk+2.0/+bug/285285 and http://bugs.gentoo.org/show_bug.cgi?id=239360. There are probably others but wording could be different and popular distros with gtk+ 2.14 are still in beta/rc stage so the userbase is still reduced. Moreover, I don't know if this bug affects all users or if it is masked/created by a specific wm/xorg/drivers/settings combination.

The attached patch, which is what was suggested in those reports, more or less "fixes" it for me, but I'm pretty much sure that it's incorrect and probably has side effects.
Comment 8 Giacomo Perale 2008-10-25 09:37:47 UTC
Created attachment 121334 [details] [review]
dirty fix for the filechooser problems

The previous patch was probably malformed.
Comment 9 Pacho Ramos 2008-12-15 12:33:27 UTC
*** Bug 564365 has been marked as a duplicate of this bug. ***
Comment 10 Milan Bouchet-Valat 2008-12-22 21:51:07 UTC
For reference, the commits that broke this:
------------------------------------------------------------------------
r21163 | federico | 2008-08-20 03:11:20 +0200 (mer 20 aoû 2008) | 3
lines

[PATCH 2 [edit]/7] bgo543308 - Remove obsolete sizing code in
GtkFileChooserDialog

------------------------------------------------------------------------
r21162 | federico | 2008-08-20 03:10:59 +0200 (mer 20 aoû 2008) | 3
lines

[PATCH 1 [edit]/7] bgo543308 - Let the file chooser widget be in charge of its
default size; don't force it from the dialog


And a screenshot showing a really too small dialog (I managed to reproduce it with Abiword, for example):
http://bugzilla.gnome.org/attachment.cgi?id=124087&action=view
Comment 11 Milan Bouchet-Valat 2008-12-22 21:52:51 UTC
*** Bug 563549 has been marked as a duplicate of this bug. ***
Comment 12 Milan Bouchet-Valat 2008-12-22 22:13:18 UTC
Bug 559199 and bug 559034 are duplicates, and people provided patches, one very similar to what we have here. It could be good to make them as duplicates, if you have the needed permissions.

Any feedback on the 2-line fixes? They don't appear to raise issues, and fixing this regression should be a priority. Need help?
Comment 13 Christian Dywan 2008-12-23 01:40:57 UTC
*** Bug 559034 has been marked as a duplicate of this bug. ***
Comment 14 Christian Dywan 2008-12-23 01:42:52 UTC
*** Bug 559199 has been marked as a duplicate of this bug. ***
Comment 15 Federico Mena Quintero 2008-12-23 18:05:11 UTC
I'm working on a fix for this.
Comment 16 Ian Puleston 2008-12-24 13:00:15 UTC
Milan asked me to pass on comments from bug 559034 which has just been closed as a duplicate of this. From that one:

As the file chooser dialog window opens, first gtk_window_compute_configure_request() is called from gtk_window_show(), and it
actions the GTK_WIN_POS_CENTER_ON_PARENT. But at this point the window size is
only ~ 200x200 pixels.

Then, shortly after that, gtk_file_chooser_dialog_map() is called, it maps the
chooser widget, and then file_chooser_widget_default_size_changed() is called.
The latter calculates the new window size and calls gtk_window_resize() to re-size it to that.

So, the basic problem here is that the centering was done by GtkWindow before
the chooser dialog was mapped, but the chooser does not set its final size
until it is mapped, so the centering is wrong.

I submitted two patches with bug 559034 that are variants of the same fix (the 2nd is probably the better one) which fix it by pre-setting the window size before it is centered by doing it in the constructor.
Comment 17 Federico Mena Quintero 2009-01-14 20:33:34 UTC
Fixed in trunk (see commits 22116, 22117, 22118, 22119):

2009-01-14  Federico Mena Quintero  <federico@novell.com>

	Remember the file chooser's geometry across invocations.

	* gtk/gtkfilechoosersettings.h (struct _GtkFileChooserSettings):
	New fields geometry_x, geometry_y, geometry_width, geometry_height.
	(_gtk_file_chooser_settings_get_geometry): New prototype.
	(_gtk_file_chooser_settings_set_geometry): New prototype.

	* gtk/gtkfilechoosersettings.c (GEOMETRY_X_KEY, GEOMETRY_Y_KEY,
	GEOMETRY_WIDTH_KEY, GEOMETRY_HEIGTH_KEY): New key names.
	(ensure_settings_read): Read the geometry keys.
	(_gtk_file_chooser_settings_save): Save the geometry keys.
	(_gtk_file_chooser_settings_init): Initialize the geometry keys to
	"don't have this value".
	(_gtk_file_chooser_settings_get_geometry): New public function.
	(_gtk_file_chooser_settings_set_geometry): New public function.

	* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_map):
	Don't change the default size in ::map() so we don't flicker...
	(gtk_file_chooser_default_realize): ... so do it in ::realize()
	instead, when the window is not yet visible.  This avoids a
	dialog-that-resizes when you first pop up the file chooser.
	(emit_default_size_changed): Just emit the signal; don't check for
	the widget's state so we can be emitted during the initial
	::realize() when we are not mapped yet.
	(update_preview_widget_visibility): Only emit default_size_changed
	if the widget is not mapped, to avoid resizing the dialog while it
	is visible.

	* gtk/gtkfilechooserdialog.c
	(file_chooser_widget_default_size_changed): Simply resize the
	dialog to the default size without any fancy clamping.  Also,
	leave in place ifdef-ed out code to restore the file chooser's
	position in addition to its size.  The code to restore the
	position doesn't quite work yet, but we'll leave it in as a
	reference.

	* gtk/gtkfilechooserdefault.c (save_dialog_geometry): New function.
	(settings_save): Save the dialog's geometry.
	(gtk_file_chooser_default_get_default_size): Load the geometry
	from the settings.  If it was already saved, return that instead
	of computing an ad-hoc size.

Comment 18 Milan Bouchet-Valat 2009-01-14 20:39:38 UTC
Great! Size is definitely a tricky part of the FileChooser...

Do you think we can expect a bugfix release in the 2.14 series? Else we'll consider backporting patches to Ubuntu. In all cases, I guess the last third patch is sufficient to fix the major issue. Thanks!
Comment 19 Jean-Philippe Fleury 2009-02-18 03:34:35 UTC
(In reply to comment #18)
> Great! Size is definitely a tricky part of the FileChooser...
> 
> Do you think we can expect a bugfix release in the 2.14 series? Else we'll
> consider backporting patches to Ubuntu. In all cases, I guess the last third
> patch is sufficient to fix the major issue. Thanks!

Finally, is there a backport?
Comment 20 Daniel Gryniewicz 2009-02-19 14:46:55 UTC
Created attachment 129067 [details] [review]
Backport to 2.14.7

It's a straight forward backport, but here's the one that we're using.