emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/posframe f7ce740 1/3: * posframe.el (posframe-parent-fr


From: ELPA Syncer
Subject: [elpa] externals/posframe f7ce740 1/3: * posframe.el (posframe-parent-frame-poshandler-xwininfo): tiny refact.
Date: Thu, 8 Apr 2021 05:57:13 -0400 (EDT)

branch: externals/posframe
commit f7ce74052a53c1434c9f3c1d72815e3ba7c0da67
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    * posframe.el (posframe-parent-frame-poshandler-xwininfo): tiny refact.
---
 posframe.el | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/posframe.el b/posframe.el
index 58292e6..5cea285 100644
--- a/posframe.el
+++ b/posframe.el
@@ -1367,23 +1367,26 @@ bottom center.  The structure of INFO can be found in 
docstring of
 
 (defun posframe-parent-frame-poshandler-xwininfo ()
   "Parent frame poshander function.
-Get the position of currentframe with the help of xwininfo."
-  (with-temp-buffer
-    (let ((case-fold-search nil))
-      (call-process shell-file-name nil t nil shell-command-switch
-                   (format "xwininfo -display %s -id %s"
-                           (frame-parameter nil 'display)
-                           (frame-parameter nil 'window-id)))
-      (goto-char (point-min))
-      (search-forward "\n  Absolute")
-      (cons (string-to-number
-             (buffer-substring-no-properties
-             (search-forward "X: ")
-             (line-end-position)))
-           (string-to-number
-             (buffer-substring-no-properties
-             (search-forward "Y: ")
-             (line-end-position)))))))
+Get the position of parent frame (current frame) with the help of
+xwininfo."
+  (when (executable-find "xwininfo")
+    (with-temp-buffer
+      (let ((case-fold-search nil)
+            (args (format "xwininfo -display %s -id %s"
+                         (frame-parameter nil 'display)
+                         (frame-parameter nil 'window-id))))
+        (call-process shell-file-name nil t nil shell-command-switch args)
+        (goto-char (point-min))
+        (search-forward "Absolute upper-left")
+        (let ((x (string-to-number
+                  (buffer-substring-no-properties
+                  (search-forward "X: ")
+                  (line-end-position))))
+              (y (string-to-number
+                  (buffer-substring-no-properties
+                  (search-forward "Y: ")
+                  (line-end-position)))))
+          (cons x y))))))
 
 
 (provide 'posframe)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]