[clfswm-devel] request pull my bugfix patch

Desmond O. Chang dochang at gmail.com
Mon Jan 31 03:48:57 UTC 2011


On Sun, Jan 30, 2011 at 18:21, Philippe Brochard
<pbrochard at common-lisp.net> wrote:
> Well, raise-window is a very low function which unhide a window and
> raise it from the xlib view. The clfswm tree is not updated from this
> function. You have to do it yourself.
>
> Here is how I would write run-or-raise. As I like to have all my windows
> in fullscreen, I set *current-child* and *current-root* accordingly.
> Fell free to do as you like.
>
> --------------------------------------------------
> (defun b1-start-emacs ()
>  "start emacs"
>  (setf *second-mode-leave-function*
>        (lambda ()
>          (let ((window (block return-block
>                          (with-all-windows (*root-frame* win)
>                            (when (string-equal "emacs" (xlib:get-wm-class win))
>                              (return-from return-block win))))))
>            (if window
>                (let ((parent (find-parent-frame window)))
>                  (hide-all-children *current-root*)
>                  (setf *current-child* parent
>                        *current-root* parent
>                        (frame-child parent) (nconc (list window) (child-remove window (frame-child parent))))
>                  (show-all-children))
>                (do-shell "cd $HOME && exec emacsclient -c")))))
>  (leave-second-mode))
> --------------------------------------------------
>
> If this do what you want, I can polish the code a bit more :
>  - with an implicit return-block in with-all-windows or with an
>   additional test parameter in find-child.
>  - with a new function put-child-on-top instead of
>   (nconc (list window) (child-remove window (frame-child parent)))
>
>> Thanks,
>> Des
> Hope this helps

Thank you!  Your code works well!

And I put it into a new function RUN-OR-RAISE.

This is the final version in my conffile, for your reference:


(defun run-or-raise (raisep run-fn &key (maximized t))
  (let ((window (block return-block
                  (with-all-windows (*root-frame* win)
                    (when (funcall raisep win)
                      (return-from return-block win))))))
    (if window
        (let ((parent (find-parent-frame window)))
          (hide-all-children *current-root*)
          (setf *current-child* parent
                (frame-child parent)
                (cons window (child-remove window (frame-child parent))))
          (when maximized
            (setf *current-root* parent))
          (show-all-children))
        (funcall run-fn))))

(defun $start-emacs ()
  "start emacs"
  (setf *second-mode-leave-function*
        (lambda ()
          (run-or-raise (lambda (win) (string-equal "emacs"
(xlib:get-wm-class win)))
                        (lambda () (do-shell "cd $HOME && exec
emacsclient -c")))))
  (leave-second-mode))

(defun $start-conkeror ()
  "start conkeror"
  (setf *second-mode-leave-function*
        (lambda ()
          (run-or-raise (lambda (win) (string-equal "Navigator"
(xlib:get-wm-class win)))
                        (lambda () (do-shell "cd $HOME && exec conkeror")))))
  (leave-second-mode))




More information about the clfswm-devel mailing list