Permalink
Browse files

tilings: auto-tiling predicates

  • Loading branch information...
1 parent 1c55dd8 commit aba5dc97e143d201aa32e748c33235ab6f1f806f @jaor committed Nov 12, 2011
Showing with 17 additions and 8 deletions.
  1. +5 −2 readme.org
  2. +12 −6 tile/tiler.jl
View
@@ -26,8 +26,9 @@
- =top=, =bottom= Top and bottom margins, in pixels (default: 0).
- =gap= Spacing between adjacent windows, in pixels (default: 0).
- =max= Maximum number of visible windows (default: 3).
- - =auto= A boolean indicating whether tiling should happen
- automatically whenever a new window is created (default: t).
+ - =auto= A boolean or predicate indicating whether tiling should
+ happen automatically whenever a new window is created (default:
+ =t=).
- *column tile* Divide the screen in the given number of columns and
distributed windows among them. All columns have the same width
@@ -49,6 +50,8 @@
;; switch among them with 'next-tiling':
(tall-tiling 0 #:width 3 #:top 20 #:bottom 20 #:gap 1 #:max 2 #:auto #f)
(col-tiling 0 #:cols 3 #:gap 2 #:top 40 #:bottom 20)
+ ;; here's a tiling that will only act on urxvt windows:
+ (tall-tiling 2 #:auto (lambda (w) (equal "URxvt" (window-class w))))
(bind-keys global-keymap
"F12" 'tile-workspace
View
@@ -5,6 +5,7 @@
next-tiling
setting
set-setting)
+
(open rep
rep.system
rep.data.tables
@@ -20,11 +21,12 @@
(define (forget w) (table-unset %sizes w))
+ (define (restore-window w)
+ (let ((s (table-ref %sizes w)))
+ (when s (apply push-window (cons w s)))))
+
(define (restore-windows ws)
- (mapc (lambda (w)
- (let ((s (table-ref %sizes w)))
- (when s (apply push-window (cons w s)))))
- (workspace-windows ws)))
+ (mapc restore-window (workspace-windows ws)))
(define (restore-sizes ws)
(mapc (lambda (w)
@@ -63,7 +65,11 @@
(define (tiling-tiler ti) (nth 0 ti))
(define (tiling-settings ti) (nth 1 ti))
- (define (tiling-auto-p ti) (nth 2 ti))
+
+ (define (tiling-auto-p ti w)
+ (let ((p (nth 2 ti)))
+ (if (functionp p) (p w) p)))
+
(define (tiling-name ti) (nth 3 ti))
(define (current-tiler-name) (tiling-name (tiling)))
@@ -74,7 +80,7 @@
(when ti ((tiling-tiler ti) new-window destroyed-window))))
(define (tileable-window-p w)
- (and (tiling-auto-p (tiling (window-workspace w)))
+ (and (tiling-auto-p (tiling (window-workspace w)) w)
(eq (window-type w) 'default)))
(define (add-autotile w)

0 comments on commit aba5dc9

Please sign in to comment.