##Merge of all patches applied from revision 118094 ## patch-r118037: * lisp/avoid.el: Allow setting in which corner banish move the mouse. ## patch-r118084: * lisp/avoid.el (mouse-avoidance-banish-distance-from-edge): Allow banishing mouse in frame or window corner. ## diff --git a/lisp/avoid.el b/lisp/avoid.el --- a/lisp/avoid.el +++ b/lisp/avoid.el @@ -115,6 +115,23 @@ :type 'integer :group 'avoid) +(defcustom mouse-avoidance-banish-destination '(right . top) + "Position to which Mouse Avoidance mode `banish' moves the mouse. + +Valid possible values can be: +\'(right . top\), \'(left . top\), \'(right . bottom\) or \'(left . bottom\)." + :group 'avoid + :type 'list) + +(defcustom mouse-avoidance-banish-distance-from-edge '(window . 2) + "Distance from edge of window or frame in Mouse Avoidance mode `banish'. + +It is a cons cell where the car can be 'window or 'frame +and the cdr and integer representing the distance +from edge of window or frame." + :group 'avoid + :type 'list) + ;; Internal variables (defvar mouse-avoidance-state nil) (defvar mouse-avoidance-pointer-shapes nil) @@ -183,10 +200,24 @@ (defun mouse-avoidance-banish-destination () "The position to which Mouse Avoidance mode `banish' moves the mouse. -You can redefine this if you want the mouse banished to a different corner." - (let* ((pos (window-edges))) - (cons (- (nth 2 pos) 2) - (nth 1 pos)))) + +If you want the mouse banished to a different corner set +`mouse-avoidance-banish-destination' and +`mouse-avoidance-banish-distance-from-edge' as you need." + (let* ((fra-or-win (case (car mouse-avoidance-banish-distance-from-edge) + (frame (list 0 0 (frame-width) (frame-height))) + (window (window-edges)))) + (pos (loop for v in fra-or-win + for k in '(left top right bottom) + collect (cons k v))) + (side (car mouse-avoidance-banish-destination)) + (up-down (cdr mouse-avoidance-banish-destination)) + (fn (case side + (left '+) + (right '-)))) + (cons (funcall fn (assoc-default side pos 'eq) + (cdr mouse-avoidance-banish-distance-from-edge)) + (assoc-default up-down pos 'eq)))) (defun mouse-avoidance-banish-mouse () ;; Put the mouse pointer in the upper-right corner of the current frame.