Subject: bug#58945: 29.0.50; Setting frame name in pgtk Emacs is asynchronous

From: Po Lu <[email-masked]>
Date: Thu, 03 Nov 2022 08:31:30 +0800

tags 58945 notabug
thanks

Thibault Polge <[email-masked]> writes:

> In pgtk Emacs (built from a very recent git HEAD), running under the
> Sway window manager, setting a frame name like this:
>
> (set-frame-parameter (selected-frame) 'name "Some new name")
> (redisplay t)
>
> Doesn't immediately take effect.
>
> The example program below demonstrates this by triggering a race
> condition: it renames all frames, then immediately requests the state of
> the Sway window manager, and renames them back. Repeatedly eval'ing the
> final sexp randomly returns either the original or the renamed frame
> names. (When testing with a few frames, it never returned a mix of
> original or renamed names --- it's 100% one or the other)
>
> This is an issue because frame names is the only way to associate Emacs
> frames with Sway identifiers (or any wayland wm) on pgtk Emacs).

Setting the title on Wayland is asynchronous, just as it is with X.  By
the time the request or PropertyNotify event reaches the compositor or
window manager, other processes may already have run.  In addition,
running asynchronously improves performance.

I would recommend just waiting a set delay after setting the title.