Subject: Re: bug#63555: closed (Re: bug#63555: emacs 29 complains that it can't connect to the display)

From: Po Lu <[email-masked]>
Date: Mon, 22 May 2023 17:26:27 +0800

Robert Pluim <[email-masked]> writes:

> Not too hard. Very much for master, though (and Iʼd need to check if
> gtk_init_check has any GTK version dependencies).
>
> diff --git a/src/dispnew.c b/src/dispnew.c
> index a928a5d1b14..9a23fb5a182 100644
> --- a/src/dispnew.c
> +++ b/src/dispnew.c
> @@ -6518,7 +6518,28 @@ init_display_interactive (void)
>       try to use X, and if that fails output a line to stderr
>       reporting that -nw will be simulated.  */
>  
> -#ifdef HAVE_X_WINDOWS
> +#ifdef HAVE_PGTK
> +  if (! inhibit_window_system)
> +    {
> +     if (! gtk_init_check (0, 0))
> +	{
> +	  fprintf (stderr, "PGTK display unavailable, simulating -nw\nCheck your $DISPLAY, $WAYLAND_DISPLAY, or $BROADWAY_DISPLAY\n");
> +	  inhibit_window_system = 1;
> +	}
> +    }

The problem with this approach is that gtk_init_check initializes the
window system upon success, so once pgtk_term_init is called in
pgtkterm.c, the window system is set up a second time, leaving two
display connections open...