From 2b047abea6b665851a605f1d894b5ea8ea51b543 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Mon, 4 May 2009 01:47:29 +0200 Subject: [PATCH] Use the XINERAMA support in portable-clx instead of parsing xdpyinfo's output. This only works for portable-clx! --- screen.lisp | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/screen.lisp b/screen.lisp index 19eebdb..94048da 100644 --- a/screen.lisp +++ b/screen.lisp @@ -478,36 +478,23 @@ FOCUS-WINDOW is an extra window used for _NET_SUPPORTING_WM_CHECK." ;;; Head functions -(defun head-by-number (screen n) - (find n (screen-heads screen) :key 'head-number)) - -(defun parse-xinerama-head (line) - (ppcre:register-groups-bind (('parse-integer number width height x y)) - ("^ +head #([0-9]+): ([0-9]+)x([0-9]+) @ ([0-9]+),([0-9]+)" line :sharedp t) - (handler-case - (make-head :number number - :x x :y y - :width width - :height height) - (parse-error () - nil)))) - (defun make-screen-heads (screen root) "or use xdpyinfo to query the xinerama extension, if it's enabled." (or (and (xlib:query-extension *display* "XINERAMA") + (xinerama:xinerama-is-active *display*) (with-current-screen screen - ;; Ignore 'clone' heads. (loop - for i = 0 then (1+ i) - for h in - (delete-duplicates - (loop for i in (split-string (run-shell-command "xdpyinfo -ext XINERAMA" t)) - for head = (parse-xinerama-head i) - when head - collect head) - :test #'frames-overlap-p) - do (setf (head-number h) i) - collect h))) + for screen in (xinerama:xinerama-query-screens *display*) + for head = (make-head :number (xinerama:screen-info-number screen) + :x (xinerama:screen-info-x screen) + :y (xinerama:screen-info-y screen) + :width (xinerama:screen-info-width screen) + :height (xinerama:screen-info-height screen)) + when (notany (lambda (frame) + (frames-overlap-p head frame)) + heads) + collect head into heads + finally (return heads)))) (list (make-head :number 0 :x 0 :y 0 :width (xlib:drawable-width root) @@ -518,7 +505,6 @@ FOCUS-WINDOW is an extra window used for _NET_SUPPORTING_WM_CHECK." "Return a copy of screen's heads." (mapcar 'copy-frame (screen-heads screen))) - ;; Determining a frame's head based on position probably won't ;; work with overlapping heads. Would it be better to walk ;; up the frame tree?