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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 Mar 2015 16:04:59 +0200

> From: Joost Kremers <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Mon, 02 Mar 2015 04:59:25 +0100
> 
> > I asked about values returned by window-width in this scenario, can
> > you provide them?
> 
> Sorry, forgot that. `window-width' doesn't have the same issue. On my
> system, with a maximised Emacs frame (Emacs version 25.0.50.1), it
> returns 236 before `custom-push-theme' + `face-spec-recalc', and 188
> after it, even without doing `C-x 3' followed by `C-x 1'.

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

Also, what does frame-total-cols return during your recipe?

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.

Joost, could you find out where does w->pixel_size change in your
recipe (where 'w' is the pointer to the window displaying *scratch*)?
If my guess is correct, it should change twice: once as shown below in
the backtrace I produced, and then once more, where it changes back to
the dimensions of your display.  We are interested to know where is
that second time, and who calls that code.

One way of finding this out is to put a watchpoint in GDB on
w->pixel_size.  Let me know if you need more detailed instructions for
how to do it.

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
#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
#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
#13 0x011a23f2 in Ffuncall (nargs=5, args=0x88df24) at eval.c:2729
#14 0x011e5ffb in exec_byte_code (bytestr=19792668, vector=19792685,
    maxdepth=30, args_template=0, nargs=0, args=0x0) at bytecode.c:919
#15 0x011a306d in funcall_lambda (fun=19792629, nargs=4,
    arg_vector=0x12e032d <pure+252013>) at eval.c:2951
#16 0x011a25dd in Ffuncall (nargs=5, args=0x88e250) at eval.c:2767
#17 0x011a182c in Fapply (nargs=4, args=0x88e388) at eval.c:2337
#18 0x011a2235 in Ffuncall (nargs=5, args=0x88e384) at eval.c:2698
#19 0x011e5ffb in exec_byte_code (bytestr=19801932, vector=19801949,
    maxdepth=26, args_template=0, nargs=0, args=0x0) at bytecode.c:919
#20 0x011a306d in funcall_lambda (fun=19801893, nargs=3,
    arg_vector=0x12e275d <pure+261277>) at eval.c:2951
#21 0x011a25dd in Ffuncall (nargs=4, args=0x88e6b4) at eval.c:2767
#22 0x011e5ffb in exec_byte_code (bytestr=19801788, vector=19801805,
    maxdepth=22, args_template=0, nargs=0, args=0x0) at bytecode.c:919
#23 0x011a306d in funcall_lambda (fun=19801765, nargs=2,
    arg_vector=0x12e26cd <pure+261133>) at eval.c:2951
#24 0x011a2918 in apply_lambda (fun=19801765, args=98601339, count=13)
    at eval.c:2826
#25 0x011a1118 in eval_sub (form=98601363) at eval.c:2226
#26 0x011a069d in Feval (form=98601363, lexical=0) at eval.c:1996
#27 0x011a2376 in Ffuncall (nargs=3, args=0x88eb9c) at eval.c:2721
#28 0x011e5ffb in exec_byte_code (bytestr=20304908, vector=20304925,
    maxdepth=22, args_template=1030, nargs=1, args=0x88eed0) at bytecode.c:919
#29 0x011a2c42 in funcall_lambda (fun=20304885, nargs=1, arg_vector=0x88eecc)
    at eval.c:2885
#30 0x011a25dd in Ffuncall (nargs=2, args=0x88eec8) at eval.c:2767
#31 0x011e5ffb in exec_byte_code (bytestr=20305284, vector=20305301,
    maxdepth=18, args_template=1030, nargs=1, args=0x88f2dc) at bytecode.c:919
#32 0x011a2c42 in funcall_lambda (fun=20305253, nargs=1, arg_vector=0x88f2d8)
    at eval.c:2885
#33 0x011a25dd in Ffuncall (nargs=2, args=0x88f2d4) at eval.c:2767
#34 0x011990dc in Ffuncall_interactively (nargs=2, args=0x88f2d4)
    at callint.c:252
#35 0x011a2235 in Ffuncall (nargs=3, args=0x88f2d0) at eval.c:2698
#36 0x0119b2b5 in Fcall_interactively (function=-10501392, record_flag=0,
    keys=22605245) at callint.c:849
#37 0x011a23ae in Ffuncall (nargs=4, args=0x88f55c) at eval.c:2725
#38 0x011e5ffb in exec_byte_code (bytestr=19977892, vector=19977909,
    maxdepth=54, args_template=4102, nargs=1, args=0x88f8a0) at bytecode.c:919
#39 0x011a2c42 in funcall_lambda (fun=19977869, nargs=1, arg_vector=0x88f89c)
    at eval.c:2885
#40 0x011a25dd in Ffuncall (nargs=2, args=0x88f898) at eval.c:2767
#41 0x011a1e40 in call1 (fn=9184, arg1=-10501392) at eval.c:2573
#42 0x0110b3b3 in command_loop_1 () at keyboard.c:1521
#43 0x0119ee3b in internal_condition_case (bfun=0x110ab87 <command_loop_1>,
    handlers=12224, hfun=0x110a281 <cmd_error>) at eval.c:1348
#44 0x0110a7c2 in command_loop_2 (ignore=0) at keyboard.c:1139
#45 0x0119e376 in internal_catch (tag=31904, func=0x110a797 <command_loop_2>,
    arg=0) at eval.c:1108
#46 0x0110a761 in command_loop () at keyboard.c:1118
#47 0x01109de1 in recursive_edit_1 () at keyboard.c:728
#48 0x01109fd3 in Frecursive_edit () at keyboard.c:799
#49 0x01107f3d in main (argc=2, argv=0xca1f38) at emacs.c:1607

Lisp Backtrace:
"internal-set-lisp-face-attribute" (0x88df28)
"set-face-attribute" (0x88e254)
"apply" (0x88e388)
"face-spec-set-2" (0x88e6b8)
"face-spec-recalc" (0x88e940)
"eval" (0x88eba0)
"elisp--eval-last-sexp" (0x88eecc)
"eval-last-sexp" (0x88f2d8)
"funcall-interactively" (0x88f2d4)
"call-interactively" (0x88f560)
"command-execute" (0x88f89c)