William Brusa <williambr...@airmail.cc> writes: > TL;DR: `org--get-display-dpi` calculated the dpi with data from different > monitors, i fixed it and now it returns the highest correct dpi.
> ... it computed the dpi using `display-pixel-height` and > `display-mm-height`. > > The problem is that one returns the pixel-height of one screen and the other > returns the mm-height of the other one (the plugged one). Seemingly these > function returned the highest value for each field. Right. > My original goal was to have the scaling always refer to one monitor, > or in any case be consistent in such a way that simply the latex > fragment previews wouldn't just change from one moment to the > other. In fact whilst the `:scale` factor (of > `org-format-latex-options`) is fixed, the dpi calculating function > retrieves the monitor parameters dynamically. But I just started > learning lisp yesterday and currently my patch works for my use-case, > but most importantly it properly calculates the dpi. I think that taking the highest dpi among all the monitors is reasonable. Dynamically changing images depending on current monitor will be a lot of work for no clear gain. > The patch retrieves its data from `display-monitor-attributes-list` > which seems more consistent than the previously used functions, albeit > having more overhead (parsing is to be done). It also accounts for the > scaling field provided by the aforementioned function. Not all the monitors have scaling field. Your patch should account for that. For example, here is the output of (display-monitor-attributes-list) on my side: (((name . "eDP-1") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 294 165) (frames #<frame *Minibuf-1* - GNU Emacs at localhost 0x5619eac90f68>) (source . "Gdk"))) > + (cl-labels > + ((compute-dpi (list-of-attr) That list is an alist, a special form of list. See 5.8 Association Lists section of Elisp manual. > + "Compute the DPI for a given LIST-OF-ATTR." > + (let* ((geometry (seq-find (lambda (prop) (eq (car prop) > 'geometry)) list-of-attr)) And you can use `alist-get' rather than directly scanning an alist. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>