From: Philippe Brochard Date: Fri, 5 Apr 2013 20:00:55 +0000 (+0200) Subject: Move mouse pointer only when needed on :sloppy-select-window focus policy X-Git-Url: https://repo.or.cz/w/clfswm.git/commitdiff_plain/19066cc758594c65add4494e8117bbaf6c1a0b0f Move mouse pointer only when needed on :sloppy-select-window focus policy --- diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index 61fd5dc..14f628c 100644 --- a/src/clfswm-internal.lisp +++ b/src/clfswm-internal.lisp @@ -1668,3 +1668,39 @@ managed." (frame-selected-pos parent) 0))) +(defun manage-focus (window root-x root-y) + (case (if (frame-p (current-child)) + (frame-focus-policy (current-child)) + *default-focus-policy*) + (:sloppy (focus-window window)) + (:sloppy-strict (when (and (frame-p (current-child)) + (child-member window (frame-child (current-child)))) + (focus-window window))) + (:sloppy-select (let* ((child (find-child-under-mouse root-x root-y)) + (parent (find-parent-frame child))) + (unless (or (child-root-p child) + (child-equal-p (typecase child + (xlib:window parent) + (t child)) + (current-child))) + (focus-all-children child parent) + (show-all-children)))) + (:sloppy-select-window (let* ((child (find-child-under-mouse root-x root-y)) + (parent (find-parent-frame child)) + (need-warp-pointer (not (or (frame-p child) + (child-equal-p child (frame-selected-child parent)))))) + (unless (child-root-p child) + (when (focus-all-children child parent) + (show-all-children) + (when (and need-warp-pointer + (not (eql (frame-data-slot (current-child) :tile-layout-keep-position) + :yes))) + (typecase child + (xlib:window (xlib:warp-pointer *root* + (truncate (+ (x-drawable-x child) + (/ (x-drawable-width child) 2))) + (truncate (+ (x-drawable-y child) + (/ (x-drawable-height child) 2))))) + (frame (xlib:warp-pointer *root* + (+ (frame-rx child) 10) + (+ (frame-ry child) 10))))))))))) \ No newline at end of file diff --git a/src/clfswm.lisp b/src/clfswm.lisp index c874b09..5b32fd6 100644 --- a/src/clfswm.lisp +++ b/src/clfswm.lisp @@ -123,39 +123,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))) - (case (if (frame-p (current-child)) - (frame-focus-policy (current-child)) - *default-focus-policy*) - (:sloppy (focus-window window)) - (:sloppy-strict (when (and (frame-p (current-child)) - (child-member window (frame-child (current-child)))) - (focus-window window))) - (:sloppy-select (let* ((child (find-child-under-mouse root-x root-y)) - (parent (find-parent-frame child))) - (unless (or (child-root-p child) - (child-equal-p (typecase child - (xlib:window parent) - (t child)) - (current-child))) - (focus-all-children child parent) - (show-all-children)))) - (:sloppy-select-window (let* ((child (find-child-under-mouse root-x root-y)) - (parent (find-parent-frame child)) - (need-warp-pointer (not (or (frame-p child) - (child-equal-p child (frame-selected-child parent)))))) - (unless (child-root-p child) - (when (focus-all-children child parent) - (show-all-children) - (when need-warp-pointer - (typecase child - (xlib:window (xlib:warp-pointer *root* - (truncate (+ (x-drawable-x child) - (/ (x-drawable-width child) 2))) - (truncate (+ (x-drawable-y child) - (/ (x-drawable-height child) 2))))) - (frame (xlib:warp-pointer *root* - (+ (frame-rx child) 10) - (+ (frame-ry child) 10)))))))))))) + (manage-focus window root-x root-y))) + (define-handler main-mode :exposure (window) (awhen (find-frame-window window)