From 553fc1c5d5ea8ce0bfd910a42a462e08fa29296b Mon Sep 17 00:00:00 2001 From: frese Date: Mon, 5 May 2003 14:42:01 +0000 Subject: [PATCH] added iconify, maximize modified client selection with show-clients --- src/manager.scm | 77 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/src/manager.scm b/src/manager.scm index 931428b..0742795 100644 --- a/src/manager.scm +++ b/src/manager.scm @@ -1,5 +1,6 @@ (define-options-spec manager-options-spec (focus-policy symbol-list '(enter)) ;; enter, click + (client-cursor cursor xc-X-cursor) ) ;; TODO: focus-policy click does not work yet @@ -84,6 +85,7 @@ (event-mask structure-notify enter-window focus-change + button-press exposure) (lambda (event-channel) (call-with-current-continuation @@ -142,15 +144,22 @@ (time (cadr (property:data p)))) (if (equal? name (intern-atom dpy "WM_TAKE_FOCUS" #f)) (begin - (set-input-focus dpy main-window (revert-to parent) time) + (if (window-viewable? dpy main-window) + (set-input-focus dpy main-window (revert-to parent) + current-time)) (send internal-out-channel - (list 'manager-focused time)))) + (list 'manager-focused current-time)))) (if (equal? name (intern-atom dpy "WM_DELETE_WINDOW" #f)) (if (null? (wm:clients wm)) ;; (destroy-wm wm) would dead-lock (handle-external-message wm exit '(destroy-manager)) (bell dpy 100))) )))) + + ((button-event? xevent) + (if (eq? (event-type button-press) (button-event-type xevent)) + (take-focus dpy main-window (button-event-time xevent)))) + ((destroy-window-event? xevent) (exit 'destroy)) ))) @@ -186,6 +195,24 @@ (wm:clients wm)))) (if client (reparent-to-root dpy window)))) + + ((iconify-window) + (let* ((window (second msg)) + (client (find (lambda (c) + (eq? window (client:window c))) + (wm:clients wm)))) + (if client + (send internal-out-channel + (list 'iconify-client client))))) + + ((maximize-window) + (let* ((window (second msg)) + (client (find (lambda (c) + (eq? window (client:window c))) + (wm:clients wm)))) + (if client + (send internal-out-channel + (list 'maximize-client client))))) ((destroy-manager) (send-message+wait internal-out-channel '(deinit-manager)) @@ -196,23 +223,24 @@ (let ((client (second msg))) (set-wm:clients! wm (filter (lambda (c) (not (eq? c client))) (wm:clients wm))) - (if (eq? (wm:current-client wm) client) - ;; select-client ?? - (set-wm:current-client! wm (and (not (null? (wm:clients wm))) - (car (wm:clients wm))))) (send-message+wait (wm:internal-out-channel wm) (list 'deinit-client client)) + (if (eq? client (wm:current-client wm)) + (set-wm:current-client! wm #f)) (destroy-window dpy (client:client-window client)))) ((select-client) - (let ((client (second msg)) - (time (third msg))) - (for-each (lambda (client) - (set-wm:current-client! wm client) - (raise-window dpy (client:client-window client)) - (if (window-exists? dpy (client:window client)) - (take-focus dpy (client:window client) time))) - (cons client (transients-for-client wm client))))) + (let* ((client (second msg)) + (time (third msg)) + (all (cons client (transients-for-client wm client))) + (top (last all))) + (if (not (eq? top (wm:current-client wm))) + (begin + (send-message+wait (wm:internal-out-channel wm) + (list 'show-clients all)) + (set-wm:current-client! wm top))) + (if (window-exists? dpy (client:window top)) + (take-focus dpy (client:window top) time)))) (else (warn "unhandled manager message" wm msg))))) @@ -235,6 +263,12 @@ (define (wm-unmanage-window wm window) (send (wm:in-channel wm) (list 'unmanage-window window))) +(define (wm-iconify-window wm window) + (send (wm:in-channel wm) (list 'iconify-window window))) + +(define (wm-maximize-window wm window) + (send (wm:in-channel wm) (list 'maximize-window window))) + (define (wm-select-client wm client time) (spawn (lambda () (send (wm:in-channel wm) (list 'select-client client time))))) @@ -279,6 +313,8 @@ (black-pixel dpy))) (in-channel (make-channel)) (client (make-client window client-window in-channel #f #f))) + (define-cursor dpy client-window + (get-option-value (wm:options wm) 'client-cursor)) (reparent-window dpy window client-window 0 0) (create-client-handler wm client) client)) @@ -378,7 +414,10 @@ ;; ((circulate-event? xevent) ;; (send internal-out-channel (list 'update-client-state client))) ((eq? (event-type enter-notify) type) - (if (memq 'enter (get-option-value (wm:options wm) 'focus-policy)) + (if (and (memq 'enter (get-option-value (wm:options wm) 'focus-policy)) + (window-exists? dpy (client:window client)) + (not (eq? client (wm-current-client wm))) + (not (window-contains-focus? dpy (client:window client)))) (wm-select-client wm client (crossing-event-time xevent)))) ;; ((eq? (event-type button-press) type) @@ -434,6 +473,14 @@ (begin (wm-deinit-client wm client) (exit 'destroy)))) + + ((map-event? xevent) + (let* ((s.i (get-wm-state dpy (client:window client))) + (s (and s.i (car s.i)))) + (if (eq? (wm-state iconic) s) + ;; iconic -> normal transition + (send (wm:internal-out-channel wm) + (list 'normalize-client client))))) ))) (define (transients-for-client wm client)