Subject: Re: bug#60585: 30.0.50; global-text-scale-adjust shrinks window (was not before), was: Re: bug#52493: 29.0.50; Setting Inconsolata up in init.el makes default face rendered wrong

From: Dmitry Gutov <[email-masked]>
Date: Sun, 12 Feb 2023 04:06:02 +0200

On 12/02/2023 03:45, Po Lu via Bug reports for GNU Emacs, the Swiss army 
knife of text editors wrote:
> Dmitry Gutov<[email-masked]>  writes:
> 
>> On 11/02/2023 12:22, Po Lu via Bug reports for GNU Emacs, the Swiss
>> army knife of text editors wrote:
>>> Dmitry Gutov<[email-masked]>  writes:
>>>
>>>> On 11/02/2023 03:36, Po Lu via Bug reports for GNU Emacs, the Swiss
>>>> army knife of text editors wrote:
>>>>> Whenever you see an inconsistency between what Emacs thinks its WM hints
>>>>> are, and what you think the window manager sees, try to actually read
>>>>> the window manager hints property with `xprop'.
>>>>> It should print several lines describing the window manager hints.
>>>>> WM_NORMAL_HINTS(WM_SIZE_HINTS):
>>>>> 		program specified minimum size: 34 by 55
>>>>> 		program specified resize increment: 8 by 17 <------
>>>>> 		program specified base size: 34 by 55
>>>>> 		window gravity: NorthWest
>>>>> Check there to see if the increment is really 17x37.
>>>>> Xt sometimes refuses to set hints, which can be very confusing.
>>>> Thanks!
>>>>
>>>> Lucid's hints with InconsolataLGC:
>>>>
>>>> WM_NORMAL_HINTS(WM_SIZE_HINTS):
>>>> 		user specified size: 1714 by 1723
>>>> 		program specified minimum size: 51 by 140
>>>> 		program specified resize increment: 17 by 37
>>>> 		program specified base size: 51 by 140
>>>> 		window gravity: NorthWest
>>> I guess the Lucid build is working correctly.
>>>
>>>> GTK's hints with InconsolataLGC:
>>>>
>>>> WM_NORMAL_HINTS(WM_SIZE_HINTS):
>>>> 		program specified minimum size: 64 by 324
>>>> 		program specified resize increment: 16 by 36
>>>> 		program specified base size: 64 by 168
>>>> 		window gravity: NorthWest
>>>>
>>>> GTK's hints with "Inconsolata LGC" are the same, though:
>>>>
>>>> WM_NORMAL_HINTS(WM_SIZE_HINTS):
>>>> 		program specified minimum size: 64 by 324
>>>> 		program specified resize increment: 16 by 36
>>>> 		program specified base size: 64 by 168
>>>> 		window gravity: NorthWest
>>> Thanks.
>>> Would you please instrument emacsgtkfixed.c like such:
>>> diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
>>> index 2b6ebee65fd..24aaf134dd2 100644
>>> --- a/src/emacsgtkfixed.c
>>> +++ b/src/emacsgtkfixed.c
>>> @@ -178,6 +178,9 @@ XSetWMSizeHints (Display *d,
>>>    	 data[5] = w;
>>>    	 data[6] = h; */
>>>    +      fprintf (stderr, "XSetWMSizeHints: %d, %d\n",
>>> hints->width_inc,
>>> +	       hints->height_inc);
>>> +
>>>          /* Make sure min_width and min_height are multiples of width_inc
>>>    	 and height_inc.  */
>>>    and tell me what is printed when Emacs begins to shrink?
>> Apply it on top of the already patched Emacs, correct? The one I've
>> been running most of the tests lately.
>>
>> During startup, it prints:
>>
>> XSetWMSizeHints: 2, 2
>> XSetWMSizeHints: 18, 36
>> XSetWMSizeHints: 18, 36
>> XSetWMSizeHints: 18, 36
>>
>> After I evaluate (set-face-attribute ...), it adds:
>>
>> XSetWMSizeHints: 20, 44
>> XSetWMSizeHints: 16, 36
>> XSetWMSizeHints: 16, 36
>>
>> After that, whenever the same evaluation results in frame shrinking
>> (after I resized it with a mouse), it also prints
>>
>> XSetWMSizeHints: 16, 36
>>
>> That's it.
> Right... thanks.
> 
> I'm interested in why XSetWMSizeHints might be called with 20, 44.
> Would you please put a breakpoint there and make it conditional on
> those values of hints->width_inc and hints->height_inc?

Done.

You didn't specify what information you wanted from that breakpoint, so 
here's everything that came to mind:

Thread 1 "emacs" hit Breakpoint 3, XSetWMSizeHints (d=0x555555eb5e20, 
w=58720469, hints=0x7fffffffc870, prop=40) at emacsgtkfixed.c:187
187	      if (hints->flags & PResizeInc)
(gdb) xbacktrace
"internal-set-lisp-face-attribute" (0xf09ff218)
"set-face-attribute" (0xffffd8c0)
"progn" (0xffffda70)
"eval" (0xf09ff180)
"elisp--eval-last-sexp" (0xf09ff100)
"eval-last-sexp" (0xffffdc50)
"funcall-interactively" (0xffffdc48)
"call-interactively" (0xf09ff070)
"command-execute" (0xffffdef8)
(gdb) p hints->width_inc
$1 = 20
(gdb) p hints->height_inc
$2 = 44
(gdb) backtrace
#0  XSetWMSizeHints (d=0x555555eb5e20, w=58720469, hints=0x7fffffffc870, 
prop=40) at emacsgtkfixed.c:187
#1  0x00007ffff7575fa5 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#2  0x00007ffff79bd37b in  () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#3  0x00007ffff706231c in g_signal_emit_valist () at 
/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4  0x00007ffff7062403 in g_signal_emit () at 
/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#5  0x00007ffff7774980 in  () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#6  0x00007ffff706231c in g_signal_emit_valist () at 
/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff7062403 in g_signal_emit () at 
/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff753ec3b in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#9  0x00007ffff752b2ab in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#10 0x00007ffff6f4bb02 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#11 0x00007ffff6f4b43f in g_main_context_dispatch () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#12 0x00007ffff6fa03c8 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x00007ffff6f48d20 in g_main_context_iteration () at 
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff7847609 in gtk_main_iteration () at 
/lib/x86_64-linux-gnu/libgtk-3.so.0
#15 0x000055555569ad52 in XTread_socket (terminal=<optimized out>, 
hold_quit=0x7fffffffd0a0) at xterm.c:25148
#16 0x00005555556e8491 in gobble_input () at keyboard.c:7416
#17 0x00005555556eb66d in handle_async_input () at keyboard.c:7647
#18 process_pending_signals () at keyboard.c:7661
#19 unblock_input_to (level=0) at keyboard.c:7676
#20 unblock_input_to (level=0) at keyboard.c:7670
#21 totally_unblock_input () at keyboard.c:7704
#22 0x00005555556a2a0c in x_wait_for_event (f=f@entry=0x5555563131e0, 
eventtype=eventtype@entry=22) at xterm.c:27809
#23 0x00005555556d097f in xg_frame_set_char_size 
(f=f@entry=0x5555563131e0, width=width@entry=1728, 
height=height@entry=1620) at gtkutil.c:1425
#24 0x00005555556a2d71 in x_set_window_size (f=0x5555563131e0, 
change_gravity=<optimized out>, width=1728, height=1620) at xterm.c:27916
#25 0x00005555555bd8b4 in adjust_frame_size
     (f=f@entry=0x5555563131e0, new_text_width=1680, 
new_text_height=<optimized out>, inhibit=inhibit@entry=3, 
pretend=pretend@entry=false, parameter=parameter@entry=XIL(0x7860)) at 
frame.c:779
#26 0x000055555568f0e6 in x_new_font (f=0x5555563131e0, 
font_object=XIL(0x55555695e80d), fontset=28) at xterm.c:26576
#27 0x00005555555c49a6 in gui_set_font (f=0x5555563131e0, 
arg=XIL(0x5555569060a4), oldval=XIL(0x55555627fa54)) at frame.c:4791
#28 0x00005555555c2349 in gui_set_frame_parameters_1 
(f=f@entry=0x5555563131e0, alist=<optimized out>, 
alist@entry=XIL(0x7fffffffd6f3), 
default_parameter=default_parameter@entry=true) at frame.c:4383
#29 0x0000555555680221 in set_font_frame_param 
(lface=XIL(0x5555563650d5), frame=XIL(0x5555563131e5)) at xfaces.c:3816
#30 Finternal_set_lisp_face_attribute (face=XIL(0x5940), attr=<optimized 
out>, value=<optimized out>, frame=<optimized out>) at xfaces.c:3629
#31 0x000055555567eeb8 in Finternal_set_lisp_face_attribute 
(face=XIL(0x5940), attr=XIL(0xdb0), value=XIL(0x555556905a94), 
frame=<optimized out>) at xfaces.c:3092
...