;; When connected to various displays, be careful to use the display of
;; the currently selected frame, rather than the original start display,
;; which may not even exist any more.
- (if (stringp (frame-parameter nil 'display))
- (setenv "DISPLAY" (frame-parameter nil 'display)))
+ (let ((dpy (frame-parameter nil 'display))
+ classname)
+ (if (stringp dpy)
+ (cond
+ ((featurep 'pgtk)
+ (setq classname (pgtk-backend-display-class))
+ (if (equal classname "GdkWaylandDisplay")
+ (setenv "WAYLAND_DISPLAY" dpy)
+ (setenv "DISPLAY" dpy)))
+ (t
+ (setenv "DISPLAY" dpy)))))
(if (functionp function)
(apply function url args)
(error "No suitable browser for URL %s" url))))
struct pgtk_display_info *dpyinfo;
static int x_initialized = 0;
static unsigned x_display_id = 0;
+ static char *initial_display = NULL;
+ char *dpy_name;
+ Lisp_Object lisp_dpy_name = Qnil;
block_input ();
++x_initialized;
}
+ dpy_name = SSDATA (display_name);
+ if (strlen(dpy_name) == 0 && initial_display != NULL)
+ dpy_name = initial_display;
+ lisp_dpy_name = build_string (dpy_name);
+
{
#define NUM_ARGV 10
int argc;
if (x_initialized++ > 1)
{
- xg_display_open (SSDATA (display_name), &dpy);
+ xg_display_open (dpy_name, &dpy);
}
else
{
argc = 0;
argv[argc++] = initial_argv[0];
- if (strlen(SSDATA(display_name)) != 0)
+ if (strlen(dpy_name) != 0)
{
argv[argc++] = display_opt;
- argv[argc++] = SSDATA (display_name);
+ argv[argc++] = dpy_name;
}
argv[argc++] = name_opt;
xg_initialize ();
dpy = DEFAULT_GDK_DISPLAY ();
+
+ initial_display = g_strdup (gdk_display_get_name(dpy));
+ dpy_name = initial_display;
+ lisp_dpy_name = build_string(dpy_name);
}
}
struct pgtk_display_info *share;
for (share = x_display_list; share; share = share->next)
- if (same_x_server (SSDATA (XCAR (share->name_list_element)),
- SSDATA (display_name)))
+ if (same_x_server (SSDATA (XCAR (share->name_list_element)), dpy_name))
break;
if (share)
terminal->kboard = share->terminal->kboard;
dpyinfo->next = x_display_list;
x_display_list = dpyinfo;
- dpyinfo->name_list_element = Fcons (display_name, Qnil);
+ dpyinfo->name_list_element = Fcons (lisp_dpy_name, Qnil);
dpyinfo->gdpy = dpy;
/* https://lists.gnu.org/r/emacs-devel/2015-11/msg00194.html */
dpyinfo->smallest_char_width = 1;
/* Set the name of the terminal. */
- terminal->name = xlispstrdup (display_name);
+ terminal->name = xlispstrdup (lisp_dpy_name);
Lisp_Object system_name = Fsystem_name ();
ptrdiff_t nbytes;