Do not steal the focus on focus-in
authorRenaud Casenave-Pere <renaud@casenave-pere.fr>
Fri, 13 Dec 2013 22:28:33 +0000 (13 23:28 +0100)
committerPhilippe Brochard <pbrochard@common-lisp.net>
Fri, 13 Dec 2013 22:28:33 +0000 (13 23:28 +0100)
src/clfswm.lisp
src/xlib-util.lisp

index 3b6545a..0853644 100644 (file)
     (manage-focus window root-x root-y)))
 
 
+(define-handler main-mode :focus-in (window)
+  (unless (child-equal-p window (focused-window))
+    (set-focus-to-current-child)))
+
+
+
+
+
 (define-handler main-mode :exposure (window)
   (awhen (find-frame-window window)
     (display-frame-info it)))
index dbe4c2a..8dae671 100644 (file)
@@ -570,15 +570,23 @@ they should be windows. So use this function to make a window out of them."
     (setf (xlib:window-priority window) :above)))
 
 
-(defun no-focus ()
-  "don't focus any window but still read keyboard events."
-  (xlib:set-input-focus *display* *no-focus-window* :pointer-root))
+(let ((focused-window nil))
+  (defun no-focus ()
+    "don't focus any window but still read keyboard events."
+    (xlib:set-input-focus *display* *no-focus-window* :pointer-root)
+    (setf focused-window nil))
+
+  (defun focus-window (window)
+    "Give the window focus."
+    (no-focus)
+    (when (xlib:window-p window)
+      (xlib:set-input-focus *display* window :parent)
+      (setf focused-window window)))
+
+  (defun focused-window ()
+    focused-window))
+
 
-(defun focus-window (window)
-  "Give the window focus."
-  (no-focus)
-  (when (xlib:window-p window)
-    (xlib:set-input-focus *display* window :parent)))
 
 (defun raise-and-focus-window (window)
   "Raise and focus."