about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2015-09-25T05·45+0800
committerChris Feng <chris.w.feng@gmail.com>2015-09-25T05·45+0800
commitf685de12d464b334ba7efdfe67e989dd63a96fa0 (patch)
tree17ec717363466ed6ecadd150f8b2d76cc89cda12 /exwm-input.el
parent4ad76b879d2f3807828de5345d5da4cac301415d (diff)
Fix click-to-focus on multi-monitor settings
* exwm-input.el (exwm-input--on-ButtonPress): [click-to-focus] Switch to
  the corresponding workspace if necessary.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 9645182d09..9def8ca565 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -187,8 +187,22 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
              (exwm-floating--start-moveresize event))
             (t
              ;; Click to focus
-             (let ((window (get-buffer-window (exwm--id->buffer event) t)))
+             (let ((window (get-buffer-window (exwm--id->buffer event) t))
+                   frame)
                (unless (eq window (selected-window))
+                 (setq frame (window-frame window))
+                 (unless (eq frame exwm-workspace--current)
+                   (if (memq frame exwm-workspace--list)
+                       ;; The X window is on another workspace
+                       (exwm-workspace-switch
+                        (cl-position frame exwm-workspace--list))
+                     (with-current-buffer (window-buffer window)
+                       (when (and (eq major-mode 'exwm-mode)
+                                  (not (eq exwm--frame
+                                           exwm-workspace--current)))
+                         ;; The floating X window is on another workspace
+                         (exwm-workspace-switch
+                          (cl-position exwm--frame exwm-workspace--list))))))
                  (select-window window)))
              ;; The event should be replayed
              (setq mode xcb:Allow:ReplayPointer))))