Subject: Re: bug#62135: xterm.c: (x_set_offset)

From: Madhu <[email-masked]>
Date: Sat, 25 Mar 2023 19:50:34 +0530 (IST)

*  Po Lu <[email-masked]> <[email-masked]>
Wrote on Sun, 12 Mar 2023 17:18:35 +0800
> `change_gravity' means the function should update f->top_pos and
> f->left_pos, then reset the window gravity, as well as move the window
> to f->top_pos and f->left_pos.
>
> `change_gravity' < 0 means to leave f->top_pos and f->left_pos intact.
>
> However, at that point, the window's configuration is not guaranteed to
> have its origin at f->top_pos and f->left_pos, so the window must still
> be moved over.  Thus, the code is correct.  The comment above the
> function is somewhat misleading but still correct.
>
> To test out one theory of mine, please say what this does:
> -  x_wm_set_size_hint (f, 0, false);
> +  x_wm_set_size_hint (f, 0, true);

Thanks for your note (and apologies for the delay).  I think all this
does is push all windows to +0+0 all the time.

>  #ifdef USE_GTK
>    if (x_gtk_use_window_move)
>
>> Also the 0x0 placement only happens on non-gtk builds, because I think
>> there is another bug in lines 22689-22702. x_gtk_use_window_move is
>> always true and gtk builds exit x_set_offset before reaching that
>> line.
>
> If that is the case, I think we have a bug in the x_gtk_use_window_move
> code, and another bug (or at least misbehavior) in Wayfire.

>From what I see in wayfire's src/view/xwayland.c:
(on_configure.callback)

```
            if (!is_mapped())  {
                /* If the view is not mapped yet, let it be configured as it
                 * wishes. We will position it properly in ::map() */
                wlr_xwayland_surface_configure(xw,
                    ev->x, ev->y, ev->width, ev->height);
                if ((ev->mask & XCB_CONFIG_WINDOW_X) &&
                    (ev->mask & XCB_CONFIG_WINDOW_Y))  {

```

During make_frame_visible,

This gets ev->x == 0 and ev->y == 0 (presumably from the XMoveWindow
in x_set_offset) and always pins the geometry of the view at +0+0
because it has got it from the client. It declines to pass the
decision to the placement manager to place the window after the window
is mapped, even though no geometry was supplied (say through
--geometry 80x25+0+0)

The x_gtk_use_window_move codepath actually does not call
gtk_window_move (because of the change_gravity conditional I mention
above) , and so the configure event does not specify values for x,
y. and consequently wayfire does not pin x y.  however gtk still maps
the window at the correct (presumably based on its wm hints) when
gtk_widget_show_all is called in x_make_frame_visible, so fortuitously
there isn't a problem with gtk.

I cant call foul on what wayfire's is doing. would you think
otherwise?