added a possibility to change the client ordering with the keyboard:

- "M-k t" moves a client to right (swaps with the next client)
  - "M-k r" moves to the left
This commit is contained in:
frese 2004-01-21 20:44:44 +00:00
parent d93266740a
commit 9cfdc62d28
1 changed files with 49 additions and 6 deletions

View File

@ -7,6 +7,8 @@
(font font "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*")
(select-next keys "M-k n")
(select-previous keys "M-k p")
(swap-next keys "M-k t")
(swap-previous keys "M-k r")
)
(define (create-switch-wm out-channel dpy parent options default-options
@ -46,12 +48,11 @@
(data (make-switch-wm-data '() empty-titlebar (cons #f #f))))
(update-titlebars wm data)
(grab-shortcut dpy window
(get-option-value options 'select-next)
'select-next channel #f)
(grab-shortcut dpy window
(get-option-value options 'select-previous)
'select-previous channel #f)
(for-each (lambda (id)
(grab-shortcut dpy window
(get-option-value options id)
id channel #f))
'(select-next select-previous swap-next swap-previous))
(spawn* (list 'switch-wm wm)
(lambda (release)
@ -157,6 +158,9 @@
((select-next) (select-next-client wm (second msg)))
((select-previous) (select-previous-client wm (second msg)))
((swap-next) (swap-titlebar-with-next wm data (second msg)))
((swap-previous) (swap-titlebar-with-previous wm data (second msg)))
((show-clients)
(let ((clients (second msg)))
;; it's a list of a client and it's transients.
@ -352,3 +356,42 @@
(define (select-previous-client wm time)
(select-next-client* wm (reverse (wm-clients wm)) time))
;; ***
(define (swap-titlebar wm data time next?)
(let* ((cc (wm-current-client wm))
(titlebars (if next?
(data:titlebars data)
(reverse (data:titlebars data))))
(before.after
(fold-right (lambda (client.tb result)
(if (eq? (car client.tb) cc)
(cons (cdr result) (cons client.tb (car result)))
(cons (cons client.tb (car result)) (cdr result))))
(cons '() '())
titlebars))
(before (car before.after))
(after (cdr before.after))
(ntitlebars (cond
((null? after) titlebars) ;; cc not in list
((null? (cdr after)) ;; it's the last one
;; this is not really a 'swap', but probably
;; what the user expects
(cons (car after)
before))
(else
(append before
(cons (cadr after)
(cons (car after) (cddr after))))))))
(if next?
(set-data:titlebars! data ntitlebars)
(set-data:titlebars! data (reverse ntitlebars)))
(fit-titlebars wm data)))
(define (swap-titlebar-with-next wm data time)
(swap-titlebar wm data time #t))
(define (swap-titlebar-with-previous wm data time)
(swap-titlebar wm data time #f))