about summary refs log tree commit diff
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
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.
-rw-r--r--exwm-randr.el9
-rw-r--r--exwm-workspace.el68
2 files changed, 35 insertions, 42 deletions
diff --git a/exwm-randr.el b/exwm-randr.el
index f49073c45540..39edb7b1b9be 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -89,7 +89,7 @@ the first one in result being the primary output."
 
 (defun exwm-randr--refresh ()
   "Refresh workspaces according to the updated RandR info."
-  (let (output-name geometry output-plist default-geometry)
+  (let (output-name geometry output-plist primary-output default-geometry)
     ;; Query all outputs
     (with-slots (config-timestamp outputs)
         (xcb:+request-unchecked+reply exwm--connection
@@ -115,8 +115,9 @@ the first one in result being the primary output."
                                             :x x :y y
                                             :width width :height height)
                     output-plist (plist-put output-plist output-name geometry))
-              (unless default-geometry ;assume the first output as primary
-                (setq default-geometry geometry)))))))
+              (unless primary-output
+                (setq primary-output output-name
+                      default-geometry geometry)))))))
     (exwm--log "(randr) outputs: %s" output-plist)
     (when output-plist
       (when exwm-workspace--fullscreen-frame-count
@@ -128,7 +129,7 @@ the first one in result being the primary output."
                (frame (elt exwm-workspace--list i)))
           (unless geometry
             (setq geometry default-geometry
-                  output nil))
+                  output primary-output))
           (set-frame-parameter frame 'exwm-randr-output output)
           (set-frame-parameter frame 'exwm-geometry geometry)))
       ;; Update workareas.
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 9b0bfeb3387d..5bd746a8976e 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)