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.
This commit is contained in:
Chris Feng 2016-02-03 13:23:55 +08:00
parent 9c95c03e18
commit d8281abca4

View file

@ -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--log "Set focus on #x%x" exwm--id)
(exwm-input--set-focus exwm--id) (exwm-input--set-focus exwm--id)
;; Adjust stacking orders ;; Adjust stacking orders
(xcb:+request exwm--connection (if exwm--floating-frame
(make-instance 'xcb:ConfigureWindow ;; Put this floating X window at top.
:window exwm--container (xcb:+request exwm--connection
:value-mask xcb:ConfigWindow:StackMode (make-instance 'xcb:ConfigureWindow
:stack-mode (if exwm--floating-frame :window exwm--container
xcb:StackMode:Above :value-mask xcb:ConfigWindow:StackMode
xcb:StackMode:Below))) :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 (xcb:+request exwm--connection
(make-instance 'xcb:ConfigureWindow (make-instance 'xcb:ConfigureWindow
:window (frame-parameter :window (frame-parameter
(or exwm--floating-frame exwm--frame) (or exwm--floating-frame exwm--frame)
'exwm-outer-id) 'exwm-outer-id)
:value-mask xcb:ConfigWindow:StackMode :value-mask xcb:ConfigWindow:StackMode
:stack-mode xcb:StackMode:Below)) :stack-mode xcb:StackMode:BottomIf))
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
(when (eq (selected-window) exwm-input--focus-window) (when (eq (selected-window) exwm-input--focus-window)
(exwm--log "Focus on %s" exwm-input--focus-window) (exwm--log "Focus on %s" exwm-input--focus-window)