using first-client and second-client variables to fix their locations

This commit is contained in:
frese 2003-04-01 13:22:17 +00:00
parent fb2fd2ec65
commit c19af840d8
1 changed files with 36 additions and 69 deletions

View File

@ -22,8 +22,14 @@
(split-wm-handler wm in-channel)))
wm)))
(define (split-wm? wm)
(and (wm? wm) (eq? (wm:type wm) (manager-type split))))
(define (split-wm-handler wm channel)
(let ((resizer-window (create-resizer wm)))
(let ((resizer-window (create-resizer wm))
(dpy (wm:dpy wm))
(first-client #f)
(second-client #f))
(map-window (wm:dpy wm) resizer-window)
(let loop ()
(let ((msg (receive channel)))
@ -31,13 +37,28 @@
((draw-main-window) #t)
((fit-windows)
(fit-windows wm resizer-window))
(fit-windows wm resizer-window first-client second-client))
((init-client)
(init-client wm (second msg) (third msg)))
(let ((client (second msg)))
(if first-client
(set! second-client client)
(set! first-client client))
(set-window-border-width! dpy (client:window client) 0)
(fit-windows wm resizer-window first-client second-client)
(map-window dpy (client:client-window client))
;;(select-client wm client))) ??
))
((deinit-client)
(deinit-client wm (second msg)))
(let ((client (second msg)))
(if (eq? client first-client)
(set! first-client #f))
(if (eq? client second-client)
(set! second-client #f))
;; TODO: destroy switch if only one client left
))
((draw-client-window) #t)
@ -47,51 +68,19 @@
((fit-client-window)
;; client changed it's size ??
(fit-client-window wm (second msg)))
#t)
((update-client-state) #t)
))
(loop))))
;(define (draw-main-window wm gc)
; (let* ((dpy (wm:dpy wm))
; (options (wm:options wm))
; (colors (get-option-value options 'bar-colors))
; (bar-style (get-option-value options 'bar-style))
; (rects (calc-rectangles wm))
; (bar-rect (second rects))
; (win (wm:window wm))
; (x1 (rectangle:x bar-rect))
; (y1 (rectangle:y bar-rect))
; (x2 (+ (rectangle:x bar-rect) (rectangle:width bar-rect) -1))
; (y2 (+ (rectangle:y bar-rect) (rectangle:height bar-rect) -1)))
; (mdisplay "bar drawing: " bar-rect "\n")
; (set-gc-foreground! dpy gc (second colors))
; (fill-rectangle dpy win gc x1 y1
; (rectangle:width bar-rect) (rectangle:height bar-rect))
; (if (and #f (not (eq? bar-style 'flat)))
; (let ((light (if (eq? bar-style 'raised)
; (first colors)
; (third colors)))
; (dark (if (eq? bar-style 'raised)
; (third colors)
; (first colors))))
; (set-gc-line-width! dpy gc 1)
; (set-gc-foreground! dpy gc light)
; (draw-lines dpy win gc (list (cons x1 y2) (cons x1 y1) (cons x2 y1))
; (coord-mode origin))
; (set-gc-foreground! dpy gc dark)
; (draw-lines dpy win gc (list (cons x2 (+ y1 1)) (cons x2 y2)
; (cons x1 y2))
; (coord-mode origin))))))
(define (calc-rectangles wm)
(let* ((options (wm:options wm))
(bar-width (get-option-value options 'bar-width))
(orientation (get-option-value options 'orientation))
(aspect (get-option-value options 'aspect))
(r (clip-rectangle (wm:dpy wm) (wm:window wm))))
(mdisplay "calc-rects: aspect " aspect "\n")
(if (eq? orientation 'horizontal)
(let* ((r1 (make-rectangle 0 0
(floor (/ (- (rectangle:width r) bar-width)
@ -115,47 +104,23 @@
(+ (rectangle:height r1) bar-width)))))
(list r1 r2 r3)))))
(define (fit-windows wm resizer-window)
(define (fit-windows wm resizer-window first-client second-client)
(let* ((rects (calc-rectangles wm))
(clients (wm-clients wm))
(dpy (wm:dpy wm)))
(mdisplay "splitter rects: " rects "\n")
(move-resize-window* dpy resizer-window (second rects))
(if (and (pair? clients) (pair? (cdr clients)))
(if first-client
(move-resize-window* dpy
(client:client-window (second clients))
(client:client-window first-client)
(first rects)))
(if (pair? clients)
(if second-client
(move-resize-window* dpy
(client:client-window (first clients))
(client:client-window second-client)
(third rects)))))
(define (init-client wm client maybe-rect)
(let* ((rects (calc-rectangles wm))
(r (if (> (length (wm-clients wm)) 1)
(third rects)
(first rects))))
(let ((dpy (wm:dpy wm))
(options (wm:options wm)))
(set-window-border-width! dpy (client:window client) 0)
(move-resize-window* dpy (client:client-window client) r)
(map-window dpy (client:client-window client))
;;(select-client wm client))) ??
)))
(define (deinit-client wm client)
(let ((dpy (wm:dpy wm)))
;; maybe destroy-wm ?? TODO
#t))
(define (fit-client-windows wm client)
(let ((dpy (wm:dpy wm)))
(maximize-window dpy (client:window client))))
(define (fit-client-window wm client)
#t)
;; *******************************************************************
;; Resizer
;; *******************************************************************
@ -255,7 +220,9 @@
(if (> aspect 0)
(begin
(set-option! options 'aspect aspect)
(fit-windows wm window))))))
(send (wm:internal-out-channel wm)
'(fit-windows))
)))))
(calc-new-rect
(lambda (start-rect dx dy)
(let ((width (rectangle:width start-rect))