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 783242 - Evince's window grows after closing and reopening
Evince's window grows after closing and reopening
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 787544 792813 793496 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-05-30 13:48 UTC by teefax
Modified: 2018-02-23 07:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window size patch (2.71 KB, patch)
2017-05-31 10:43 UTC, teefax
none Details | Review
Fix growing window (1.66 KB, patch)
2017-05-31 16:37 UTC, teefax
reviewed Details | Review
shell: Save correct position and size of window in Metadata (2.27 KB, patch)
2018-02-14 03:45 UTC, José Aliste
committed Details | Review

Description teefax 2017-05-30 13:48:47 UTC
Everytime I open a document the window seems to be placed randomly on the screen at a larger size than when I closed it last time. Sometimes the window is even bigger than the vertical size of my monitor. Resizing Evince everytime I open it becomes very tedious.

It would be good to have an option to remember the window size and position and open evince at the same spot and at the same size it had the last time.
Comment 1 Germán Poo-Caamaño 2017-05-30 17:11:09 UTC
Evince remembers the window size per document. If it not working for you, there might be an issue in your system.

Evince uses gsettings for keeping such information.

What is the output of `gvfs-info sample.pdf | grep evince`? where sample.pdf is a file you have opened with Evince.

This report could be a duplicate of 769652
Comment 2 teefax 2017-05-31 10:43:11 UTC
Created attachment 352940 [details] [review]
window size patch

I don't think it's a duplicate.

The problem I am seeing is the following: When I am opening a new document, that is a document I haven't opened with evince before, the placement and size of the window seems to be random and doesn't really fit my expectations. Some documents are opened in fullscreen, others take the entire height but only ~15 % of the width of my monitor. This seems to be caused by the way the window size is initially calculated taking into account the window ratio and document size, which, at least for me, feels unnatural.

If I am opening a document that I have already opened before, the size is somewhat remembered, but the window is growing everytime I open it and eventually exceeds the size of my monitor, for example:

$ evince test.pdf
$ gvfs-info test.pdf | grep evince 
  metadata::evince::author: 
  metadata::evince::continuous: 1
  metadata::evince::dual-page: 0
  metadata::evince::dual-page-odd-left: 0
  metadata::evince::fullscreen: 0
  metadata::evince::inverted-colors: 0
  metadata::evince::page: 0
  metadata::evince::sidebar_page: thumbnails
  metadata::evince::sidebar_size: 200
  metadata::evince::sidebar_visibility: 1
  metadata::evince::sizing_mode: fit-width
  metadata::evince::title: 
  metadata::evince::window_maximized: 0
  metadata::evince::zoom: 1
  metadata::evince::window_width: 1024
  metadata::evince::window_height: 794
  metadata::evince::window_x: 195
  metadata::evince::window_y: 70

and then when I open it a second time, the window becomes larger:

$ evince test.pdf
$ gvfs-info test.pdf | grep evince 
  metadata::evince::author: 
  metadata::evince::continuous: 1
  metadata::evince::dual-page: 0
  metadata::evince::dual-page-odd-left: 0
  metadata::evince::fullscreen: 0
  metadata::evince::inverted-colors: 0
  metadata::evince::page: 0
  metadata::evince::sidebar_page: thumbnails
  metadata::evince::sidebar_size: 200
  metadata::evince::sidebar_visibility: 1
  metadata::evince::sizing_mode: fit-width
  metadata::evince::title: 
  metadata::evince::window_maximized: 0
  metadata::evince::zoom: 1
  metadata::evince::window_height: 883
  metadata::evince::window_width: 1070
  metadata::evince::window_x: 172
  metadata::evince::window_y: 17


I have never contributed to GNOME, so I am not familiar with the code, but the attached patch fixes the problem for me. It seems that the window size that is received in the `window_configure_event_cb` event handler is wrong. I am using xfwm4, so maybe that could be the cause for the wrong values?
Comment 3 Germán Poo-Caamaño 2017-05-31 14:08:39 UTC
Thanks for the detailed explanation. Indeed, it is a different issue.

It may well be triggered by a different window manager, although it would strange.
Comment 4 Germán Poo-Caamaño 2017-05-31 14:09:59 UTC
Review of attachment 352940 [details] [review]:

The patch undoes what it was supposed to be fixed in Bug 617547.

It should be fix the issue, while not introducing regressions.
Comment 5 teefax 2017-05-31 16:37:47 UTC
Created attachment 352958 [details] [review]
Fix growing window

Ok, the attached patch now only addresses the problem with the growing window that is introduced by false values in the event structure. The initial window size is left untouched in this patch.

However, the window size for new documents is calculated multiplying the (window size / document size) ratio of the previously opened document with the document size of the new document, which leads to weird results if the aspect ratios of those documents differ significantly, e.g. when opening a A4 paper and then a 16:9 presentation.
Comment 6 DC 2018-02-13 08:18:25 UTC
@teefax, I can confirm that your patch works flawlessly, finally fixing this annoying bug. Now if we can only get the devs to actually implement it.
Comment 7 José Aliste 2018-02-14 03:30:46 UTC
Review of attachment 352958 [details] [review]:

Yes! I far as I understand, Gtk is adding client decorations to the window, and the positions and sizes we get in the GdkConfigureEvent take
these into account. The gtk doc is not very explicit, as it says to use gtk_window_get_size in size_allocate but it says nothing about ConfigureEvent. But! on my machine Gtk almost always will give me 52pixels difference between the Event width and gtk_window_get_size. 

Also, gtk_window_get_size doc says that these are the values that should be used to save window sizes across sessions. 

In summary, this looks good to me. @Carlos?
Comment 8 José Aliste 2018-02-14 03:45:54 UTC
Created attachment 368334 [details] [review]
shell: Save correct position and size of window in Metadata

Since now Gtk manages (sometimes) client decorations, it is
not safe to use the values we get from configure events or
size allocate events and we must call gtk_window_get_size
and gtk_window_get_position

Patch by iskatu@posteo.org
Comment 9 José Aliste 2018-02-14 03:46:54 UTC
Same patch formatted by git.
Comment 10 José Aliste 2018-02-15 23:46:12 UTC
*** Bug 793496 has been marked as a duplicate of this bug. ***
Comment 11 José Aliste 2018-02-17 13:33:02 UTC
Review of attachment 368334 [details] [review]:

thanks
Comment 12 José Aliste 2018-02-17 13:33:18 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.
Comment 13 Jason Crain 2018-02-21 21:32:38 UTC
*** Bug 792813 has been marked as a duplicate of this bug. ***
Comment 14 Jason Crain 2018-02-23 07:11:34 UTC
*** Bug 787544 has been marked as a duplicate of this bug. ***