clearified client creation process

fixed some more problems with immediately closed clients
fixed dead-lock problem with wm-select-client
This commit is contained in:
frese 2003-04-22 15:38:19 +00:00
parent 68e7a41372
commit d158788001
1 changed files with 80 additions and 67 deletions

View File

@ -152,16 +152,23 @@
(dpy (wm:dpy wm))) (dpy (wm:dpy wm)))
(case (car msg) (case (car msg)
((manage-window) ((manage-window)
(let* ((window (second msg)) (let ((window (second msg))
(client (create-client wm window)) (maybe-rect (third msg)))
(maybe-rect (third msg))) (let ((client (create-client wm window)))
(set-wm:clients! wm (append (wm:clients wm) (list client))) (set-wm:clients! wm (append (wm:clients wm) (list client)))
(if (window-exists? dpy window)
(map-window dpy window))
(send internal-out-channel
(list 'init-client client maybe-rect))
;;(send internal-out-channel (list 'fit-client client))
;;(send internal-out-channel (list 'update-client-state client))
)))
((configure-window)
(let ((window (second msg))
(changes (third msg)))
(send internal-out-channel (send internal-out-channel
(list 'init-client client maybe-rect)) (list 'configure-window window changes))))
(send internal-out-channel (list 'fit-client client))
;; sync ??
(map-window dpy window)
(send internal-out-channel (list 'update-client-state client))))
((unmanage-window) ((unmanage-window)
(let* ((window (second msg)) (let* ((window (second msg))
@ -225,11 +232,15 @@
;; sync ?? ;; sync ??
) )
(define (wm-configure-window wm window changes)
(send (wm:in-channel wm) (list 'configure-window window changes)))
(define (wm-unmanage-window wm window) (define (wm-unmanage-window wm window)
(send (wm:in-channel wm) (list 'unmanage-window window))) (send (wm:in-channel wm) (list 'unmanage-window window)))
(define (wm-select-client wm client time) (define (wm-select-client wm client time)
(send (wm:in-channel wm) (list 'select-client client time))) (spawn (lambda ()
(send (wm:in-channel wm) (list 'select-client client time)))))
(define (destroy-wm wm) (define (destroy-wm wm)
(send (wm:in-channel wm) '(destroy-manager))) (send (wm:in-channel wm) '(destroy-manager)))
@ -344,8 +355,8 @@
(send internal-out-channel (send internal-out-channel
(list 'draw-client-window client)))) (list 'draw-client-window client))))
((configure-event? xevent) ((configure-event? xevent)
(send internal-out-channel (if (window-exists? dpy (client:window client))
(list 'fit-client client))) (send internal-out-channel (list 'fit-client client))))
((or (focus-change-event? xevent) (circulate-event? xevent)) ((or (focus-change-event? xevent) (circulate-event? xevent))
;; TODO: look at mode? or maybe only look at focus-in of the ;; TODO: look at mode? or maybe only look at focus-in of the
;; client, because the client-window never gets the focus ;; client, because the client-window never gets the focus
@ -370,62 +381,64 @@
(let ((type (any-event-type xevent)) (let ((type (any-event-type xevent))
(internal-out-channel (wm:internal-out-channel wm)) (internal-out-channel (wm:internal-out-channel wm))
(dpy (wm:dpy wm))) (dpy (wm:dpy wm)))
(if (or (destroy-window-event? xevent) (cond
(window-exists? dpy (client:window client))) ((eq? (event-type focus-out) type)
(let ((mode (focus-change-event-mode xevent))
(detail (focus-change-event-detail xevent)))
(if (and (eq? mode (notify-mode normal))
(memq detail (list (notify-detail nonlinear)
(notify-detail nonlinear-virtual)
(notify-detail ancestor))))
;; focus lost -- if window-exists?
(uninstall-colormaps dpy (client:window client)))))
((eq? (event-type focus-in) type)
(let ((mode (focus-change-event-mode xevent))
(detail (focus-change-event-detail xevent)))
(if (and (eq? mode (notify-mode normal))
(memq detail (list (notify-detail nonlinear)
(notify-detail nonlinear-virtual)
(notify-detail ancestor))))
;; focus taken -- if window-exists?
(install-colormaps dpy (client:window client)))))
((property-event? xevent)
(let ((name (get-atom-name (property-event-display xevent)
(property-event-atom xevent))))
(cond (cond
((eq? (event-type focus-out) type) ((equal? "WM_NAME" name)
(let ((mode (focus-change-event-mode xevent)) (send internal-out-channel
(detail (focus-change-event-detail xevent))) (list 'update-client-state client)))
(if (and (eq? mode (notify-mode normal)) ;; TODO: respect NORMAL_HINTS change
(memq detail (list (notify-detail nonlinear) )))
(notify-detail nonlinear-virtual) ((configure-event? xevent)
(notify-detail ancestor)))) ;; TODO: we have to prevent this event if changed the size on our own.
;; focus lost -- if window-exists? ;; --> XReconfigureWMWindow ??
(uninstall-colormaps dpy (client:window client))))) (send internal-out-channel (list 'fit-client-window client))
((eq? (event-type focus-in) type) )
(let ((mode (focus-change-event-mode xevent)) ((reparent-event? xevent)
(detail (focus-change-event-detail xevent))) (if (or (not (window-exists? dpy (client:window client)))
(if (and (eq? mode (notify-mode normal)) (not (eq? (client:client-window client)
(memq detail (list (notify-detail nonlinear) (window-parent dpy (client:window client)))))
(notify-detail nonlinear-virtual) (begin
(notify-detail ancestor)))) (mdisplay "manager " (wm:type wm) " reparented client\n")
;; focus taken -- if window-exists? (wm-deinit-client wm client)
(install-colormaps dpy (client:window client))))) (exit 'reparent))))
((unmap-event? xevent)
((property-event? xevent) ;; might be the transition to withdrawn-state, wm-state
(let ((name (get-atom-name (property-event-display xevent) ;; change by root-manager --> reparent to root ??
(property-event-atom xevent)))) (if (or (not (window-exists? dpy (client:window client)))
(cond (not (eq? (client:client-window client)
((equal? "WM_NAME" name) (window-parent dpy (client:window client)))))
(send internal-out-channel (begin
(list 'update-client-state client))) (wm-deinit-client wm client)
;; TODO: respect NORMAL_HINTS change (exit 'unmap))))
))) ((destroy-window-event? xevent)
((configure-event? xevent) (mdisplay "destroy-window-event client " wm " " client "\n")
;; TODO: we have to prevent this event if changed the size on our own. (if (eq? (client:window client) (destroy-window-event-event xevent))
;; --> XReconfigureWMWindow ?? (begin
(send internal-out-channel (list 'fit-client-window client)) (wm-deinit-client wm client)
) (exit 'destroy))))
((reparent-event? xevent) )))
(if (or (not (window-exists? dpy (client:window client)))
(not (eq? (client:client-window client)
(window-parent dpy (client:window client)))))
(begin
(mdisplay "manager " (wm:type wm) " reparented client\n")
(wm-deinit-client wm client)
(exit 'reparent))))
((unmap-event? xevent)
;; might be the transition to withdrawn-state, wm-state
;; change by root-manager
(wm-deinit-client wm client)
(exit 'unmap))
((destroy-window-event? xevent)
(mdisplay "destroy-window-event client " wm " " client "\n")
(if (eq? (client:window client) (destroy-window-event-event xevent))
(begin
(wm-deinit-client wm client)
(exit 'destroy))))
))))
(define (transients-for-client wm client) (define (transients-for-client wm client)
(filter (lambda (c) (filter (lambda (c)