diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index 61fd5dcd608e591973241d3978b14cfd60bbad12..14f628c6ee692486e763952fa6c078238563f8f8 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 c874b09695518337e56db3d47e659aa6e3937e5e..5b32fd6f241489e4f7a18b0ee3fe6aef7434cd90 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)