[clfswm-devel] Two layouts

Ales Guzik ales.guzik at gmail.com
Sat Jan 7 14:18:17 UTC 2012


Here is two layouts i've hacked for myself. Just thought it may be
interesting for someone here. It redefines two already existing
layouts.
First one is a small hack on tile-layout so it switches between
horisontal and vertical tiling depending on whether width or height is
longer, so child frames tend to be squarish.

(defmethod tile-layout (child parent)
  (let* ((managed-children (update-layout-managed-children child parent))
         (pos (child-position child managed-children))
         (len (length managed-children))
         (d1 (ceiling (sqrt len)))
         (d2  (ceiling (/ len d1)))
         (nx (if (> (frame-rw parent) (frame-rh parent)) d1 d2))
         (ny (if (> (frame-rw parent) (frame-rh parent)) d2 d1))
         (dx (/ (frame-rw parent) nx))
         (dy (/ (frame-rh parent) ny))
         (dpos (- (* nx ny) len))
         (width dx))
    (when (plusp dpos)
      (if (zerop pos)
          (setf width (* dx (1+ dpos)))
          (incf pos dpos)))
    (values (round (adj-border-xy (+ (frame-rx parent) (truncate (*
(mod pos nx) dx))) child))
            (round (adj-border-xy (+ (frame-ry parent) (truncate (*
(truncate (/ pos nx)) dy))) child))
            (round (adj-border-wh width child))
            (round (adj-border-wh dy child)))))

Another one is tile-space-layout rewrite so space between screen
border and frame is the same as between frames (now space between
frames twice as large as between screen border and frame)

(defun tile-space-layout (child parent)
  "Tile Space: tile child in its frame leaving spaces between them"
  (with-slots (rx ry rw rh) parent
    (let* ((managed-children (update-layout-managed-children child parent))
           (pos (child-position child managed-children))
           (len (length managed-children))
           (d1 (ceiling (sqrt len)))
           (d2 (ceiling (/ len d1)))
           (cols (if (> rw rh) d1 d2))
           (rows (if (> rw rh) d2 d1))
           (col (mod pos cols))
           (row (floor pos cols))
           (space-percent (or (frame-data-slot parent :tile-space-size) 0.05))
           (col-space-total (* rw space-percent))
           (row-space-total (* rh space-percent))
           (col-space (floor col-space-total (1+ cols)))
           (row-space (floor row-space-total (1+ rows)))
           (child-width (floor (- rw col-space-total) cols))
           (child-height (floor (- rh row-space-total) rows))
           )
      (values (round (print (adj-border-xy (+ rx col-space (* (+
col-space child-width) col)) child)))
              (round (print (adj-border-xy (+ ry row-space (* (+
row-space child-height) row)) child)))
              (round (print (adj-border-wh child-width child)))
              (round (print (adj-border-wh child-height child)))))))

-- 
Regards,
Ales Guzik
------------------------------------------------------------
e-mail: ales.guzik at gmail.com
skype: ales-guzik
tel: +375 29 5751103




More information about the clfswm-devel mailing list