From 23bc3eecc83c1ae63cfcd768574d064704d04bfd Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Wed, 31 Jul 2013 17:01:07 +0200 Subject: [PATCH] Use x-drawable-width/height of *root* instead of xlib:screen-width/height to get the screen size --- src/clfswm-corner.lisp | 8 ++++---- src/clfswm-expose-mode.lisp | 4 ++-- src/clfswm-fastswitch-mode.lisp | 10 +++++----- src/clfswm-info.lisp | 4 ++-- src/clfswm-internal.lisp | 20 ++++++++++---------- src/clfswm-placement.lisp | 4 ++-- src/clfswm-query.lisp | 2 +- src/clfswm-util.lisp | 8 ++++---- src/clfswm.lisp | 8 ++++---- src/netwm-util.lisp | 4 ++-- src/xlib-util.lisp | 8 ++++++++ 11 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/clfswm-corner.lisp b/src/clfswm-corner.lisp index 2ac28df..9c1597c 100644 --- a/src/clfswm-corner.lisp +++ b/src/clfswm-corner.lisp @@ -27,8 +27,8 @@ -(symbol-macrolet ((sw (xlib:screen-width *screen*)) - (sh (xlib:screen-height *screen*)) +(symbol-macrolet ((sw (screen-width)) + (sh (screen-height)) (cs *corner-size*)) (defun in-corner (corner x y) "Return t if (x, y) is in corner. @@ -44,8 +44,8 @@ Corner is one of :bottom-right :bottom-left :top-right :top-left" (<= ymin y ymax))))) -(symbol-macrolet ((sw (xlib:screen-width *screen*)) - (sh (xlib:screen-height *screen*)) +(symbol-macrolet ((sw (screen-width)) + (sh (screen-height)) (cs *corner-size*)) (defun find-corner (x y) (cond ((and (< cs x (- sw cs)) (< cs y (- sh cs))) nil) diff --git a/src/clfswm-expose-mode.lisp b/src/clfswm-expose-mode.lisp index f4354ba..22c52f8 100644 --- a/src/clfswm-expose-mode.lisp +++ b/src/clfswm-expose-mode.lisp @@ -141,8 +141,8 @@ *expose-child-list* (expose-associate-keys) *expose-selected-child* nil *query-string* "") - (xlib:warp-pointer *root* (truncate (/ (xlib:screen-width *screen*) 2)) - (truncate (/ (xlib:screen-height *screen*) 2))) + (xlib:warp-pointer *root* (truncate (/ (screen-width) 2)) + (truncate (/ (screen-height) 2))) (add-hook *query-key-press-hook* 'expose-query-key-press-hook) (add-hook *query-button-press-hook* 'expose-query-button-press-hook)) diff --git a/src/clfswm-fastswitch-mode.lisp b/src/clfswm-fastswitch-mode.lisp index ea1eb37..c74d2d5 100644 --- a/src/clfswm-fastswitch-mode.lisp +++ b/src/clfswm-fastswitch-mode.lisp @@ -71,13 +71,13 @@ (child-fullname (expose-child-child ex-child))) (incf posx (1+ (length (child-fullname (expose-child-child ex-child)))))) (when (> (* posx (xlib:max-char-width *fastswitch-font*)) - (xlib:drawable-width *fastswitch-window*)) + (x-drawable-width *fastswitch-window*)) (if *fastswitch-adjust-window-p* (setf posx 1 posy (1+ posy)) (return))))))) (adjust-window () - (setf (xlib:drawable-height *fastswitch-window*) (* (xlib:font-ascent *fastswitch-font*) 3)) + (setf (x-drawable-height *fastswitch-window*) (* (xlib:font-ascent *fastswitch-font*) 3)) (let ((posx 1)) (dolist (ex-child *fastswitch-match-child*) (when (or *fastswitch-show-frame-p* (not (frame-p (expose-child-child ex-child)))) @@ -85,9 +85,9 @@ (incf posx) (incf posx (1+ (length (child-fullname (expose-child-child ex-child))))) (when (> (* posx (xlib:max-char-width *fastswitch-font*)) - (xlib:drawable-width *fastswitch-window*)) + (x-drawable-width *fastswitch-window*)) (setf posx 1) - (incf (xlib:drawable-height *fastswitch-window*) (xlib:font-ascent *fastswitch-font*)))))))) + (incf (x-drawable-height *fastswitch-window*) (xlib:font-ascent *fastswitch-font*)))))))) (when *fastswitch-adjust-window-p* (adjust-window)) (clear-pixmap-buffer *fastswitch-window* *fastswitch-gc*) @@ -106,7 +106,7 @@ (setf *fastswitch-font* (xlib:open-font *display* *fastswitch-font-string*) *fastswitch-string* "" *fastswitch-match-child* (string-match *fastswitch-string* *expose-child-list* #'expose-child-key)) - (let* ((width (- (xlib:screen-width *screen*) 2)) + (let* ((width (- (screen-width) 2)) (height (* (xlib:font-ascent *fastswitch-font*) 3))) (with-placement (*fastswitch-mode-placement* x y width height) (setf *fastswitch-window* (xlib:create-window :parent *root* diff --git a/src/clfswm-info.lisp b/src/clfswm-info.lisp index 46be718..836ce43 100644 --- a/src/clfswm-info.lisp +++ b/src/clfswm-info.lisp @@ -317,10 +317,10 @@ Or ((1_word color) (2_word color) 3_word (4_word color)...)" (ilh (+ (xlib:max-char-ascent font) (xlib:max-char-descent font) 1)) (width (or width (min (* (+ (loop for l in info-list maximize (compute-size l)) 2) ilw) - (xlib:screen-width *screen*)))) + (screen-width)))) (height (or height (min (round (+ (* (length info-list) ilh) (/ ilh 2))) - (xlib:screen-height *screen*))))) + (screen-height))))) (with-placement (*info-mode-placement* x y width height) (let* ((window (xlib:create-window :parent *root* :x x :y y diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index f56de6b..73dbcd8 100644 --- a/src/clfswm-internal.lisp +++ b/src/clfswm-internal.lisp @@ -1,4 +1,4 @@ -;; -------------------------------------------------------------------------- +;;; -------------------------------------------------------------------------- ;;; CLFSWM - FullScreen Window Manager ;;; ;;; -------------------------------------------------------------------------- @@ -762,7 +762,7 @@ (unless (get-root-list) (let ((frame (create-frame))) (add-frame frame *root-frame*) - (define-as-root frame 0 0 (xlib:screen-width *screen*) (xlib:screen-height *screen*)) + (define-as-root frame 0 0 (screen-width) (screen-height)) (add-frame (create-frame) frame)))) @@ -850,9 +850,9 @@ XINERAMA version 1.1 opcode: 150 (defun place-frames-from-xinerama-infos () "Place frames according to xdpyinfo/xinerama informations" - (let ((sizes (get-connected-heads-size)) - (width (xlib:screen-width *screen*)) - (height (xlib:screen-height *screen*))) + (let ((sizes (get-connected-heads-size t)) ;;; PHIL: remove here + (width (screen-width)) + (height (screen-height))) (labels ((update-root-geometry () (loop for size in sizes for root in (get-root-list) @@ -1020,8 +1020,8 @@ XINERAMA version 1.1 opcode: 150 (funcall it child parent) (no-layout child parent)) (values (- (child-border-size child)) (- (child-border-size child)) - (xlib:screen-width *screen*) - (xlib:screen-height *screen*))) + (screen-width) + (screen-height))) (values (x-drawable-x child) (x-drawable-y child) (x-drawable-width child) (x-drawable-height child))))) @@ -1625,8 +1625,8 @@ managed." (defun store-root-background () (with-all-mapped-windows *screen* #'hide-window) - (setf *background-image* (xlib:create-pixmap :width (xlib:screen-width *screen*) - :height (xlib:screen-height *screen*) + (setf *background-image* (xlib:create-pixmap :width (screen-width) + :height (screen-height) :depth (xlib:screen-root-depth *screen*) :drawable *root*) *background-gc* (xlib:create-gcontext :drawable *background-image* @@ -1635,7 +1635,7 @@ managed." :font *default-font* :line-style :solid)) (xlib:copy-area *root* *background-gc* - 0 0 (xlib:screen-width *screen*) (xlib:screen-height *screen*) + 0 0 (screen-width) (screen-height) *background-image* 0 0) (with-all-mapped-windows *screen* #'unhide-window)) diff --git a/src/clfswm-placement.lisp b/src/clfswm-placement.lisp index cb8efb8..d777d66 100644 --- a/src/clfswm-placement.lisp +++ b/src/clfswm-placement.lisp @@ -61,8 +61,8 @@ ;;; Absolute placement ;;; (defun root-screen-coord (border-size) - (values (- (xlib:screen-width *screen*) (* 2 border-size)) - (- (xlib:screen-height *screen*) (* 2 border-size)))) + (values (- (screen-width) (* 2 border-size)) + (- (screen-height) (* 2 border-size)))) (defmacro with-root-screen-coord ((border-size w h) &body body) `(multiple-value-bind (,w ,h) diff --git a/src/clfswm-query.lisp b/src/clfswm-query.lisp index e250ee7..091eda5 100644 --- a/src/clfswm-query.lisp +++ b/src/clfswm-query.lisp @@ -150,7 +150,7 @@ (defun query-enter-function () (setf *query-font* (xlib:open-font *display* *query-font-string*)) - (let ((width (- (xlib:screen-width *screen*) 2)) + (let ((width (- (screen-width) 2)) (height (* 3 (+ (xlib:max-char-ascent *query-font*) (xlib:max-char-descent *query-font*))))) (with-placement (*query-mode-placement* x y width height) (setf *query-window* (xlib:create-window :parent *root* diff --git a/src/clfswm-util.lisp b/src/clfswm-util.lisp index 4521c0c..2d24a98 100644 --- a/src/clfswm-util.lisp +++ b/src/clfswm-util.lisp @@ -493,7 +493,7 @@ Write (defparameter *contrib-dir* \"/usr/local/lib/clfswm/\") in ~A.~%" (font (xlib:open-font *display* *identify-font-string*)) (window (xlib:create-window :parent *root* :x 0 :y 0 - :width (- (xlib:screen-width *screen*) (* *border-size* 2)) + :width (- (screen-width) (* *border-size* 2)) :height (* 5 (+ (xlib:max-char-ascent font) (xlib:max-char-descent font))) :background (get-color *identify-background*) :border-width *border-size* @@ -577,7 +577,7 @@ Write (defparameter *contrib-dir* \"/usr/local/lib/clfswm/\") in ~A.~%" (let ((ret (info-mode (expand-newline (append (ensure-list (format nil "> ~A" form)) (ensure-list printed-result) (ensure-list result))) - :width (- (xlib:screen-width *screen*) 2)))) + :width (- (screen-width) 2)))) (when (or (search "defparameter" form :test #'string-equal) (search "defvar" form :test #'string-equal)) (let ((elem (split-string form))) @@ -1662,7 +1662,7 @@ For window: set current child to window or its parent according to window-parent (reset-if-moved x y) (setf minx x) (add-in-history x y) - (setf lx (middle minx (or maxx (xlib:screen-width *screen*)))) + (setf lx (middle minx (or maxx (screen-width)))) (xlib:warp-pointer *root* lx y))) (defun speed-mouse-up () "Speed move mouse to up" @@ -1678,7 +1678,7 @@ For window: set current child to window or its parent according to window-parent (reset-if-moved x y) (setf miny y) (add-in-history x y) - (setf ly (middle miny (or maxy (xlib:screen-height *screen*)))) + (setf ly (middle miny (or maxy (screen-height)))) (xlib:warp-pointer *root* x ly))) (defun speed-mouse-undo () "Undo last speed mouse move" diff --git a/src/clfswm.lisp b/src/clfswm.lisp index 090decd..ba8314b 100644 --- a/src/clfswm.lisp +++ b/src/clfswm.lisp @@ -124,8 +124,8 @@ (define-handler main-mode :enter-notify (window root-x root-y) - (unless (and (> root-x (- (xlib:screen-width *screen*) 3)) - (> root-y (- (xlib:screen-height *screen*) 3))) + (unless (and (> root-x (- (screen-width) 3)) + (> root-y (- (screen-height) 3))) (manage-focus window root-x root-y))) @@ -198,8 +198,8 @@ *root* (xlib:screen-root *screen*) *no-focus-window* (xlib:create-window :parent *root* :x 0 :y 0 :width 1 :height 1) *default-font* (xlib:open-font *display* *default-font-string*) - *pixmap-buffer* (xlib:create-pixmap :width (xlib:screen-width *screen*) - :height (xlib:screen-height *screen*) + *pixmap-buffer* (xlib:create-pixmap :width (screen-width) + :height (screen-height) :depth (xlib:screen-root-depth *screen*) :drawable *root*) *in-second-mode* nil diff --git a/src/netwm-util.lisp b/src/netwm-util.lisp index 71689c2..ff747f3 100644 --- a/src/netwm-util.lisp +++ b/src/netwm-util.lisp @@ -49,8 +49,8 @@ ;; (xlib:change-property *root* :_NET_NUMBER_OF_DESKTOPS ;; (list (length *workspace-list*)) :cardinal 32) ;; (xlib:change-property *root* :_NET_DESKTOP_GEOMETRY - ;; (list (xlib:screen-width *screen*) - ;; (xlib:screen-height *screen*)) + ;; (list (screen-width) + ;; (screen-height)) ;; :cardinal 32) ;; (xlib:change-property *root* :_NET_DESKTOP_VIEWPORT ;; (list 0 0) :cardinal 32) diff --git a/src/xlib-util.lisp b/src/xlib-util.lisp index 1e305ba..b70f654 100644 --- a/src/xlib-util.lisp +++ b/src/xlib-util.lisp @@ -103,6 +103,14 @@ Features: ~A" ;; `(progn ;; ,@body)) +(defun screen-width () + ;;(xlib:screen-width *screen*)) + (x-drawable-width *root*)) + +(defun screen-height () + ;;(xlib:screen-height *screen*)) + (x-drawable-height *root*)) + (defmacro with-x-pointer (&body body) -- 2.11.4.GIT