Subject: Re: bug#21317: 25.0.50; frame-resize-pixelwise has no effect (GTK, no window manager)

From: Pip Cet <[email-masked]>
Date: Sat, 22 Aug 2015 10:50:59 +0000

Thanks for responding!

On Sat, Aug 22, 2015 at 6:40 AM, martin rudalics <[email-masked]> wrote:
>> When starting Emacs (GTK build) on an X server which has no window
>> manager (such as a newly-created Xnest session), setting
>> `frame-resize-pixelwise' to t followed by a resize operation often has
>> no effect.
>
> According to the manual
>
>      Setting this variable usually causes the next resize operation to
>      pass the corresponding size hints to the window manager.  This
>      means that this variable should be set only in a user's initial
>      file; applications should never bind it temporarily.

That documentation is outdated and does not apply to GTK builds in all
cases, I'm afraid. It is not the window manager that decides to honor
or dishonor frame-resize-pixelwise but GDK. See x_wm_set_size_hint and
gtk_window_move_resize (gtkwindow.c, in the GTK sources). In
particular, gtk_window_compute_configure_request calls
gtk_window_constrain_size which calls gdk_window_constrain_size which
calculates

  width = base_width + FLOOR (width - base_width, xinc);
  height = base_height + FLOOR (height - base_height, yinc);

(where FLOOR is defined as #define FLOOR(value, base)    ( ((gint)
((value) / (base))) * (base) ) )

> So it's possible that Xnest or some other X component refuses to resize
> your frame because the size hints were set up inappropriately.

I'm pretty sure that's not what's happening, but I'll be happy to
provide traces to demonstrate my analysis is correct...or to prove it
wrong, of course! The attached gdb log shows quite clearly that it's
GDK making the second (erroneous) call to XResizeWindow, not Xnest
(there is no window manager).

> Does it also fail when `frame-resize-pixelwise' is set to t in your
> initial file?

Yes, it does.

> Does it fail when you set `frame-resize-pixelwise' to t, request an
> integral resize first and a second non-integral one afterwards?

I'm not sure I fully understand how you define "integral". In short,
non-full-screen resize + redisplay + full-screen resize works, the
other combinations do not.

If I run this code (Xnest running on display :3):

DISPLAY=:3 emacs -Q --eval "(progn (setq frame-resize-pixelwise t)
(set-frame-height (selected-frame) (1+ (frame-pixel-height
(selected-frame))) nil t) (redisplay) (set-frame-parameter
(selected-frame) 'fullscreen 'fullboth))"

Things work, but without the "(redisplay)" they don't. (So that's a
non-full-screen resize first, then a full-screen resize). Doing the
full-screen resize first breaks things.

I must also point out that without the "(redisplay)", there are
unexpected results: the full screen resize appears to be ignored
entirely.

But, again, I currently stand by my initial analysis of what's
happening. The problem is that we cannot simply do the right thing
because of the KWin bug...