On 28/10/2022 11:28, Ihor Radchenko wrote:
* lisp/org-clock.el (org-x11idle-exists-p): Do not check if load-time
`window-system' is `x'. Instead, rely on the check in
`org-user-idle-seconds'.
I would say that even there it is not strictly correct to test
`window-system', perhaps `x-display-list' is a bit better since
particular frame may be a terminal one running in xterm, but user has x
frames. In server.el I found
(frame-parameter frame 'display)
that might be even better and should work with daemon having a single
frame in xterm. I can not figure out if --display command line option
affects some variable of Emacs daemon.
Another tricky case is multiple x connection to different displays. It
seems GTK3 have some limitations (pgtk build) and such rarely used
configuration will become completely obsolete.
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e98a34f0d..ca026c44f 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1201,8 +1201,7 @@ (defun org-mac-idle-seconds ()
(defvar org-x11idle-exists-p
;; Check that x11idle exists
- (and (eq window-system 'x)
- (eq 0 (call-process-shell-command
+ (and (eq 0 (call-process-shell-command
(format "command -v %s" org-clock-x11idle-program-name)))
I joined to this discussion presuming (by some confusion) that such
variable should be lazily initialized on first call of
`org-user-idle-seconds'. I considered `window-system' test as a way to
distinguish GUI and text Emacs sessions. Actually such parameter is
dynamic. Remotely running Emacs may be disconnected from one X server
and connected to another session.
Actually `window-system' check has another role: skip command
availability test on systems other than Linux.
What is the result of "command -v" on Windows? Should it be executed
there at all (unconditionally at load time)?
P.S. There are a number of X11 servers for Windows. I am unsure if Emacs
builds for Windows and X11 frames are supported. I am lost how to
properly test such cases in the code.