[clfswm-devel] Create frames on start

Philippe Brochard pbrochard at common-lisp.net
Sat Oct 20 12:14:48 UTC 2012


[Sorry for the lag again]

Oleksandr Kozachuk writes:

> Hi again!
>
> I would like to create and configure some frames at startup and have now
> this code in my clfswmrc for it:
>
> ;; -----------------------------------------------------------------------------
>
> (defun set-frame-layout-fast (layout &optional (frame (current-child)))
>   (when (frame-p frame)
>     (set-frame-default frame)
>     (setf (frame-layout frame) layout)
>     (show-all-children frame)))
>
> (defun create-bounded-frame (name parent layout &optional (slot nil))
>   (let ((frame (add-frame (create-frame :name name) parent)))
>     (set-frame-layout-fast layout frame)
>     (when slot (bind-child-on-slot slot frame))
>     frame))
>
> (defun ok-init-hook ()
>   (let ((root (create-bounded-frame "Root" *root-frame* #'tile-space-layout)))
>     (let* ((default   (create-bounded-frame "Default"   root #'tile-space-layout 0))
> 	   (devel     (create-bounded-frame "Devel"     root #'tile-space-layout 1))
> 	   (www       (create-bounded-frame "WWW"       root #'tile-space-layout 2))
> 	   (unmanaged (create-bounded-frame "Unmanaged" root #'tile-left-layout  3)))
>       (create-bounded-frame "Devel P2" devel #'tile-left-layout 4)
>       (create-bounded-frame "Devel P1" devel #'tile-left-layout 5)
>       (setf (frame-managed-type unmanaged) nil))
>     (define-as-root root 0 0 (xlib:screen-width *screen*) (xlib:screen-height *screen*))
>     (focus-all-children root root)))
>
> (setf *init-hook* '(ok-init-hook))
>
> ;; -----------------------------------------------------------------------------
>
> It works, but i do not know if it is a goot way to do it, because i
> replace the initialization function fully and i am not sure about root
> frames. How are you doing that?
>
This is perfectly valid code but it'll not work if you plug another
monitor. A better way would be to let CLFSWM make its root
initialization and add your own init hook at the end of the default init
hook and use the CLFSWM structure.

More something like that:

;; -----------------------------------------------------------------------------
(defun my-init-hook ()
  (let* ((parent    (first (frame-child *root-frame*)))
         (default   (first (frame-child parent)))
         (devel     (create-bounded-frame "Devel"     parent #'tile-left-layout  1))
         (www       (create-bounded-frame "WWW"       parent #'tile-space-layout 2))
         (unmanaged (create-bounded-frame "Unmanaged" parent #'tile-left-layout  3)))
    (dbg (child-fullname parent))     ; To see where we are
    (setf (frame-layout parent) #'tile-left-layout
          (frame-name default) "Default"
          (frame-layout default) #'tile-left-layout
          (frame-managed-type unmanaged) nil)
    (bind-on-slot 0 default)
    (create-bounded-frame "Devel P2" devel #'tile-left-layout 4)
    (create-bounded-frame "Devel P1" devel #'tile-left-layout 5)
    (setf (current-child) default)
    (focus-all-children (current-child) parent)
    ;; We can show all children only once at the end of initialization
    (show-all-children)))

(add-hook *init-hook* 'my-init-hook)
;; -----------------------------------------------------------------------------



> Other thing is my "bind-child-on-slot" function, it would be nice to
> have additional optional parameter in the normal "bind-on-slot" function
> which is bound per default to (current-child), instead of using
> (current-child) directly.
>
You're right. This is fixed with the commit c31ef42.

> Best regards,
> Alex.
>
Best regards,

Philippe




More information about the clfswm-devel mailing list