anchor.diff:               (rplacd ,asc #',fn)
                (push (cons ,sc #',fn) *shortcuts*))))))
   
  -(defun move (window &key x y width height)
  -  "Move a window."
  -  (with-state (window)
  -    (when x (setf (drawable-x window) x))
  -    (when y (setf (drawable-y window) y))
  -    (when width (setf (drawable-width window) width))
  -    (when height (setf (drawable-height window) height))))
  +(defun move (window &key x y width height dx dy dw dh)
  +  "Move a window with respect to sizehints. Returns effective size
  +values."
  +  (let ((hints (wm-normal-hints window)))
  +    (when hints (let* ((min-w (or (wm-size-hints-min-width hints) 1))
  +                       (min-h (or (wm-size-hints-min-height hints) 1))
  +                       (inc-w (or (wm-size-hints-width-inc hints) 1))
  +                       (inc-h (or (wm-size-hints-height-inc hints) 1))
  +                       (base-w (or (wm-size-hints-base-width hints) 1))
  +                       (base-h (or (wm-size-hints-base-height hints) 1)))
  +                  (when x (setf x (* inc-w (truncate x inc-w))))
  +                  (when y (setf y (* inc-h (truncate y inc-h))))
  +                  (when width
  +                    (decf width base-w)
  +                    (setf width (max min-w (+ (* inc-w (truncate width inc-w)) base-w))))
  +                  (when height
  +                    (decf height base-h)
  +                    (setf height (max min-h (+ (* inc-h (truncate height inc-h)) base-h))))
  +                  (when dx (setf dx (* inc-w (truncate dx inc-w))))
  +                  (when dy (setf dy (* inc-h (truncate dy inc-h))))
  +                  (when dh (setf dh (* inc-h (truncate dh inc-h))))
  +                  (when dw (setf dw (* inc-w (truncate dw inc-w))))))
  +    (with-state (window)
  +      (when x (setf (drawable-x window) x))
  +      (when y (setf (drawable-y window) y))
  +      (when width (setf (drawable-width window) width))
  +      (when height (setf (drawable-height window) height))
  +      (when dx (incf (drawable-x window) dx))
  +      (when dy (incf (drawable-y window) dy))
  +      (when dw (incf (drawable-width window) dw))
  +      (when dh (incf (drawable-height window) dh)))
  +    (values x y width height dx dy dw dh)))
   
   (defun memove (window &optional x y w h)
     "Memory Move a window (i.e. toggle between current position and the
  
positive.code:            (grab-mouse *root* nil)
             (setf waiting-shortcut t)))))
  
  (defun 1-o-value (val) "Replace nil with one." (if (null val) 1 val))
  (defun 0-o-value (val) "Replace nil with zero." (if (null val) 0 val))
  
  (defun size-w/hints (window width height)
    (let ((hints (wm-normal-hints window)))
      (cond (hints (let* ((min-w (1-o-value (wm-size-hints-min-width hints)))
                          (min-h (1-o-value (wm-size-hints-min-height hints)))
                          (inc-w (1-o-value (wm-size-hints-width-inc hints)))
                          (inc-h (1-o-value (wm-size-hints-height-inc hints)))
                          (base-w (1-o-value (wm-size-hints-base-width hints)))
                          (base-h (1-o-value (wm-size-hints-base-height hints)))
                          (baseismin (and (= base-w min-w) (= base-h min-h))))
                     (when baseismin
                       (decf width base-w)
                       (decf height base-h))
                     (let ((new-w (max min-w (+ (* inc-w (truncate width inc-w)) base-w)))
                           (new-h (max min-h (+ (* inc-h (truncate height inc-h)) base-h))))
                       (values new-w new-h))))
            (t (values (max 1 width) (max 1 height))))))
  
  (defun position-w/hints (window x y)
    (let ((hints (wm-normal-hints window)))
      (cond (hints (let ((inc-w (1-o-value (wm-size-hints-width-inc hints)))
                         (inc-h (1-o-value (wm-size-hints-height-inc hints))))
                     (values (* inc-w (truncate x inc-w)) (* inc-h (truncate y inc-h)))))
            (t (values x y)))))
  
  (defhandler :button-press (state code child x y)
    (when (and child (eql (window-override-redirect child) :off)
  
negative.code:            (focus child)
             (grab-mouse child '(:pointer-motion :button-release))
             (when (sc= *resize* state code)
               (multiple-value-bind (x y width height)
                   (move child :width (drawable-width child)
                               :height (drawable-height child))
                 (warp-pointer child width height)))
             (setf last-x x
                   last-y y)))))
  
  (defhandler :motion-notify (event-window root-x root-y time)
    (when (or (null last-motion) (> (- time last-motion) (/ 1000 60)))
      (cond ((= last-button (code *move*))
             (let ((delta-x (- root-x last-x))
                   (delta-y (- root-y last-y)))
               (multiple-value-bind (x y width height dx dy dw dh)
                   (move event-window :dx delta-x :dy delta-y)
                 (incf last-x dx)
                 (incf last-y dy))))
            ((= last-button (code *resize*))
             (move event-window :width (- root-x (drawable-x event-window))
                                :height (- root-y (drawable-y event-window)))))
      (setf last-motion time)))
  
  (defhandler :button-release () (ungrab-mouse))
  