From a9c8a56ba1fdbb6645ddebdabbb826993b6dca23 Mon Sep 17 00:00:00 2001 From: Yuuki Harano Date: Sat, 12 May 2018 23:49:00 +0900 Subject: [PATCH] Fix xdg-open handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * ../src/pgtkterm.c (pgtk_term_init, NUM_ARGV, pgtk_term_init): * ../lisp/net/browse-url.el (browse-url): xdg-open できなかったのを修正。 --- lisp/net/browse-url.el | 13 +++++++++++-- src/pgtkterm.c | 25 ++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 8b245b01066..27a4f1be5ab 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -888,8 +888,17 @@ If ARGS are omitted, the default is to pass ;; 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)))) diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 4f2c4542372..d84e3b1ae54 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -5846,6 +5846,9 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 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 (); @@ -5861,6 +5864,11 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) ++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; @@ -5870,7 +5878,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) if (x_initialized++ > 1) { - xg_display_open (SSDATA (display_name), &dpy); + xg_display_open (dpy_name, &dpy); } else { @@ -5883,10 +5891,10 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 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; @@ -5910,6 +5918,10 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 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); } } @@ -5929,8 +5941,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_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; @@ -5951,7 +5962,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 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 */ @@ -5959,7 +5970,7 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name) 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; -- 2.39.5