]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix some DISPLAY variable related bugs on PGTK
authorPo Lu <luangruo@yahoo.com>
Tue, 12 Apr 2022 05:27:56 +0000 (13:27 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 12 Apr 2022 05:27:56 +0000 (13:27 +0800)
* src/callproc.c (getenv_internal, make_environment_block):
Don't set DISPLAY on non-X GDK backends.  (bug#54844)

src/callproc.c

index 0922e10f01d0ad073bf0833300c44a10aebd6d0f..dd162f36a6c89ef174f846763928c52e8a21f3ff 100644 (file)
@@ -85,6 +85,10 @@ extern char **environ;
 #include "nsterm.h"
 #endif
 
+#ifdef HAVE_PGTK
+#include "pgtkterm.h"
+#endif
+
 /* Pattern used by call-process-region to make temp files.  */
 static Lisp_Object Vtemp_file_name_pattern;
 
@@ -1687,6 +1691,7 @@ getenv_internal (const char *var, ptrdiff_t varlen, char **value,
   /* For DISPLAY try to get the values from the frame or the initial env.  */
   if (strcmp (var, "DISPLAY") == 0)
     {
+#ifndef HAVE_PGTK
       Lisp_Object display
        = Fframe_parameter (NILP (frame) ? selected_frame : frame, Qdisplay);
       if (STRINGP (display))
@@ -1695,6 +1700,7 @@ getenv_internal (const char *var, ptrdiff_t varlen, char **value,
          *valuelen = SBYTES (display);
          return 1;
        }
+#endif
       /* If still not found, Look for DISPLAY in Vinitial_environment.  */
       if (getenv_internal_1 (var, varlen, value, valuelen,
                             Vinitial_environment))
@@ -1812,6 +1818,18 @@ make_environment_block (Lisp_Object current_dir)
     if (NILP (display))
       {
        Lisp_Object tmp = Fframe_parameter (selected_frame, Qdisplay);
+
+#ifdef HAVE_PGTK
+       /* The only time GDK actually returns correct information is
+          when it's running under X Windows.  DISPLAY shouldn't be
+          set to a Wayland display either, since that's an X specific
+          variable.  */
+       if (FRAME_WINDOW_P (SELECTED_FRAME ())
+           && strcmp (G_OBJECT_TYPE_NAME (FRAME_X_DISPLAY (SELECTED_FRAME ())),
+                      "GdkX11Display"))
+         tmp = Qnil;
+#endif
+
        if (!STRINGP (tmp) && CONSP (Vinitial_environment))
          /* If still not found, Look for DISPLAY in Vinitial_environment.  */
          tmp = Fgetenv_internal (build_string ("DISPLAY"),