about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-08-14T04·24+0800
committerChris Feng <chris.w.feng@gmail.com>2016-08-14T04·24+0800
commitfe653ba244758362ac83603a28389660834fcb5a (patch)
treeb4cd6f16e03bd5586744de20afac1a9bb2ee29d9 /exwm-input.el
parent108b3949c26f55cfdb96866dedac3f68c893692f (diff)
Only check input focus for globally active model
* exwm-input.el (exwm-input--set-focus): Partly revert 810b471.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el61
1 files changed, 30 insertions, 31 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 668e49585e55..e5828126f9a3 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -61,38 +61,37 @@
 (defun exwm-input--set-focus (id)
   "Set input focus to window ID in a proper way."
   (when (exwm--id->buffer id)
-    (let ((focus (slot-value (xcb:+request-unchecked+reply exwm--connection
+    (with-current-buffer (exwm--id->buffer id)
+      (cond
+       ((and (not exwm--hints-input)
+             (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols))
+        (when (= (frame-parameter nil 'exwm-id)
+                 (slot-value (xcb:+request-unchecked+reply exwm--connection
                                  (make-instance 'xcb:GetInputFocus))
-                             'focus)))
-      (unless (= focus id)
-        (with-current-buffer (exwm--id->buffer id)
-          (cond
-           ((and (not exwm--hints-input)
-                 (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols))
-            (when (= focus (frame-parameter nil 'exwm-id))
-              (exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id)
-              (exwm-input--update-timestamp
-               (lambda (timestamp id)
-                 (let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS
-                                             :window id
-                                             :time timestamp)))
-                   (setq event (xcb:marshal event exwm--connection))
-                   (xcb:+request exwm--connection
-                       (make-instance 'xcb:icccm:SendEvent
-                                      :destination id
-                                      :event event))
-                   (exwm-input--set-active-window id)
-                   (xcb:flush exwm--connection)))
-               id)))
-           (t
-            (exwm--log "Focus on #x%x with SetInputFocus" id)
-            (xcb:+request exwm--connection
-                (make-instance 'xcb:SetInputFocus
-                               :revert-to xcb:InputFocus:Parent
-                               :focus id
-                               :time xcb:Time:CurrentTime))
-            (exwm-input--set-active-window id)
-            (xcb:flush exwm--connection))))))))
+                             'focus))
+          (exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id)
+          (exwm-input--update-timestamp
+           (lambda (timestamp id)
+             (let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS
+                                         :window id
+                                         :time timestamp)))
+               (setq event (xcb:marshal event exwm--connection))
+               (xcb:+request exwm--connection
+                   (make-instance 'xcb:icccm:SendEvent
+                                  :destination id
+                                  :event event))
+               (exwm-input--set-active-window id)
+               (xcb:flush exwm--connection)))
+           id)))
+       (t
+        (exwm--log "Focus on #x%x with SetInputFocus" id)
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:SetInputFocus
+                           :revert-to xcb:InputFocus:Parent
+                           :focus id
+                           :time xcb:Time:CurrentTime))
+        (exwm-input--set-active-window id)
+        (xcb:flush exwm--connection))))))
 
 (defun exwm-input--update-timestamp (callback &rest args)
   "Fetch the latest timestamp from the server and feed it to CALLBACK.