emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix fit-frame-to-buffer for multi-monitor setup.


From: Sergey Trofimov
Subject: Re: [PATCH] Fix fit-frame-to-buffer for multi-monitor setup.
Date: Sat, 29 Feb 2020 19:31:26 +0100

On Sat, 29 Feb 2020 at 17:05, martin rudalics <address@hidden> wrote:
>
>  > I've noticed `fit-frame-to-buffer` results in incorrect frame position
>  > when the frame is not a child frame. I've looked into the code and
>  > seems that there are two issues: first is that frame monitor is
>  > ignored, always first monitor in `display-monitor-attributes-list` is
>  > used.
>
> Good.  I never really checked that since I always use only one monitor.
> Besides, 'frame-monitor-attributes' should be preferable anyway.
>
>  > Second is that `workarea` and `geometry` are in the form of `(X
>  > Y WIDTH HEIGHT)` but code treats them as `(X1 Y1 X2 Y2)`.
>
> I believe the reasoning was to avoid moving the frame whenever it
> already appears within its margins and thus constrain it to the region
> to the right of and below (X, Y).  But my memory may fail.

Yes, the intention is correct, but few formulas are written in a wrong
assumption of return value of (display-monitor-attributes-list).

> Could you  provide an example where the original code results in bad 
> placement?

I have used this snippet to debug. My setup is:
Screen 0: current 1920 x 1980
LVDS-1 connected 1600x900+0+1080
HDMI-1 connected primary 1920x1080+0+0

LVDS-1 is placed under HDMI-1

;; I'm create a frame on LVDS1 in the upper area of the monitor
(setq sarg/frame
      (posframe-show
       "*scratch*"
       :width 20
       :height 20
       :min-width 20
       :background-color "#ff0000"
       :min-height 20
       :position '(100 . 1200)
       :override-parameters '((parent-frame nil))))

;; this function works correctly and returns size of LVDS-1 where the
frame is shown
(frame-monitor-workarea sarg/frame)
;; (0 1080 1600 900) - (X Y W H)
;; notice that the formula for parent-or-display-width
;;  (- (nth 3 geometry) (nth 1 geometry))
;; is producing incorrect value

(mapcar (lambda (p) (frame-parameter sarg/frame p)) '(left top width height))
;; (100 1200 20 20) - frame is sized and placed correctly

;; the buffer contents are slightly bigger, so the frame should be
resized accordingly
(fit-frame-to-buffer sarg/frame)

(mapcar (lambda (p) (frame-parameter sarg/frame p)) '(left top width height))
;; (100 1004 50 4)
;; new size is correct but the frame jumped on the first monitor, 1004 < 1080

(posframe-delete-all)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]