Subject: bug#76190: 31.0.50; Setting frame parameter 'left (- -N) broken

From: Po Lu <[email-masked]>
Date: Wed, 12 Feb 2025 09:35:57 +0800

martin rudalics <[email-masked]> writes:

>>> according to (info "(elisp) Position Parameters"),
>>>
>>>    (set-frame-parameter nil 'left '(- -100))
>>>
>>> should move the selected frame to the right so a small part (100 pixels)
>>> is moved outside of the current screen, and the rest is visible on the
>>> right side.  However, for me the effect is exactly the same as with
>>> (set-frame-parameter nil 'left +100).  A totally different result!  I'm
>>> quite sure that this worked for me as described a while ago.  Something
>>> has changed.  I did not change my system setup AFAICT, still Openbox on
>>> X, same monitor setup, same Notebook, same OS.
>>>
>>> Other values do work as described.  In particular do (+ -N) and
>>> (+ +N) work as described (the latter case is similar to the broken one
>>> but works for me).
>>>
>>> Can others reproduce this?
>>
>> I can't (on MS-Windows): the original example works for me as you
>> expected.
>
> I attached a patch.  Can you try it Michael?
>
> martin
>
> diff --git a/src/xterm.c b/src/xterm.c
> index 0a877e9edf9..962166f3d3e 100644
> --- a/src/xterm.c
> +++ b/src/xterm.c
> @@ -27512,7 +27512,7 @@ x_calc_absolute_position (struct frame *f)
>  
>    /* Treat negative positions as relative to the leftmost bottommost
>       position that fits on the screen.  */
> -  if ((flags & XNegative) && (f->left_pos <= 0))
> +  if (flags & XNegative)
>      {
>        int width = FRAME_PIXEL_WIDTH (f);
>  
> @@ -27539,7 +27539,7 @@ x_calc_absolute_position (struct frame *f)
>  
>      }
>  
> -  if ((flags & YNegative) && (f->top_pos <= 0))
> +  if (flags & YNegative)
>      {
>        int height = FRAME_PIXEL_HEIGHT (f);
>  

This and the documented behavior in the maual doesn't appear correct to
me, as XParseGeometry returns a negative value if XNegative is set.
Hence f->left_pos is meant always to be negative if (flags & XNegative),
and after all, "=100x100--100+0" is not a valid geometry string.