[clfswm-devel] Questions / Feature requests regarding the focus policy

Renaud Casenave-Péré renaud at casenave-pere.fr
Mon Mar 25 03:18:30 UTC 2013


On Mon, Mar 25 2013, Philippe Brochard wrote:

> Ok, so we need to hack a new sloppy focus method which follow mouse over
> windows and not only over frames. And we need to move the mouse on the
> new focused window since its position may have changed according to the
> frame layout used. Does something like :sloppy-select-window in commit
> d6b1dd9 do what you want?
> It's not finished code (there is some glitch) but the idea is here.

Yes that's the behavior I was hoping for. Thank you.


> Myself I think I don't like the automatic mouse move.

I just thought of :tile-layout-keep-position when set to false, and you're
right, if the mouse automatically moves, it would feel pretty weird...
Maybe move it only when the focus changes with the keyboard... It's a more
complex change than I thought.


> Ah, so, you can make it the default new window hook:
>
> (setf *default-nw-hook* 'leave-focus-frame-nw-hook)

Oh, very nice. I didn't know it would work for every focus stealing. Thanks.


> Yes you can paste it here or fork clfswm git repo and ask for a git pull
> request.

Here you go:

#+begin_src lisp
(defun three-columns-layout (child parent)
  "Three Colums: main child in the middle, others on the two sides."
  (with-slots (rx ry rw rh) parent
    (let* ((managed-children (update-layout-managed-children child parent))
           (pos (child-position child managed-children))
           (len (max (1- (length managed-children)) 1))
           (dy (round (/ rh (max (truncate (/ (+ (if (oddp pos) 1 0) len) 2)) 1))))
           (size (or (frame-data-slot parent :tile-size) 0.75))
           (other-size (if (> len 1) (/ (- 1 size) 2) (- 1 size))))
      (if (> (length managed-children) 1)
          (if (= pos 0)
              (values (adj-border-xy (if (> len 1)
                                         (round (+ rx (* rw other-size)))
                                         rx) parent)
                      (adj-border-xy ry parent)
                      (adj-border-wh (round (* rw size)) child)
                      (adj-border-wh rh child))
              (values (adj-border-xy (if (oddp pos)
                                         (round (+ rx (* rw (if (> len 1) (+ size other-size) size))))
                                         rx) parent)
                      (adj-border-xy (round (+ ry (* dy (truncate (/ (1- pos) 2))))) parent)
                      (adj-border-wh (round (* rw other-size)) parent)
                      (adj-border-wh dy parent)))
          (no-layout child parent)))))

(defun set-three-columns-layout ()
  "Three Columns: main child in the middle, others on the two sides."
  (layout-ask-size "Tile size in percent (%)" :tile-size)
  (set-layout-managed-children)
  (set-layout #'three-columns-layout))
#+end_src

It's a bit ugly, though... You are free to rewrite it as much as you want.
At least it gets the job done.

> yes, clfswm is very rich and I use myself only a few part of all its
> features :-) 

Yes, I see that :)

-- 
Renaud Casenave-Péré




More information about the clfswm-devel mailing list