Skip to content

Improve handling of window position / size

Patrick Storz requested to merge ede123/inkscape:monitor_geometry into master

This fixes a few issues with restoring / determining window position / size of new windows, notably:

  • Fixes for the GTK3 deprecation "fixes" which introduced broken behavior in multi-monitor environments (the new implementation mixed up coordinates relative to a specific monitor with gdk screen coordinates which are absolute to the combined screen area).
  • Inkscape blindly assumed it would be shown on the primary display in many places which is often not the case; fix most of these (Inkscape now properly adjusts its size according to the monitor it will be shown on)
  • Remove most custom code that attempted to sanitize window position/size (but failed in many cases) and let gtk+ / the window manager handle this instead (confirmed working on Windows and Ubuntu 16.04)
  • Introduce a new "Default" setting for Window size (which is simply the natural size of the window) and should be a sane default for most cases as it uses the values determined by gtk3 as-is instead of trying to do something clever (at least unless gtk3 does something very stupid and determines a natural size that is larger than the screen - which happens).

Two issues I noticed and for which I don't have an ideal solution yet:

  • Ubuntu's window manager seems to overwrite most of the size requests we make (this was already the case before). Not sure if we should try to do something about it, changing documentation to inform users accordingly might work just as well.
  • In some cases (e.g. when reading window geometry from a file or from preferences after disconnecting a large monitor) it can happen that a window is larger than the monitor. While window size is always clamped to the monitors size it can still happen that some parts of the window are hidden as this clamping does not properly account for task bar heights / titlebars / window decorations (I believe this is a problem especially on Windows). The previous code tried to alleviate this with more or less arbitrary "safety margins" which however often resulted in the window size changing even when it was not necessary which is why I chose to omit those for now. If somebody has any ideas on how to solve this better please let me know.

There was also some refactoring under the hood (more than I intended initially) so please keep your eyes open for regressions.

Edited by Patrick Storz

Merge request reports