From: Stefan Monnier <monnier@iro.umontreal.ca>
To: chad <yandros@gmail.com>
Cc: Max Nikulin <manikulin@gmail.com>, emacs-devel@gnu.org
Subject: Re: How to get DISPLAY of emacsclient?
Date: Tue, 29 Nov 2022 21:44:02 -0500 [thread overview]
Message-ID: <jwvfse1cglq.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAO2hHWbHuUXv1ZV4gHnp7gg08qdceURpWwvbQQx8W53hGNK0vQ@mail.gmail.com> (chad's message of "Tue, 29 Nov 2022 19:41:11 -0500")
chad [2022-11-29 19:41:11] wrote:
> On Tue, Nov 29, 2022 at 1:11 PM Max Nikulin <manikulin@gmail.com> wrote:
>> [...]
>> Add to user notes content of X selection when emacs is started as
>> daemong with no frames and the user prefers to avoid distraction due to
>> creation of a new frame.
> In general, you seem to assume that there's no way for emacs to create a
> new X11 frame object without it being immediately visible to the user. In
> my experience, that's only true in the limited subset of cases where the
> user has chosen a window manager that enforces that choice. Further, that
> wasn't the default when I last looked -- but that was quite some time ago,
> and I don't know about the current options/defaults for common X11-based
> display systems of today. Can anyone shed some light on this?
`xclip.el` (from GNU ELPA) uses:
(defun xclip--hidden-frame ()
(or xclip--hidden-frame
(setq xclip--hidden-frame
(make-frame-on-display (getenv "DISPLAY")
'((visibility . nil)
(user-position . t)
(left . 0)
(top . 0)
(no-other-frame . t))))))
I haven't heard of a problem with that yet, but it probably hasn't been
widely tested (and it is specific to X11).
> This is a fundamentally different case from "the user wants to use a
> non-graphical X11-based mechanism that emacs normally doesn't enable until
> emacs actually connects to a working X11 display", and I think it should be
> possible to get emacs to make that connection without necessarily popping
> up a window that the user doesn't want.
server.el also does something similar to xclip-mode, tho with simpler
code:
(defun server-select-display (display)
;; If the current frame is on `display' we're all set.
;; Similarly if we are unable to open frames on other displays, there's
;; nothing more we can do.
(unless (or (not (fboundp 'make-frame-on-display))
(server--on-display-p (selected-frame) display))
;; Otherwise, look for an existing frame there and select it.
(dolist (frame (frame-list))
(when (server--on-display-p frame display)
(select-frame frame)))
;; If there's no frame on that display yet, create and select one.
(unless (server--on-display-p (selected-frame) display)
(let* ((buffer (generate-new-buffer " *server-dummy*"))
(frame (make-frame-on-display
display
;; Make it display (and remember) some dummy buffer, so
;; we can detect later if the frame is in use or not.
`((server-dummy-buffer . ,buffer)
;; This frame may be deleted later (see
;; server-unselect-display) so we want it to be as
;; unobtrusive as possible.
(visibility . nil)))))
(select-frame frame)
(set-window-buffer (selected-window) buffer)
frame))))
This code has been used a lot more widely, but in many/most cases we end
up making that frame visible soon after, so there might be cases where
it is not 100% unobtrusive but users don't notice it.
Stefan
next prev parent reply other threads:[~2022-11-30 2:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 15:17 How to get DISPLAY of emacsclient? Max Nikulin
2022-11-25 16:57 ` Stefan Monnier
2022-11-26 3:36 ` Max Nikulin
2022-11-26 21:33 ` chad
2022-11-27 11:34 ` Max Nikulin
2022-11-27 13:42 ` Gregory Heytings
2022-11-27 14:23 ` Max Nikulin
2022-11-27 14:38 ` Gregory Heytings
2022-11-27 15:26 ` Max Nikulin
2022-11-27 16:12 ` Gregory Heytings
2022-11-28 1:19 ` Po Lu
2022-11-27 20:36 ` Jim Porter
2022-11-28 15:33 ` Max Nikulin
2022-11-28 17:15 ` Gregory Heytings
2022-11-28 18:19 ` Stefan Monnier
2022-11-29 16:23 ` Max Nikulin
2022-11-30 0:41 ` chad
2022-11-30 2:44 ` Stefan Monnier [this message]
2022-11-30 12:47 ` Max Nikulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvfse1cglq.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=manikulin@gmail.com \
--cc=yandros@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.