[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/exwm 84f0f03 15/64: Fix input focus lost after closing

From: Chris Feng
Subject: [elpa] externals/exwm 84f0f03 15/64: Fix input focus lost after closing window
Date: Thu, 17 Sep 2015 23:17:54 +0000

branch: externals/exwm
commit 84f0f0328b173af82c873e395353bd9a6c3bf1f6
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Fix input focus lost after closing window
    Also insert some debug messages.
 exwm-input.el     |   35 +++++++++++++++++++++++++----------
 exwm-layout.el    |    3 +++
 exwm-manage.el    |    6 ++++--
 exwm-workspace.el |    2 ++
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/exwm-input.el b/exwm-input.el
index f94cf50..c312ff7 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -57,17 +57,22 @@ It's updated in several occasions, and only used by 
 (defun exwm-input--set-focus (id)
   "Set input focus to window ID in a proper way."
   (exwm--with-current-id id
+    (exwm--log "Set focus ID to #x%x" id)
     (setq exwm-input--focus-id id)
     (if (and (not exwm--hints-input)
              (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols))
-        (xcb:+request exwm--connection
-            (make-instance 'xcb:icccm:SendEvent
-                           :destination id
-                           :event (xcb:marshal
-                                   (make-instance 'xcb:icccm:WM_TAKE_FOCUS
-                                                  :window id
-                                                  :time exwm-input--timestamp)
-                                   exwm--connection)))
+        (progn
+          (exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id)
+          (xcb:+request exwm--connection
+              (make-instance 'xcb:icccm:SendEvent
+                             :destination id
+                             :event (xcb:marshal
+                                     (make-instance 'xcb:icccm:WM_TAKE_FOCUS
+                                                    :window id
+                                                    :time
+                                                    exwm-input--timestamp)
+                                     exwm--connection))))
+      (exwm--log "Focus on #x%x with SetInputFocus" id)
       (xcb:+request exwm--connection
           (make-instance 'xcb:SetInputFocus
                          :revert-to xcb:InputFocus:Parent :focus id
@@ -85,24 +90,34 @@ It's updated in several occasions, and only used by 
     (setq exwm-input--focus-lock t)
     (when (eq (current-buffer) (window-buffer)) ;e.g. with-temp-buffer
       (if (eq major-mode 'exwm-mode)
-          (progn (setq exwm-input--focus-id exwm--id)
+          (progn (exwm--log "Set focus ID to #x%x" exwm--id)
+                 (setq exwm-input--focus-id exwm--id)
                  (when exwm--floating-frame
                    (if (eq (selected-frame) exwm--floating-frame)
                        ;; Cancel the possible input focus redirection
-                       (redirect-frame-focus exwm--floating-frame nil)
+                       (progn
+                         (exwm--log "Cancel input focus redirection on %s"
+                                    exwm--floating-frame)
+                         (redirect-frame-focus exwm--floating-frame nil))
                      ;; Focus the floating frame
+                     (exwm--log "Focus on floating frame %s"
+                                exwm--floating-frame)
                      (x-focus-frame exwm--floating-frame)))
                  ;; Finally focus the window
                  (exwm-input--set-focus exwm-input--focus-id))
         (exwm--with-current-id exwm-input--focus-id
+          (exwm--log "Set focus ID to #x%x" xcb:Window:None)
           (setq exwm-input--focus-id xcb:Window:None)
           (let ((frame (selected-frame)))
             (if exwm--floating-frame
                 (unless (or (eq frame exwm--floating-frame)
                   ;; Redirect input focus to the workspace frame
+                  (exwm--log "Redirect input focus (%s => %s)"
+                             exwm--floating-frame frame)
                   (redirect-frame-focus exwm--floating-frame frame))
               ;; Focus the workspace frame
+              (exwm--log "Focus on workspace %s" frame)
               (x-focus-frame frame))))))
     (setq exwm-input--focus-lock nil)))
diff --git a/exwm-layout.el b/exwm-layout.el
index 7630b68..1dd8333 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -28,6 +28,7 @@
 (defun exwm-layout--show (id &optional window)
   "Show window ID exactly fit in the Emacs window WINDOW."
+  (exwm--log "Show #x%x in %s" id window)
   (xcb:+request exwm--connection (make-instance 'xcb:MapWindow :window id))
   (xcb:+request exwm--connection
       (make-instance 'xcb:icccm:set-WM_STATE
@@ -69,6 +70,7 @@
   "Hide window ID."
   (unless (eq xcb:icccm:WM_STATE:IconicState ;already hidden
               (with-current-buffer (exwm--id->buffer id) exwm-state))
+    (exwm--log "Hide #x%x" id)
     (xcb:+request exwm--connection
         (make-instance 'xcb:ChangeWindowAttributes
                        :window id :value-mask xcb:CW:EventMask
@@ -162,6 +164,7 @@
   "Refresh layout."
   (unless (compare-window-configurations exwm-layout--window-configuration
+    (exwm--log "Refresh layout")
     (setq exwm-layout--window-configuration (current-window-configuration))
     (let ((frame (selected-frame))
diff --git a/exwm-manage.el b/exwm-manage.el
index 0d2c74f..7c82696 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -178,8 +178,10 @@ corresponding buffer.")
                              :window id :property xcb:Atom:WM_STATE))
           (xcb:flush exwm--connection))
         (setq kill-buffer-query-functions nil)
-        (kill-buffer)
-        (select-frame-set-input-focus exwm-workspace--current)))))
+        (let ((floating exwm--floating-frame))
+          (kill-buffer)
+          (when floating
+            (select-frame-set-input-focus exwm-workspace--current)))))))
 (defun exwm-manage--scan ()
   "Search for existing windows and try to manage them."
diff --git a/exwm-workspace.el b/exwm-workspace.el
index b175543..da3f9ce 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -152,7 +152,9 @@ The optional FORCE option is for internal use only."
   "Fix unexpected frame switch."
   (unless exwm-workspace--switch-lock
     (let ((index (cl-position (selected-frame) exwm-workspace--list)))
+      (exwm--log "Focus on workspace %s" index)
       (when (and index (/= index exwm-workspace-current-index))
+        (exwm--log "Workspace was switched unexpectedly")
         (exwm-workspace-switch index)))))
 (defun exwm-workspace-move-window (index &optional id)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]