about summary refs log tree commit diff
path: root/exwm-workspace.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2018-02-20T14·17+0800
committerChris Feng <chris.w.feng@gmail.com>2018-02-20T14·17+0800
commitc821f76dfef9d7592b263f8fea789b6da7fbddf4 (patch)
tree5de88d69d27cf572a89114d13af39373c7f5376d /exwm-workspace.el
parentbfa35c0e388e5b4daf27aa162ecb6323f7716c85 (diff)
Use the 'exwm-randr-output' frame parameter to determine the output
* exwm-randr.el (exwm-randr--refresh): Always set the name of primary
output.

* exwm-workspace.el (exwm-workspace-switch)
(exwm-workspace-move-window): Use 'exwm-randr-output' frame parameter
to check if two frames are on the same output.
Diffstat (limited to 'exwm-workspace.el')
-rw-r--r--exwm-workspace.el68
1 files changed, 30 insertions, 38 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 9b0bfeb338..5bd746a897 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -528,18 +528,14 @@ for internal use only."
         ;; Set a default minibuffer frame.
         (setq default-minibuffer-frame frame))
       ;; Show/Hide X windows.
-      (let ((hide-x-windows-on-old-frame
-             (with-slots ((x1 x)
-                          (y1 y))
-                 (exwm-workspace--get-geometry frame)
-               (with-slots ((x2 x)
-                            (y2 y))
-                   (exwm-workspace--get-geometry old-frame)
-                 (and (= x1 x2) (= y1 y2))))))
+      (let ((hide-old-workspace
+             (and old-frame
+                  (eq (frame-parameter old-frame 'exwm-randr-output)
+                      (frame-parameter frame 'exwm-randr-output)))))
         (dolist (i exwm--id-buffer-alist)
           (with-current-buffer (cdr i)
             (if (eq old-frame exwm--frame)
-                (when hide-x-windows-on-old-frame
+                (when hide-old-workspace
                   (exwm-layout--hide exwm--id))
               (when (eq frame exwm--frame)
                 (let ((window (get-buffer-window nil t)))
@@ -703,7 +699,7 @@ INDEX must not exceed the current number of workspaces."
                       (exwm-workspace--prompt-delete-allowed t))
                   (exwm-workspace--prompt-for-workspace "Move to [+/-]: "))))
   (let ((frame (exwm-workspace--workspace-from-frame-or-index frame-or-index))
-        x-old y-old x-new y-new should-hide old-frame container)
+        should-hide old-frame container)
     (unless id (setq id (exwm--buffer->id (window-buffer))))
     (with-current-buffer (exwm--id->buffer id)
       (unless (eq exwm--frame frame)
@@ -715,33 +711,23 @@ INDEX must not exceed the current number of workspaces."
                (concat " " name)))))
         (setq old-frame exwm--frame
               exwm--frame frame)
-        ;; Save the positions of new & old frames.
-        (with-slots ((x1 x)
-                     (y1 y))
-            (exwm-workspace--get-geometry old-frame)
-          (with-slots ((x2 x)
-                       (y2 y))
-              (exwm-workspace--get-geometry frame)
-            (setq x-old x1
-                  y-old y1
-                  x-new x2
-                  y-new y2)))
-        (if (and (= x-old x-new)
-                 (= y-old y-new))
+        (if (eq (frame-parameter old-frame 'exwm-randr-output)
+                (frame-parameter frame 'exwm-randr-output))
             ;; Switch to a workspace on the same output.
             (setq should-hide t)
           ;; Check if this frame has the largest timestamp of that output.
-          (let ((timestamp (frame-parameter frame 'exwm-timestamp))
-                (timestamp-active
-                 (apply #'max
-                        (mapcar (lambda (w)
-                                  (with-slots (x y)
-                                      (exwm-workspace--get-geometry w)
-                                    (if (and (= x x-new)
-                                             (= y y-new))
-                                        (frame-parameter w 'exwm-timestamp)
-                                      -1)))
-                                exwm-workspace--list))))
+          (let* ((timestamp (frame-parameter frame 'exwm-timestamp))
+                 (output (frame-parameter frame 'exwm-randr-output))
+                 (timestamp-active
+                  (apply #'max
+                         (mapcar
+                          (lambda (w)
+                            (or (when (eq output
+                                          (frame-parameter w
+                                                           'exwm-randr-output))
+                                  (frame-parameter w 'exwm-timestamp))
+                                -1))
+                          exwm-workspace--list))))
             (when (< timestamp timestamp-active)
               ;; Switch to a workspace not active on another output.
               (setq should-hide t))))
@@ -762,14 +748,20 @@ INDEX must not exceed the current number of workspaces."
           ;; Floating.
           (setq container (frame-parameter exwm--floating-frame
                                            'exwm-container))
-          (unless (and (= x-old x-new)
-                       (= y-old y-new))
+          (unless (eq (frame-parameter old-frame 'exwm-randr-output)
+                      (frame-parameter frame 'exwm-randr-output))
             (with-slots (x y)
                 (xcb:+request-unchecked+reply exwm--connection
                     (make-instance 'xcb:GetGeometry
                                    :drawable container))
-              (setq x (+ x (- x-new x-old))
-                    y (+ y (- y-new y-old)))
+              (with-slots ((x1 x)
+                           (y1 y))
+                  (exwm-workspace--get-geometry old-frame)
+                (with-slots ((x2 x)
+                             (y2 y))
+                    (exwm-workspace--get-geometry frame)
+                  (setq x (+ x (- x2 x1))
+                        y (+ y (- y2 y1)))))
               (exwm--set-geometry id x y nil nil)
               (exwm--set-geometry container x y nil nil)))
           (if (exwm-workspace--minibuffer-own-frame-p)