about summary refs log tree commit diff
path: root/exwm-workspace.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-04-07T13·03+0800
committerChris Feng <chris.w.feng@gmail.com>2016-04-07T13·03+0800
commitddbbeda285b3b671ace99f1688e6bd3c3f84c742 (patch)
tree54a3824e9f02d6f353464d0eefaeabf34f46213d /exwm-workspace.el
parentc7c233bc356fc6a846a09aa5fb13710e6706fce1 (diff)
Fix 2 multi-monitor issues
* exwm-workspace.el (exwm-workspace--on-focus-in, exwm-workspace--init):
Handle unexpected frame switch in `focus-in-hook'.

* exwm-floating.el (exwm-floating--set-floating): If the absolute position
is (0, 0) then the relative position is also the same.
Diffstat (limited to 'exwm-workspace.el')
-rw-r--r--exwm-workspace.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 8dd6284d1dec..60cf9dd7778f 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -229,6 +229,16 @@ The optional FORCE option is for internal use only."
         (xcb:flush exwm--connection))
       (run-hooks 'exwm-workspace-switch-hook))))
 
+(defun exwm-workspace--on-focus-in ()
+  "Handle unexpected frame switch."
+  ;; `focus-in-hook' is run by `handle-switch-frame'.
+  (unless (eq this-command #'handle-switch-frame)
+    (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)))))
+
 (defvar exwm-floating-border-width)
 (defvar exwm-floating-border-color)
 
@@ -679,6 +689,8 @@ The optional FORCE option is for internal use only."
     (add-hook 'minibuffer-exit-hook #'exwm-workspace--on-minibuffer-exit)
     (run-with-idle-timer 0 t #'exwm-workspace--on-echo-area-dirty)
     (add-hook 'echo-area-clear-hook #'exwm-workspace--on-echo-area-clear)
+    ;; Handle unexpected frame switch.
+    (add-hook 'focus-in-hook #'exwm-workspace--on-focus-in)
     ;; Create workspace frames.
     (dotimes (_ exwm-workspace-number)
       (push (make-frame `((window-system . x)