about summary refs log tree commit diff
path: root/exwm-input.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-02-03T05·23+0800
committerChris Feng <chris.w.feng@gmail.com>2016-02-03T05·23+0800
commitd8281abca4bc5182040a7866560a1806c59176d4 (patch)
tree6532c71550ec1b685a6d0d7147220287b470591c /exwm-input.el
parent9c95c03e18f6d5cf78bcd54bf00f8055a3863336 (diff)
Avoid unnecessary changes of stacking order
* exwm-input.el (exwm-input--update-focus): Only restack a tiling X window
when it's not the last but one sibling.  This should reduce flickering.
Diffstat (limited to 'exwm-input.el')
-rw-r--r--exwm-input.el30
1 files changed, 22 insertions, 8 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 156399c74486..f84b5fce69a1 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -110,20 +110,34 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
             (exwm--log "Set focus on #x%x" exwm--id)
             (exwm-input--set-focus exwm--id)
             ;; Adjust stacking orders
-            (xcb:+request exwm--connection
-                (make-instance 'xcb:ConfigureWindow
-                               :window exwm--container
-                               :value-mask xcb:ConfigWindow:StackMode
-                               :stack-mode (if exwm--floating-frame
-                                               xcb:StackMode:Above
-                                             xcb:StackMode:Below)))
+            (if exwm--floating-frame
+                ;; Put this floating X window at top.
+                (xcb:+request exwm--connection
+                    (make-instance 'xcb:ConfigureWindow
+                                   :window exwm--container
+                                   :value-mask xcb:ConfigWindow:StackMode
+                                   :stack-mode xcb:StackMode:TopIf))
+              ;; This should be the last X window but one in the siblings.
+              (with-slots (children)
+                  (xcb:+request-unchecked+reply exwm--connection
+                      (make-instance 'xcb:QueryTree
+                                     :window
+                                     (frame-parameter exwm--frame
+                                                      'exwm-workspace)))
+                (unless (eq (cadr children) exwm--container)
+                  (xcb:+request exwm--connection
+                      (make-instance 'xcb:ConfigureWindow
+                                     :window exwm--container
+                                     :value-mask xcb:ConfigWindow:StackMode
+                                     :stack-mode xcb:StackMode:Below)))))
+            ;; Make sure Emacs frames are at bottom.
             (xcb:+request exwm--connection
                 (make-instance 'xcb:ConfigureWindow
                                :window (frame-parameter
                                         (or exwm--floating-frame exwm--frame)
                                         'exwm-outer-id)
                                :value-mask xcb:ConfigWindow:StackMode
-                               :stack-mode xcb:StackMode:Below))
+                               :stack-mode xcb:StackMode:BottomIf))
             (xcb:flush exwm--connection))
         (when (eq (selected-window) exwm-input--focus-window)
           (exwm--log "Focus on %s" exwm-input--focus-window)