Change focus only on mouse move
authorPhilippe Brochard <pbrochard@common-lisp.net>
Fri, 5 Apr 2013 20:35:41 +0000 (22:35 +0200)
committerPhilippe Brochard <pbrochard@common-lisp.net>
Fri, 5 Apr 2013 20:35:41 +0000 (22:35 +0200)
src/clfswm-internal.lisp

index 14f628c..8b1ec3c 100644 (file)
@@ -1668,39 +1668,43 @@ 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
+(let ((lx -1) (ly -1))
+  (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 (or (child-root-p child)
+                                           (= lx root-x) (= ly root-y))
+                                 (setf lx root-x ly root-y)
+                                 (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))))))))))))
+