[clfswm-devel] request pull my bugfix patch

Philippe Brochard pbrochard at common-lisp.net
Sun Jan 30 10:21:23 UTC 2011


Desmond O. Chang writes:

> Hi Philippe,
>
> On Sat, Jan 29, 2011 at 06:29, Philippe Brochard
> <pbrochard at common-lisp.net> wrote:
>> Hi, welcome on this list and thanks for your interest in clfswm.
>
> I've used stumpwm for 2 years and discover clfswm recently.  I like
> its concept and try to use it these days.
>
Ah, good!

> I have another question here.  How can I "run-or-raise" a program like
> emacsclient?  I put the following in my clfswmrc.
>
> (defun b1-start-emacs ()
>   "start emacs"
>   (setf *second-mode-leave-function*
>         (lambda ()
>           (let* ((win (find "emacs" (xlib:query-tree *root*)
>                             :key 'xlib:get-wm-class :test 'string-equal)))
>             (if win
>                 (raise-window win)
>                 (do-shell "cd $HOME && exec emacsclient -c")))))
>   (leave-second-mode))
>
> Then I put (define-second-key (#\e) 'b1-start-emacs) in
> *BINDING-HOOK*.  Keybinding works but raising doesn't.
>
> I try to use FOCUS-WINDOW to replace RAISE-WINDOW, I fail again.
>
> Any advice?
>
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

Philippe




More information about the clfswm-devel mailing list