Subject: bug#38452: 26.3; set-frame-position is slightly drifted

From: Pascal Lambrechts <[email-masked]>
Date: Tue, 3 Dec 2019 18:18:43 +0000

martin rudalics <[email-masked]> writes:

> My guess is that Emacs initially sets the parameter values to the
> requested values and asks the window manager to apply them and later
> sets the parameters to what the window manager has applied.  If you
> retrieve their values in between these two steps, Emacs reports the
> requested and not the finally realized values.
Make sense. I inserted a (sleep-for 5) in the progn between the
set-frame-position and reading the parameters: in that case again the
value of the parameters are also changed  (see the scracth eperiment at
end of mail).

> BTW, I still don't
> know what your window manager is.

I guess it is gdm3 as I entered the following commands:
M-! cat /etc/X11/default-display-manager
==> /usr/sbin/gdm3
M-! ps -e |grep gdm
==>   80 ?        00:00:00 watchdogd
  829 ?        00:00:01 rsyslogd
 1006 ?        00:00:00 gdm3
 1119 ?        00:00:00 gdm-session-wor
 1138 tty1     00:00:00 gdm-x-session
 9679 ?        00:00:00 gdm-session-wor
 9701 tty2     00:00:00 gdm-x-session

>
>
> If we say that the origin for things to display on screen is (-10, -8)
> - something you could probably verify by moving the dock to the right
> and the menu bar line to the bottom - we have a clue.  Just that it
> doesn't make sense to me, yet.

Not sure: when I try with (undecorated.t) I get LEFT=0 TOP=(+ -30)
So the left side seems to be at 0.

>
>  > If I set-frame-position at (x,y) with 0<=x<=55 and 0<=y<=27 then the
>  > frame does not move and the values are reset to (45,19).
>  > If I set-frame-position at (60,30) then the frame moved a little bit and
>  > the parameters evaluate to (50,22).
>
> These fit into the picture sketched above.
>
>  > Here is a scratch file on which I did some experiment commented.

> Fine exercise.  Appreciated!
>
>
> (modify-frame-parameters nil '((left . 0) (top . 0) (undecorated . t)))
> yield (to find out whether these 10/8 are due to the decorations)?
>
" LEFT=0  TOP=(+ -30)"

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with <open> and enter text in its buffer.

;; Experiments with set-frame-position and the result values of the parameters left and top of the frame
;; Each parenthesis sexp has been evaluated with C-j = eval-print-last-sexp
(defun pl-lt ()
  "Returns a string giving the left/top positions of the current frame"
  (concat " LEFT="
	  (prin1-to-string (frame-parameter nil 'left))
	  "  TOP="
	  (prin1-to-string (frame-parameter nil 'top))))

;; 4eme experience 2 displays: on left: internal screen=2ndary display , on right: external=primary display with dock and menu on right
;; the frame is located in the internal screen 
(display-monitor-attributes-list)
(((name . "HDMI-1") (geometry 1920 0 1920 1080) (workarea 1920 27 1920 1053) (mm-size 521 293) (frames) (source . "Gdk")) ((name . "eDP-1") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 309 174) (frames #<frame *unsent mail to martin rudalics* 0x5289930> #<frame test-frame-set-position-Martin-1.el 0x624cc90>) (source . "Gdk")))

(set-frame-position nil 0 0)
t
(pl-lt)
" LEFT=(+ -10)  TOP=(+ -8)"

(progn (set-frame-position nil 0 0) (pl-lt))
" LEFT=0  TOP=0"

(progn (set-frame-position nil 0 0) (sleep-for 5) (pl-lt))
" LEFT=(+ -10)  TOP=(+ -8)"

(modify-frame-parameters nil '((left . 0) (top . 0) (undecorated . t)))
nil
(pl-lt)
" LEFT=0  TOP=(+ -30)"

(modify-frame-parameters nil '((user-position . t) (left . 0) (top . 0)))
nil
(pl-lt)
" LEFT=0  TOP=(+ -30)"

(modify-frame-parameters nil '((user-position . t) (left . 0) (top . 0)  (undecorated . nil)))
nil
(pl-lt)
" LEFT=(+ -10)  TOP=(+ -8)"

===================================

Best,Pascal