Subject: bug#19972: 24.4; Font size change doesn't update (window-total-width)

From: martin rudalics <[email-masked]>
Date: Mon, 02 Mar 2015 18:08:45 +0100

> In that case, I guess if you call (window-total-width 'round), you
 > will see the correct value even before "C-x 3", right?

I guess so too.  `window-total-width' is very special because it tries
to support `windmove'.  Suppose I have two adjacent side-by-side windows
both 49.5 columns wide.  Then `window-total-width' returns something
like 49 columns for one and 50 for the other window because otherwise
`windmove' would be broken.  `window-left-column' behaves accordingly.

Basically, for windows whose width is not an integral multiple of the
default character width, `window-total-width' is not accurate.  But it
should obviously be "more" correct in Joost's case.

 > Martin, I show below a backtrace that explains how face-spec-recalc
 > causes the frame to be resized, I hope this will help you see what's
 > going on.
 >
 > My guess is that immediately after resizing the frame, as shown below
 > in the backtrace, we get some X event from the window manager telling
 > us to size the frame back, but we either don't interpret that event
 > correctly, or delay its handling.  This second resize doesn't happen
 > on my system, so I cannot show more information about it.

No.  The problem is more trivial.  Every request to resize a frame is
eventually processed by adjust_frame_size.  But if the latter decides
that the width of the frame's root window does not change pixelwise, it
does not call resize_frame_windows.  And it's the latter who's
responsible for updating the total widths and heights of windows (all
for the sake of windmove only).

 > Here's the backtrace from the code that resizes the frame as result of
 > face-spec-recalc:
 >
 > 0x0109bc93 in resize_frame_windows (f=0x17d7a30 <dumped_data+2428016>,
 >      size=833, horflag=true, pixelwise=true) at window.c:4192
 > 4192            r->pixel_width = new_pixel_size;
 > (gdb) bt
 > #0  0x0109bc93 in resize_frame_windows (f=0x17d7a30 <dumped_data+2428016>,
 >      size=833, horflag=true, pixelwise=true) at window.c:4192

Here you see resize_frame_windows getting called which will eventually
call `window--pixel-to-total' to assign the new total sizes of windows.
For Joost this call doesn't happen because new_windows_width equals
old_windows_width.

 > #1  0x01011f3e in adjust_frame_size (f=0x17d7a30 <dumped_data+2428016>,
 >      new_width=800, new_height=700, inhibit=5, pretend=false, parameter=8064)
 >      at frame.c:524
 > #2  0x0100f0cc in change_frame_size_1 (f=0x17d7a30 <dumped_data+2428016>,
 >      new_width=800, new_height=700, pretend=false, delay=false, safe=false,
 >      pixelwise=true) at dispnew.c:5501
 > #3  0x0100f12a in change_frame_size (f=0x17d7a30 <dumped_data+2428016>,
 >      new_width=800, new_height=700, pretend=false, delay=false, safe=false,
 >      pixelwise=true) at dispnew.c:5533
 > #4  0x0100eeb8 in do_pending_window_change (safe=false) at dispnew.c:5459
 > #5  0x0123f29d in x_set_window_size (f=0x17d7a30 <dumped_data+2428016>,
 >      change_gravity=false, width=800, height=700, pixelwise=true)
 >      at w32term.c:6194
 > #6  0x01011e7e in adjust_frame_size (f=0x17d7a30 <dumped_data+2428016>,
 >      new_width=800, new_height=700, inhibit=3, pretend=false, parameter=14464)
 >      at frame.c:490

Note that x_new_font _always_ calls adjust_frame_size (even for the
`set-frame-font' KEEP-SIZE non-nil case) trying to adjust the frame
size.

I sincerely hope your frame was not maximized here.  Otherwise,
resize_frame_windows should not have been called ...

 > #7  0x0123e411 in x_new_font (f=0x17d7a30 <dumped_data+2428016>,
 >      font_object=98909453, fontset=23) at w32term.c:5858
 > #8  0x0101b3b4 in x_set_font (f=0x17d7a30 <dumped_data+2428016>,
 >      arg=101384204, oldval=98121716) at frame.c:3611
 > #9  0x01019339 in x_set_frame_parameters (f=0x17d7a30 <dumped_data+2428016>,
 >      alist=0) at frame.c:3140
 > #10 0x010186e3 in Fmodify_frame_parameters (frame=25000501, alist=8969667)
 >      at frame.c:2663
 > #11 0x010fab62 in set_font_frame_param (frame=25000501, lface=25182821)
 >      at xfaces.c:3321
 > #12 0x010fa43c in Finternal_set_lisp_face_attribute (face=10592, attr=1792,
 >      value=514, frame=25000501) at xfaces.c:3135

martin