From 1c79e1c2384128915357ea629fc2a0503bd36733 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sat, 20 Feb 2016 14:52:53 +0800 Subject: Prevent/Reduce flickering issues with floating X windows * exwm-floating.el (exwm-floating--set-floating) (exwm-floating--unset-floating): Prevent flickering when creating/removing a floating X window. * exwm-layout.el (exwm-layout--show): Show X windows after resizing to prevent flickering. * exwm-manage.el (exwm-manage--unmanage-window): Reduce flickering by hiding the container. (exwm-manage--kill-buffer-query-function): Prevent flickering by hiding the container (except that the X window destroys itself after receiving the WM_DELETE_WINDOW client message). --- exwm-floating.el | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'exwm-floating.el') diff --git a/exwm-floating.el b/exwm-floating.el index 209539eb4a6c..276948801d95 100644 --- a/exwm-floating.el +++ b/exwm-floating.el @@ -193,17 +193,42 @@ (remove-hook 'window-configuration-change-hook #'exwm-layout--refresh) (set-window-buffer window (current-buffer)) ;this changes current buffer (add-hook 'window-configuration-change-hook #'exwm-layout--refresh) - (set-window-dedicated-p window t) - (exwm-layout--show id window)) - (select-frame-set-input-focus frame)) - (run-hooks 'exwm-floating-setup-hook)) + (set-window-dedicated-p window t)) + (select-frame-set-input-focus frame) + ;; `x_make_frame_visible' autoraises the frame. Force lowering it. + (xcb:+request exwm--connection + (make-instance 'xcb:ConfigureWindow + :window outer-id + :value-mask xcb:ConfigWindow:StackMode + :stack-mode xcb:StackMode:Below)) + ;; Show the X window with its container (and flush). + (exwm-layout--show id window)) + (run-hooks 'exwm-floating-setup-hook) + ;; Redraw the frame. + (redisplay)) (defun exwm-floating--unset-floating (id) "Make window ID non-floating." (let ((buffer (exwm--id->buffer id))) (with-current-buffer buffer - ;; Reparent the frame back to the root window. (when exwm--floating-frame + ;; The X window is already mapped. + ;; Unmap the container to prevent flickering. + (xcb:+request exwm--connection + (make-instance 'xcb:UnmapWindow :window exwm--container)) + (xcb:flush exwm--connection) + ;; Unmap the X window. + (xcb:+request exwm--connection + (make-instance 'xcb:ChangeWindowAttributes + :window id :value-mask xcb:CW:EventMask + :event-mask xcb:EventMask:NoEvent)) + (xcb:+request exwm--connection + (make-instance 'xcb:UnmapWindow :window id)) + (xcb:+request exwm--connection + (make-instance 'xcb:ChangeWindowAttributes + :window id :value-mask xcb:CW:EventMask + :event-mask exwm--client-event-mask)) + ;; Reparent the floating frame back to the root window. (let ((frame-id (frame-parameter exwm--floating-frame 'exwm-outer-id))) (xcb:+request exwm--connection (make-instance 'xcb:UnmapWindow :window frame-id)) -- cgit 1.4.1