Skip to content

libdocument: Get DPI from GdkMonitor

Marek Kašík requested to merge 617-get-dpi-from-gdk-monitor into master

This commit computes DPI from data provided by GdkMonitor instead of GdkScreen as suggested in issue #617 (closed).

It tries to obtain current GdkMonitor from GdkDisplay using gdk_display_get_monitor_at_window(). If that fails (the GtkWindow has not been realized yet) then it gets primary monitor or the first monitor of given GdkDisplay (when primary monitor has not been set).

Otherwise, it uses DPI 96 if everything fails.

This does not solve the issue when you move the window to a screen with different DPI because there is no signal for this as Jose mentioned.

There is also an issue when you open a document by e.g. "evince a-document.pdf" and its zoom level is gotten from metadata. The scale is computed before the window is realized so we don't know the DPI. This could be solved by connecting to "realize" signal but it would introduce a "blink" I think.

Merge request reports