Handle buffer change after a buffer is killed

* exwm-manage.el (exwm-manage--kill-buffer-query-function): Handle buffer
change.

* exwm-workspace.el (exwm-workspace--show-minibuffer): Revert the change
made in 93e42136 (the problem has not been fully resolved).
This commit is contained in:
Chris Feng 2016-03-03 19:34:17 +08:00
parent 93e42136e3
commit fe9be0b3ef
2 changed files with 57 additions and 48 deletions

View file

@ -334,56 +334,57 @@ corresponding buffer.")
(xcb:flush exwm--connection) (xcb:flush exwm--connection)
;; Wait for DestroyNotify event. ;; Wait for DestroyNotify event.
(throw 'return nil)) (throw 'return nil))
;; Try to close the X window with WM_DELETE_WINDOW client message. (let ((id exwm--id))
(xcb:+request exwm--connection ;; Try to close the X window with WM_DELETE_WINDOW client message.
(make-instance 'xcb:icccm:SendEvent
:destination exwm--id
:event (xcb:marshal
(make-instance 'xcb:icccm:WM_DELETE_WINDOW
:window exwm--id)
exwm--connection)))
(xcb:flush exwm--connection)
;;
(unless (memq xcb:Atom:_NET_WM_PING exwm--protocols)
;; The window does not support _NET_WM_PING. To make sure it'll die,
;; kill it after the time runs out.
;; Hide the container to prevent flickering.
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:UnmapWindow :window exwm--container)) (make-instance 'xcb:icccm:SendEvent
:destination id
:event (xcb:marshal
(make-instance 'xcb:icccm:WM_DELETE_WINDOW
:window id)
exwm--connection)))
(xcb:flush exwm--connection) (xcb:flush exwm--connection)
(run-with-timer exwm-manage-ping-timeout nil ;;
`(lambda () (exwm-manage--kill-client ,exwm--id))) (unless (memq xcb:Atom:_NET_WM_PING exwm--protocols)
;; Wait for DestroyNotify event. ;; The window does not support _NET_WM_PING. To make sure it'll die,
(throw 'return nil)) ;; kill it after the time runs out.
;; Try to determine if the X window is dead with _NET_WM_PING. ;; Hide the container to prevent flickering.
(setq exwm-manage--ping-lock t) (xcb:+request exwm--connection
(xcb:+request exwm--connection (make-instance 'xcb:UnmapWindow :window exwm--container))
(make-instance 'xcb:SendEvent (xcb:flush exwm--connection)
:propagate 0 (run-with-timer exwm-manage-ping-timeout nil
:destination exwm--id `(lambda () (exwm-manage--kill-client ,id)))
:event-mask xcb:EventMask:NoEvent ;; Wait for DestroyNotify event.
:event (xcb:marshal (throw 'return nil))
(make-instance 'xcb:ewmh:_NET_WM_PING ;; Try to determine if the X window is dead with _NET_WM_PING.
:window exwm--id (setq exwm-manage--ping-lock t)
:timestamp 0 (xcb:+request exwm--connection
:client-window exwm--id) (make-instance 'xcb:SendEvent
exwm--connection))) :propagate 0
(xcb:flush exwm--connection) :destination id
(with-timeout (exwm-manage-ping-timeout :event-mask xcb:EventMask:NoEvent
(if (yes-or-no-p (format "'%s' is not responding. \ :event (xcb:marshal
(make-instance 'xcb:ewmh:_NET_WM_PING
:window id
:timestamp 0
:client-window id)
exwm--connection)))
(xcb:flush exwm--connection)
(with-timeout (exwm-manage-ping-timeout
(if (yes-or-no-p (format "'%s' is not responding. \
Would you like to kill it? " Would you like to kill it? "
(buffer-name))) (buffer-name)))
(progn (exwm-manage--kill-client exwm--id) (progn (exwm-manage--kill-client id)
;; Kill the unresponsive X window and ;; Kill the unresponsive X window and
;; wait for DestroyNotify event. ;; wait for DestroyNotify event.
(throw 'return nil)) (throw 'return nil))
;; Give up. ;; Give up.
(throw 'return nil))) (throw 'return nil)))
(while (and exwm-manage--ping-lock (while (and exwm-manage--ping-lock
(exwm--id->buffer exwm--id)) ;may have been destroyed. (exwm--id->buffer id)) ;may have been destroyed.
(accept-process-output nil 0.1)) (accept-process-output nil 0.1))
;; Give up. ;; Give up.
(throw 'return nil)))) (throw 'return nil)))))
(defun exwm-manage--kill-client (&optional id) (defun exwm-manage--kill-client (&optional id)
"Kill an X client." "Kill an X client."

View file

@ -513,7 +513,15 @@ The optional FORCE option is for internal use only."
(make-instance 'xcb:MapWindow (make-instance 'xcb:MapWindow
:window (frame-parameter exwm-workspace--minibuffer :window (frame-parameter exwm-workspace--minibuffer
'exwm-container))) 'exwm-container)))
(xcb:flush exwm--connection)) (xcb:flush exwm--connection)
;; Unfortunately we need the following lines to workaround a cursor
;; flickering issue for line-mode floating X windows. They just make the
;; minibuffer appear to be focused.
(with-current-buffer (window-buffer (minibuffer-window
exwm-workspace--minibuffer))
(setq cursor-in-non-selected-windows
(frame-parameter exwm-workspace--minibuffer 'cursor-type))))
(defun exwm-workspace--hide-minibuffer () (defun exwm-workspace--hide-minibuffer ()
"Hide the minibuffer frame." "Hide the minibuffer frame."