Subject: bug#44002: 27.1; Small window height with VcXsrv X server when built with gtk3 toolkit

From: "J. Scott Berg" <[email-masked]>
Date: Mon, 19 Oct 2020 14:02:02 +0000

> -----Original Message-----
> From: martin rudalics <[email-masked]>
> Sent: Saturday, October 17, 2020 5:33 AM
> To: Eli Zaretskii <[email-masked]>; J. Scott Berg <[email-masked]>
> Cc: [email-masked]
> Subject: Re: bug#44002: 27.1; Small window height with VcXsrv X server when
> built with gtk3 toolkit
> 
>  >> I did a bit more debugging. What seems to be happening is that we
>  >> receive a pair of ConfigureNotify events in rapid succession. The
>  >> first is for the top level window, and has a reasonable width and
>  >> height. The second is for the window associated with the frame, but
>  >> it has a width=1 height=1. This then leads to the resizing of the
>  >> frame. Presumably the frame's window is not yet mapped, and thus the
>  >> bogus width and height. Checking for visibility on the frame fixes
>  >> the problem. I've attached a patch that works for me, but I haven't
>  >> exhaustively tested all the various possible cases.
>  >
>  >
>  > Martin, any comments on the proposed patch?  Or on the problem in
>  > general?
> 
> I applied it here and didn't see any detrimental effects.  I suppose we
> should just install it and look whether it causes problems with any of
> our window managers.
> 
> For me the most interesting aspect is that it apparently works with
> GTK2.  Maybe comparing the traces of GTK2 and GTK3 runs could reveal
> more.  Or comparing a GTK3 trace with that of a Lucid build.
> 
>  > Btw, do we understand why this happens only with VcXsrv?
> 
> I never used VcXsrv so I don't know how it works.  As an example, I have
> no idea what the "top level window" is and why it is not the same as the
> "window associated with the frame".  Also, the fact that a "bogus
> height" is propagated while a "bogus width" is not, hints at yet another
> unresolved mystery.

I at least think I understand the width/height mystery. The bogus window size returned is 1x1. This gets turned into text_width and text_height with FRAME_PIXEL_TO_TEXT_WIDTH and FRAME_PIXEL_TO_TEXT_HEIGHT. Due to the fringe, text_width becomes a negative number, text_height is left at 1. Then the code in change_frame_size_1 resets the width to the correct number because it is negative, but leaves the height alone (with the value 1) because it is positive. 

I've included the output of xwininfo (on a properly running emacs) to help describe what I see in the configureNotify events: the two configureNotify events I see are for 2621579 followed by 2611763, where the latter is the window id in the frame structure.

$ xwininfo -all -int

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 2621759 "emacs@LAD-158343"

  Root window id: 203 (the root window) (has no name)
  Parent window id: 203 (the root window) (has no name)
     2 children:
     2621763 (has no name): ()  1x1+-1+-1  +306+351
     2621760 (has no name): ()  1x1+-1+-1  +306+351

  Absolute upper-left X:  307
  Absolute upper-left Y:  352
  Relative upper-left X:  307
  Relative upper-left Y:  352
  Width: 1312
  Height: 1251
  Depth: 24
  Visual: 0x8d
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x28013e (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +307+352  -2221+352  -2221-557  +307-557
  -geometry 1312x1251+307+352

  Bit gravity: NorthWestGravity
  Window gravity: NorthWestGravity
  Backing-store hint: NotUseful
  Backing-planes to be preserved: 0xffffffff
  Backing pixel: 0
  Save-unders: No

  Someone wants these events:
      KeyPress
      KeyRelease
      ButtonPress
      ButtonRelease
      EnterWindow
      LeaveWindow
      PointerMotion
      ButtonMotion
      Exposure
      VisibilityChange
      StructureNotify
      FocusChange
      PropertyChange
  Do not propagate these events:
  Override redirection?: No

  Window manager hints:
      Client accepts input or input focus: Yes
      Initial state is Normal State
      Window type:
          Normal
      Process id: 13793 on host LAD-158343

  Normal window size hints:
      Program supplied minimum size: 0 by 0
      Program supplied base size: 0 by 0
      Program supplied window gravity: NorthWestGravity
  No zoom window size hints defined

  No window shape defined
  No border shape defined