Subject: RE: bug#16923: 24.3.50; reression: `set-frame-size' loses mode line

From: Drew Adams <[email-masked]>
Date: Sun, 9 Mar 2014 09:35:40 -0700 (PDT)

>  >> This means that the frame size changes across the "------------" on line
>  >> 91.  And it changes again across the next two "------------"'s.  Can you
>  >> explain that?
> 
> It's important to get a trace of _every_ call of `set-frame-size' for
> that frame - no matter where it comes from.  Are you sure you did that?

I cannot be sure that something, somewhere else did not issue another call
of `set-frame-size', no.  My debugging is limited to `fit-frame' calls.

> And I take it granted that for each `set-frame-size' you inserted a
> "------------" in the buffer, then three identical `window--dump-frame'
> outputs before the call to `set-frame-size' each preceded by a form feed
> and then three identical `window--dump-frame' outputs after the call to
> `set-frame-size' each preceded by a form feed too.  

Correct, wrt the call to `set-frame-size' within `fit-frame'.  See above.

> Then you did the same for the next `set-frame-size' call.  Can you
> confirm that?  If not, please elaborate.

Yes, AFAIK, IIRC.  And as I've already confirmed several times now.

>  >> If it's caused by the window manager, then you should
>  >> notice that the heights don't fit already there (you got 51 lines
>  >> instead of the 59 you requested).
>  >
>  > What shows a request of 59 and a result of 51?  I see `51' on line 93,
>  > which I guess you are saying is the resulting frame size (?).  But
>  > resulting from what size request?  Where do you see the `59' as an
>  > indication of what size was requested?
> 
> On line 48:
> frame pixel: 627 x 856   cols/lines: 75 x 59   units: 8 x 14
> 
> From the interpretation I gave above this line results from the first
> `window--dump-frame' call following the very first `set-frame-size' call
> you recorded.  Can you see that?  Is my interpretation correct?

Yes.  But again, where does the dump show a _request_ of 59?  What line
48 shows is the _result_ of resizing to 59.  And again, IIRC that was
the right thing to do - the only place where the mode line disappeared
in this debug file is at the end.  But I am repeating what I've already
repeated.

>  > What I think I see instead is this:
>  > 3 calls to w32* before the resize request, showing a height of 51,
>  > followed by 3 more calls to w32* after the resize request, showing
>  > a height of 59 (starting on line 138).
> 
> Line 138 is from the first `window--dump-frame' call following the
> _second_ `set-frame-size' resize request you recorded.  I'm talking
> about the _first_ `set-frame-size' request you recorded.

As I said, IIRC, there was no problem with that first `set-frame-size'
(before line 48).  The mode line did not disappear at that resizing.

But it's possible that I am not remembering correctly.  (So I repeated
the test - below.)

> And please make only one call of `window--dump-frame' before and one
> call after each `set-frame-size' call.  And please don't insert any form
> feeds - they might easily corrupt any communication about which line of
> dumped text we are on.
> 
> ... But what apparently happened is that after
> the last (of six) `window--dump-frame' calles belonging to the first
> `set-frame-size' request and before the first `window--dump-frame' call
> belonging to the second `set-frame-size' request the size of the frame
> changed as in lines 78 to 104 of throw-emacs-bug-16923.txt:
> ...
> And this change is unexplained yet.  What height did you see and
> what height did you expect to see at the time you hit `s' before the
> "------------" was drawn in this excerpt - 59 or 51 lines?

Dunno.

---

I made another test.  I removed the form feed from `window-dump-frame'
and I have `fit-frame' call `window-dump-frame' only once before and once
after `set-frame-size'.  And I have `fit-frame' print the requested new
width and height, before calling `set-frame-size'.

I tested it using `C-x C-_', which is bound to `fit-frame'.  See attached.

It shows that the height, as reported by `window--dump-frame', changed
from 69 to 62 after the dump that reported the result of the first
`set-frame-size'.  Why that would be is a mystery to me.

It shows that the resulting height of the second `set-frame-size', which
caused the mode line to disappear, is correct: 69.  (But the starting
height, according to `window--dump-frame', was unexpected - see above.)

The two attachments show the same test, repeated.  But here is some
more info that may help:

If I just repeat calls to `fit-frame' when the frame is already the
right size then the mode line does not disappear.  To manifest the
problem, I must first manually resize the frame (e.g. with the mouse)
so that `fit-frame' will actually resize it (change its size).  Then,
after that first `fit-frame' resizes it correctly, a second `fit-frame'
leads to the debug output attached: the mode line is lost, and the
dump output from `fit-frame' BEFORE the `set-frame-size' shows an
incorrect height value.

IOW, it seems that what is needed is first (a) an actual change in
frame size by `set-frame-size' and then (b) a `set-frame-size' that
does not actually change the size.  Both (a) and (b) seem necessary
to lose the mode line.  If I start with a frame that already has the
target size (i.e., it has already been fit), then repeating `fit-frame'
has no visible effect, including no loss of the mode line.

Note too that even though the dump shows an incorrect height value,
there is nothing visual that corresponds to this: The frame height
after the frame is fit (correctly) does not visibly change when the
second `fit-frame' is called.  The only visible effect of the second
`fit-frame' is that the mode line disappears.

IOW, `fit-frame', and thus `set-frame-size', seem to be doing their
job correctly.  As you point out, and as these dumps show once again,
something internal in Emacs seems to think that the height is less
than it actually is (by 6 units, in this case).  The new, requested
frame height is applied correctly.

HTH.