summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-04-12 13:27:56 +0800
committerPo Lu <luangruo@yahoo.com>2022-04-12 13:27:56 +0800
commite2b64f8999f79a5820ba00d2987885d7dda492d5 (patch)
tree7a9293de6190364bba375074d3d0044aae3bb489
parentb15d9fcebbafc583906a5896dc73dacd0814544c (diff)
downloademacs-e2b64f8999f79a5820ba00d2987885d7dda492d5.tar.gz
Fix some DISPLAY variable related bugs on PGTK
* src/callproc.c (getenv_internal, make_environment_block): Don't set DISPLAY on non-X GDK backends. (bug#54844)
-rw-r--r--src/callproc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 0922e10f01d..dd162f36a6c 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -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"),