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.
This commit is contained in:
Chris Feng 2016-04-07 21:03:42 +08:00
parent c7c233bc35
commit ddbbeda285
2 changed files with 15 additions and 1 deletions

View file

@ -91,7 +91,9 @@
(frame-geometry (frame-parameter original-frame 'exwm-geometry))) (frame-geometry (frame-parameter original-frame 'exwm-geometry)))
(exwm--log "Floating geometry (original, absolute): %dx%d%+d%+d" (exwm--log "Floating geometry (original, absolute): %dx%d%+d%+d"
width height x y) width height x y)
(when frame-geometry (when (and frame-geometry
(/= x 0)
(/= y 0))
(setq x (- x (slot-value frame-geometry 'x)) (setq x (- x (slot-value frame-geometry 'x))
y (- y (slot-value frame-geometry 'y)))) y (- y (slot-value frame-geometry 'y))))
(exwm--log "Floating geometry (original, relative): %dx%d%+d%+d" (exwm--log "Floating geometry (original, relative): %dx%d%+d%+d"

View file

@ -229,6 +229,16 @@ The optional FORCE option is for internal use only."
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
(run-hooks 'exwm-workspace-switch-hook)))) (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-width)
(defvar exwm-floating-border-color) (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) (add-hook 'minibuffer-exit-hook #'exwm-workspace--on-minibuffer-exit)
(run-with-idle-timer 0 t #'exwm-workspace--on-echo-area-dirty) (run-with-idle-timer 0 t #'exwm-workspace--on-echo-area-dirty)
(add-hook 'echo-area-clear-hook #'exwm-workspace--on-echo-area-clear) (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. ;; Create workspace frames.
(dotimes (_ exwm-workspace-number) (dotimes (_ exwm-workspace-number)
(push (make-frame `((window-system . x) (push (make-frame `((window-system . x)